Unit 8: Security for Web Applications
Security is fundamentally about protecting assets (data, hardware,
reputation, etc.). Therefore you should
Identify potential threats
Detect and fix vulnerabilities
Know how to react to an attack
A threat is any potential occurrence, malicious or otherwise, that could
harm an asset.
A vulnerability is a weakness that makes a threat possible, due to poor
design, configuration mistakes, and/or inappropriate and insecure coding
An attack is an action that exploits a vulnerability or enacts a threat.
sending malicious input to an application
flooding a network in an attempt to deny service.
dsbw 2008/2009 2q 1
Foundations of Security
Authentication (who are you?): the process of uniquely identifying
the clients of your applications and services.
Authorization (what can you do?): the process that governs the
resources and operations that the authenticated client is permitted
Non-repudiation: guarantees that a user cannot deny performing
an operation or initiating a transaction.
Confidentiality: the process of making sure that data remains
private and confidential, and that it cannot be viewed by
Integrity: the guarantee that data is protected from accidental or
deliberate (malicious) modification.
Availability: systems remain available for legitimate users.
dsbw 2008/2009 2q 2
Main Threat Categories: STRIDE
Spoofing: Attempting to gain access to a system by using a false
identity, eg. using stolen user credentials or a false IP address.
Tampering: Unauthorized modification of data, for example as it
flows over a network between two computers.
Repudiation: The ability of users (legitimate or otherwise) to deny
that they performed specific actions or transactions. Without
adequate auditing, repudiation attacks are difficult to prove
Information disclosure: Unwanted exposure of private data.
Denial of service: The process of making a system or application
Elevation of privilege: Occurs when a user with limited privileges
assumes the identity of a privileged user to gain privileged access to
dsbw 2008/2009 2q 3
Use strong authentication.
Spoofing user identity
Do not store secrets (eg., passwords) in plaintext.
Do not pass credentials in plaintext over the wire.
Protect authentication cookies with SSL.
Use data hashing and signing.
Tampering with data
Use digital signatures.
Use tamper-resistant protocols
Use protocols that provide message integrity.
Create secure audit trails.
Use digital signatures.
Use strong authorization.
Use strong encryption.
Use protocols that provide message confidentiality.
Do not store secrets in plaintext.
Use resource and bandwidth throttling techniques.
Denial of service
Validate and filter input.
The principle of least privilege: use least privileged
Elevation of privilege
accounts to run processes and access resources.
dsbw 2008/2009 2q 4
Core Web Application Security Principles
Compartmentalize Create different security boundaries, zones, with their own
Use least privilege Run processes using accounts with minimal privileges and
Apply defense in depth Use multiple gatekeepers to keep attackers at bay, do not
rely on a single layer of security
Do not trust user input Assume all input is malicious until proven otherwise
Authenticate and authorize callers early — at the first gate
Check at the gate
Fail securely If an application fails, do not leave sensitive data
accessible. Return friendly errors to end users that do not
expose internal system details.
Secure the weakest Identify it, strengthen it, fix it
Create secure defaults Make default users/actions/authorizations set up with least
Reduce your attack Disable or remove unused services, protocols, and
dsbw 2008/2009 2q 5
Web Application Security: The Three-Tiered Approach
dsbw 2008/2009 2q 6
Integrating Security in the WebApp Process
dsbw 2008/2009 2q 7
The RACI Chart (Responsible, Accountable, Consulted, Kept Informed)
Tasks Architect Developer Tester
Security Policies R A
Threat Modeling A I I R
Security Design Principles A I I C
Security Architecture A C R
Architecture and Design
Code Development A R
Technology Specific Threats A R
Code Review R I A
Security Testing C I A C
Network Security C R A
Host Security C A I R
Application Security C I A R
Deployment Review C R I I A
dsbw 2008/2009 2q 8
Network Threats and Countermeasures
Threat Description Countermeasure
Information Port scanning and footprinting to Configure routers to restrict their
Gathering detect device types and vulnerable responses to footprinting requests.
operating systems and application Disable unused protocols and
versions. unnecessary ports.
Sniffing Monitoring traffic on the network for Use encrypted protocols (SSL,
data such as plaintext passwords or IPSec)
Hiding one’s true identity on the
Spoofing Filter packets
network by using fake source
Session Deceiving a server or a client into Use encrypted session negotiation
Hijacking accepting the upstream host as the and communication channels.
actual legitimate host
Denial of Denying legitimate users access to a Increase the size of the TCP
Service server or services, e.g by sending connection queue, decrease the
more requests to a server than it can connection establishment period,
handle (SYN flood attack) and employ dynamic backlog
dsbw 2008/2009 2q 9
Host Threats and Countermeasures
Threat Description Countermeasure
Viruses, Trojan horses, Updated service packs and
and worms software patches
Footprinting port scans, ping sweeps, and Disable unnecessary
NetBIOS enumeration to protocols and ports
glean valuable system-level
Password Cracking Use strong passwords, limit
the number of retry
attempts, do not use default
Denial of Service Deviate traffic to other hosts
Arbitrary Code Execution Executing malicious code on Lock down system
your server by using buffer commands and utilities
Unauthorized Access Unauthorized access to Lock down files and folders
restricted information or with restricted permissions.
dsbw 2008/2009 2q 10
Input validation Buffer overflow: cross-site scripting; SQL injection; canonicalization
Authentication Network eavesdropping; brute force attacks; dictionary attacks; cookie
replay; credential theft
Authorization Elevation of privilege; disclosure of confidential data; data tampering;
Configuration Unauthorized access to administration interfaces; unauthorized access
management to configuration stores; retrieval of clear text configuration data; lack of
individual accountability; over-privileged process and service accounts
Sensitive data Access sensitive data in storage; network eavesdropping; data
Session management Session hijacking; session replay; man in the middle
Cryptography Poor key generation or key management; weak or custom encryption
Parameter manipulation Query string manipulation; form field manipulation; cookie manipulation;
HTTP header manipulation
Exception management Information disclosure; denial of service
Auditing and logging User denies performing an operation; attacker exploits an application
without trace; attacker covers his or her tracks
dsbw 2008/2009 2q 11
Input Validation Do not trust input; consider centralized input validation. Do not rely on
client-side validation. Be careful with canonicalization issues. Constrain.
reject, and sanitize input. Validate for type, length, format, and range.
Authentication Partition site by anonymous, identified, and authenticated area. Use
strong passwords. Support password expiration periods and account
disablement. Do not store credentials (use one-way hashes with salt).
Encrypt communication channels to protect authentication tokens. Pass
Forms authentication cookies only over HTTPS connections.
Authorization Use least privileged accounts. Consider authorization granularity. Enforce
separation of privileges. Restrict user access to system-level resources.
Configuration Use least privileged process and service accounts. Do not store
Management credentials in plaintext. Use strong authentication and authorization on
administration interfaces. Do not use the LSA. Secure the
communication channel for remote administration. Avoid storing sensitive
data in the Web space.
Sensitive Data Avoid storing secrets. Encrypt sensitive data over the wire. Secure the
communication channel. Provide strong access controls on sensitive data
stores. Do not store sensitive data in persistent cookies. Do not pass
sensitive data using the HTTP-GET protocol.
dsbw 2008/2009 2q 12
Application Countermeasures (cont.)
Session Management Limit the session lifetime. Secure the channel. Encrypt the contents of
authentication cookies. Protect session state from unauthorized access.
Cryptography Do not develop your own. Use tried and tested platform features. Keep
unencrypted data close to the algorithm. Use the right algorithm and key
size. Avoid key management (use DPAPI). Cycle your keys periodically.
Store keys in a restricted location.
Parameter Manipulation Encrypt sensitive cookie state. Do not trust fields that the client can
manipulate (query strings, form fields, cookies, or HTTP headers).
Validate all values sent from the client.
Exception Management Use structured exception handling. Do not reveal sensitive application
implementation details. Do not log private data such as passwords.
Consider a centralized exception management framework.
Auditing and Logging Identify malicious behavior. Know what good traffic looks like. Audit and
log activity through all of the application tiers. Secure access to log files.
Back up and regularly analyze log files.
dsbw 2008/2009 2q 13
Web Application Security: Summary
dsbw 2008/2009 2q 14
The coding of messages so as to render them unintelligible to other
than authorized recipients. Many techniques are known for the
conversion of the original message, known as plaintext, into its
encrypted form, known as ciphertext, cipher, or code
Dictionary of Computing. Oxford University Press, 2004
dsbw 2008/2009 2q 15
Roles for Cryptography
Authentication: Digital signatures can be used to identify a
participant in a web transaction or the author of an email message
Authorization: Cryptographic techniques can be used to distribute
a list of authorized users that is all but impossible to falsify.
Confidentiality: Encryption is used to scramble information sent
over networks and stored on servers so that eavesdroppers cannot
access the data's content
Integrity: Methods that are used to verify that a message has not
been modified while in transit. Often, this is done with digitally
signed message digest codes.
Nonrepudiation: Cryptographic receipts are created so that an
author of a message cannot realistically deny sending a message
dsbw 2008/2009 2q 16
Cryptography-based Internet Protocols
Virtual Private Networks (VPN)
Internet Protocol Security (IPSEC)
Point-to-Point Tunneling Protocol (PPTP)
Layer Two Forwarding (L2F)
Layer Two Tunneling Protocol (L2TP)
Secure Multipurpose Internet Mail Extensions (S/MIME)
Pretty Good Privacy
WWW i e-commerce
Secure Electronic Transaction (SET)
dsbw 2008/2009 2q 21
SSL – Secure Socket Layer
TLS – Transport Layer Security
Both provide a secure transport connection between clients and
Authentication of the server, using digital signatures
Authentication of the client, using digital signatures
Data confidentiality through the use of encryption
Data integrity through the use of message authentication codes
SSL was developed by Netscape
SSL version 3.0 has been widely used on the Internet
SSL evolved into TLS (RFC 2246)
TLS can be viewed as SSL v3.1
dsbw 2008/2009 2q 22
SSL Record Protocol
message authentication and integrity protection
SSL Handshake Protocol
negotiation of security algorithms and parameters
server authentication and optionally client authentication
SSL Alert Protocol
error messages (fatal alerts and warnings)
SSL Change Cipher Spec Protocol
a single message that indicates the end of the SSL handshake
dsbw 2008/2009 2q 24
SSL sessions and connections
An SSL session is an association between a client and a server
SSL sessions are stateful: the session state includes security
algorithms and parameters
A SSL session may include multiple secure connections between
the same client and server
SSL sessions are used to avoid expensive negotiation of new
security parameters for each connection
dsbw 2008/2009 2q 25
SSL Record Protocol: Processing
type version length
type version length
msg authentication and
encryption (with padding if necessary)
type version length MAC padding
dsbw 2008/2009 2q 26
SSL Handshake Protocol
client_hello Phase 1: Negotiation of the session ID, key exchange
algorithm, MAC algorithm, encryption algorithm, and
exchange of initial random numbers
Phase 2: Server may send its certificate and key
exchange message, and it may request the client
to send a certificate. Server signals end of hello
Phase 3: Client sends certificate if requested and may
client_key_exchange send an explicit certificate verification message.
Client always sends its key exchange message.
Phase 4: Change cipher spec and finish handshake
dsbw 2008/2009 2q 27
Web Security, Privacy & Commerce, 2nd Edition, by Simson
Garfinkle with Gene Spafford, O'Reilly, 2001.
Improving Web Application Security: Threats and
Countermeasures, by Microsoft Corporation, Microsoft Press, 2003
dsbw 2008/2009 2q 28