SlideShare a Scribd company logo
CNIT 129S: Securing
Web Applications
Ch 1: Web Application (In)security
Web Applications
• E-commerce, Social networks, Online
banking, etc.
• Fundamental security problem:
• Users can supply arbitrary input
• Malicious input can compromise the site
Static Website: Web 1.0
• Information flows 

one-way
• Users don't log in, shop, 

or submit comments
• An attacker who exploits flaws in the Web server
software can
• Steal data on the Web server (usually only
public data anyway)
• Deface the site
Modern Web App
• Two-way 

information flow
• Users log in, 

submit content
• Content dynamically generated and tailored for
each user
• Much data is sensitive and private (e.g. passwords)
• Most apps developed in-house
• Developers often naive about security
Common Web App
Functions
• Shopping (Amazon)
• Social networking (Facebook)
• Banking (Citibank)
• Web search (Google)
• Auctions (eBay)
• Gambling (Betfair)
• Web logs (Blogger)
• Web mail (Gmail)
• Interactive information (Wikipedia)
Internal Web Apps
("Cloud" Services)
• HR -- payroll information, performance reviews
• Admin interfaces to servers, VMs, workstations
• Collaboration software (SharePoint)
• Enterprise Resource Planning (ERP)
• Email web interfaces (Outlook Web Access)
• Office apps (Google Apps, MS Office Live)
Benefits of Web Apps
• HTTP is lightweight and connectionless
• Resilient in event of communications errors
• Can be proxied and tunneled over other
protocols
• Web browsers run on many devices, highly
functional, easy to use
• Many platforms and development tools available
Web App Security
• Breaches are common
• Attackers gets sensitive data, possibly
complete control of back-end systems
• Denial of Service at Application Level
This Site is Secure
100%
Secure
Online
Voting
• Link Ch 1b
Study by Text Authors
CNIT 129S: Securing Web Applications Ch 1-2
• Link Ch 1c
• Link Ch 1d
The Core Security Problem
• Users Can Submit Arbitrary Input
• Alter parameters, cookies, HTTP headers
• Client-side controls can't be trusted
• Developers must assume all input is
malicious
• Attackers have attack tools like Burp; they are
not restricted to using browsers
Possible Attacks
• Change the price of an item
• Modify a session token to enter another user's
account
• Remove parameters to exploit logic flaws
• SQL injection
• SSL doesn't stop any of these
Key Problem Factors
• Underdeveloped Security Awareness
• Custom Development
• Deceptive Simplicity
• Easy to make a website, but hard to secure it
• Rapidly Evolving Threat Profile
• Resource and Time Constraints
• Overextended Technologies
• Increasing Demands on Functionality
The New Security Perimeter
• Edge firewalls and "bastion hosts" are no longer enough
• Keeping the attacker out of critical systems
• Customers can now send transactions to servers
holding private data
• Via the Web app
• Web app must act as a security barrier
• Often it includes components from others, like widgets
• Errors by other companies can compromise your
servers
• Attackers can attack users instead of servers
• XSS, drive-by downloads, etc.
• E-mail used for password recovery
• A compromised email account exposes many
other services also
The New Security Perimeter
The Future
• Some vulnerabilities
are decreasing
• #1 security
measure: UPDATES
• Logic flaws and
failure to use controls
properly are not
decreasing
• Link Ch 1e
CNIT 129S: Securing
Web Applications
Ch 2: Core Defense Mechanisms
Core Defense Elements
• Limiting user access to app's data and
functionality
• Limiting user input to prevent exploits that use
malformed input
• Frustrating attackers with appropriate behavior
when targeted
• Administrative monitoring and configuring the
application
Handling User Access
• Authentication
• Session management
• Access Control
Authentication
• Username and password is most common
method
• Better: additional credentials and multistage
login
• Best: client certificates, smartcards, challenge-
response tokens
• Also: self-registration, account recovery,
password change
CNIT 129S: Securing Web Applications Ch 1-2
Common Login Problems
• Predictable usernames
• Password that can be guessed
• Defects in logic
Session Management
• Session: a set of data structures that track the state of
the user
• A token identifies the session, usually a cookie
• Can also use hidden form fields or the URL query
string
• Sessions expire
Common Session Problems
• Tokens are predictable (not random)
• Tokens poorly handled, so an attacker can
capture another user's token
Access Control
• Each request must be permitted or denied
• Multiple roles within application
• Frequent logic errors and flawed assumptions
Handling User Input
• "Input Validation" is the most common solution
Types of Input
• Arbitrary text, like blog posts
• Cookies
• Hidden form fields
• Parameters
• HTTP header fields, like User-Agent
"Reject Known Bad"
• Also called "blacklisting"
• Least effective method
• Difficult to identify all bad inputs
"Accept Known Good"
• Also called "whitelisting"
• Most effective technique, where feasible
• However, sometimes you can't do it
• Human names really contain apostrophes, so
you can't filter them out
Sanitization
• Render dangerous input harmless
• HTML-Encoding: Space becomes %20, etc.
• Difficult if several kinds of data may be present
within an item of input
• Boundary validation is better (four slides
ahead)
Safe Data Handling
• Write code that can't be fooled by malicious
data
• SQL parameterized queries
• Don't pass user input to an OS command line
• Effective when it can be applied
Semantic Checks
• Some malicious input is identical to valid input
• Such as changing an account number to
another customer's number
• Data must be validated in context
• Does this account number being to the
currently logged-in user?
Difficulties with Simple Input
Validation
• Data coming from user is "bad" or "untrusted"
• The server-side app is "good" and trusted
• Many different types of input with different
filtering requirements
• Apps may chain several processing steps
together
• Data may be harmless at one stage, but be
transformed into harmful data at another stage
Boundary Validation
• Trust boundary
• Divides a trusted zone from an untrusted zone
• Clean data that passes a boundary
• Such as from the user into an application
Boundary Validation
• Each component treats its input as potentially
malicious
• Data validation performed at each trust
boundary
• Not just between client and server
Example
Example SOAP Request
• Link Ch 2a
Boundary Validation
Example
• 1. App gets login: username and password
• Allows only good characters, limits length,
removes known attack signatures
• 2. App performs a SQL query to verify
credentials
• Escape dangerous characters
Boundary Validation
Example
• 3. Login succeeds; app passes data from user
profile to a SOAP service
• XML metacharacters are encoded to block
SOAP injection
• 4. App displays user's account information back
to the user's browser
• User-supplied data is HTML-encoded to block
XSS
Filtering Problems
• App removes this string:
• <script>
• So attacker sends this
• <scr<script>ipt>
Multistep Validation
• App first removes
../
• Then removes
..
• Attacker sends
..../
Canonicalization
• App gets URL-encoded data from Web browser
• Apostrophe is %27
• Percent is %25
• To block apostrophes, app filters %27
• But URL is decoded twice by mistake
• %2527 becomes %27 becomes apostrophe
Handling Attackers
• Handling errors
• Maintaining audit logs
• Alerting administrators
• Reacting to attacks
Handling Errors
• Show appropriate error messages
• Unhanded errors lead to overly-informative
error messages like this
Audit Logs
• Authentication events: login success and
failure, change of password
• Key transactions, such as credit card payments
• Access attempts that are blocked by access
control mechanisms
• Requests containing known attack strings
• For high security, log every client request in full
Protecting Logs
• Logs should contain time, IP addresses, and username
• May contain cookies and other sensitive data
• Attackers will try to erase and/or read logs
• Log must be protected
• Place on an autonomous system that only accepts
update messages
• Flush logs to write-once media
Alerting Administrators
• Usage anomalies, like a large number of
requests from the same IP address or user
• Business anomalies, such as a large number of
funds transfers to/from the same account
• Requests containing known attack strings
• Requests where hidden data has been modified
Firewalls
• Web App Firewalls can detect generic attacks
• But not subtle ones that are specific to your
app
• Most effective security control is integrated with
app's input validation mechanisms
• Check for valid values of your parameters
Reacting to Attacks
• Attackers probe for vulnerabilities
• Sending many similar requests
• Automated defenses
• Respond increasingly slowly to requests
• Terminate the attacker's session
Managing the Application
• Management interface allows administrator to
control user accounts, roles, access monitoring,
auditing, etc.
Attacking the Administration
Panel
• Defeat weak authentication
• Some administrative functions might not require
high privileges
• XSS flaws can allow cookie theft and session
hijacking

More Related Content

PDF
CNIT 129S - Ch 3: Web Application Technologies
PDF
CNIT 129S: Ch 3: Web Application Technologies
PDF
CNIT 129S: Ch 4: Mapping the Application
PDF
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
PPT
Secure code practices
PDF
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
PPTX
Command injection
PPT
HTTP Basics
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 4: Mapping the Application
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Secure code practices
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
Command injection
HTTP Basics

What's hot (20)

PDF
Ch 12 Attacking Users - XSS
PDF
CNIT 129S: 8: Attacking Access Controls
PDF
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
PDF
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
PPTX
Xss attack
ODP
OAuth2 - Introduction
PPTX
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
PDF
Broken access control
PPTX
Rest API Security
PPTX
Web API authentication and authorization
PDF
Bug Bounty Hunter Methodology - Nullcon 2016
PDF
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
PPTX
A2 - broken authentication and session management(OWASP thailand chapter Apri...
PPTX
Http and its Applications
PPTX
PPTX
Single sign on - SSO
PPTX
PDF
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
PPTX
REST API Design & Development
PPTX
Cross Site Scripting ( XSS)
Ch 12 Attacking Users - XSS
CNIT 129S: 8: Attacking Access Controls
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
Xss attack
OAuth2 - Introduction
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Broken access control
Rest API Security
Web API authentication and authorization
Bug Bounty Hunter Methodology - Nullcon 2016
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
A2 - broken authentication and session management(OWASP thailand chapter Apri...
Http and its Applications
Single sign on - SSO
OWASP Top 10 Vulnerabilities - A5-Broken Access Control; A6-Security Misconfi...
REST API Design & Development
Cross Site Scripting ( XSS)
Ad

Viewers also liked (20)

PDF
CNIT 129S: Ch 6: Attacking Authentication
PDF
CNIT 121: 12 Investigating Windows Systems (Part 2 of 3)
PDF
CNIT 121: 2 IR Management Handbook
PDF
CNIT 121: 11 Analysis Methodology
PDF
CNIT 121: 12 Investigating Windows Systems (Part 3)
PDF
CNIT 129S: Ch 5: Bypassing Client-Side Controls
PDF
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
PDF
CNIT 40: 6: DNSSEC and beyond
PDF
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
PDF
CNIT 121: 6 Discovering the Scope of the Incident & 7 Live Data Collection
PDF
CNIT 121: 3 Pre-Incident Preparation
PDF
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
PDF
CNIT 121: Computer Forensics Ch 1
PDF
CNIT 40: 3: DNS vulnerabilities
PDF
CNIT 128 Ch 4: Android
PDF
CNIT 129S: 11: Attacking Application Logic
PDF
CNIT 127 Ch Ch 1: Before you Begin
PDF
Is Your Mobile App Secure?
PDF
CNIT 129S: Ch 7: Attacking Session Management
PDF
CNIT 128 Ch 3: iOS
CNIT 129S: Ch 6: Attacking Authentication
CNIT 121: 12 Investigating Windows Systems (Part 2 of 3)
CNIT 121: 2 IR Management Handbook
CNIT 121: 11 Analysis Methodology
CNIT 121: 12 Investigating Windows Systems (Part 3)
CNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: 9: Attacking Data Stores (Part 1 of 2)
CNIT 40: 6: DNSSEC and beyond
CNIT 121: 4 Getting the Investigation Started on the Right Foot & 5 Initial D...
CNIT 121: 6 Discovering the Scope of the Incident & 7 Live Data Collection
CNIT 121: 3 Pre-Incident Preparation
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 121: Computer Forensics Ch 1
CNIT 40: 3: DNS vulnerabilities
CNIT 128 Ch 4: Android
CNIT 129S: 11: Attacking Application Logic
CNIT 127 Ch Ch 1: Before you Begin
Is Your Mobile App Secure?
CNIT 129S: Ch 7: Attacking Session Management
CNIT 128 Ch 3: iOS
Ad

Similar to CNIT 129S: Securing Web Applications Ch 1-2 (20)

PDF
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
PDF
CNIT 129S - Ch 6a: Attacking Authentication
PDF
Ch 6: Attacking Authentication
PPTX
Lock it Down: Access Control for IBM i
PDF
CNIT 129: 6. Attacking Authentication
PPTX
Introduction to Web Security
PDF
Secure Coding BSSN Semarang Material.pdf
PDF
Building an Identity Management Business Case
PPTX
Complete Guide to Setup Secure Scheme for Restful APIs
PDF
Web security uploadv1
PPTX
Securing Applications in the Cloud
PDF
OWASP TOP 10 by Team xbios
PPT
Threats of Database in ECommerce
PPT
PDF
#MFSummit2016 Secure: Is your mainframe less secure than your fileserver
PDF
CNIT 160 4e Security Program Management (Part 5)
PDF
Ch 13: Attacking Users: Other Techniques (Part 2)
PPTX
Owasp security testing methodlogies –part2
PPTX
SharePoint Authentication And Authorization SPTechCon San Francisco
PPTX
How to Test for The OWASP Top Ten
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
CNIT 129S - Ch 6a: Attacking Authentication
Ch 6: Attacking Authentication
Lock it Down: Access Control for IBM i
CNIT 129: 6. Attacking Authentication
Introduction to Web Security
Secure Coding BSSN Semarang Material.pdf
Building an Identity Management Business Case
Complete Guide to Setup Secure Scheme for Restful APIs
Web security uploadv1
Securing Applications in the Cloud
OWASP TOP 10 by Team xbios
Threats of Database in ECommerce
#MFSummit2016 Secure: Is your mainframe less secure than your fileserver
CNIT 160 4e Security Program Management (Part 5)
Ch 13: Attacking Users: Other Techniques (Part 2)
Owasp security testing methodlogies –part2
SharePoint Authentication And Authorization SPTechCon San Francisco
How to Test for The OWASP Top Ten

More from Sam Bowne (20)

PDF
Introduction to the Class & CISSP Certification
PDF
Cyberwar
PDF
3: DNS vulnerabilities
PDF
8. Software Development Security
PDF
4 Mapping the Application
PDF
3. Attacking iOS Applications (Part 2)
PDF
12 Elliptic Curves
PDF
11. Diffie-Hellman
PDF
2a Analyzing iOS Apps Part 1
PDF
9 Writing Secure Android Applications
PDF
12 Investigating Windows Systems (Part 2 of 3)
PDF
10 RSA
PDF
12 Investigating Windows Systems (Part 1 of 3
PDF
9. Hard Problems
PDF
8 Android Implementation Issues (Part 1)
PDF
11 Analysis Methodology
PDF
8. Authenticated Encryption
PDF
7. Attacking Android Applications (Part 2)
PDF
7. Attacking Android Applications (Part 1)
PDF
5. Stream Ciphers
Introduction to the Class & CISSP Certification
Cyberwar
3: DNS vulnerabilities
8. Software Development Security
4 Mapping the Application
3. Attacking iOS Applications (Part 2)
12 Elliptic Curves
11. Diffie-Hellman
2a Analyzing iOS Apps Part 1
9 Writing Secure Android Applications
12 Investigating Windows Systems (Part 2 of 3)
10 RSA
12 Investigating Windows Systems (Part 1 of 3
9. Hard Problems
8 Android Implementation Issues (Part 1)
11 Analysis Methodology
8. Authenticated Encryption
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 1)
5. Stream Ciphers

Recently uploaded (20)

PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Pre independence Education in Inndia.pdf
PDF
Business Ethics Teaching Materials for college
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Cell Types and Its function , kingdom of life
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
master seminar digital applications in india
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
TR - Agricultural Crops Production NC III.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Microbial diseases, their pathogenesis and prophylaxis
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Pre independence Education in Inndia.pdf
Business Ethics Teaching Materials for college
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Complications of Minimal Access Surgery at WLH
Basic Mud Logging Guide for educational purpose
Cell Types and Its function , kingdom of life
01-Introduction-to-Information-Management.pdf
Cell Structure & Organelles in detailed.
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Insiders guide to clinical Medicine.pdf
master seminar digital applications in india

CNIT 129S: Securing Web Applications Ch 1-2

  • 1. CNIT 129S: Securing Web Applications Ch 1: Web Application (In)security
  • 2. Web Applications • E-commerce, Social networks, Online banking, etc. • Fundamental security problem: • Users can supply arbitrary input • Malicious input can compromise the site
  • 3. Static Website: Web 1.0 • Information flows 
 one-way • Users don't log in, shop, 
 or submit comments • An attacker who exploits flaws in the Web server software can • Steal data on the Web server (usually only public data anyway) • Deface the site
  • 4. Modern Web App • Two-way 
 information flow • Users log in, 
 submit content • Content dynamically generated and tailored for each user • Much data is sensitive and private (e.g. passwords) • Most apps developed in-house • Developers often naive about security
  • 5. Common Web App Functions • Shopping (Amazon) • Social networking (Facebook) • Banking (Citibank) • Web search (Google) • Auctions (eBay) • Gambling (Betfair) • Web logs (Blogger) • Web mail (Gmail) • Interactive information (Wikipedia)
  • 6. Internal Web Apps ("Cloud" Services) • HR -- payroll information, performance reviews • Admin interfaces to servers, VMs, workstations • Collaboration software (SharePoint) • Enterprise Resource Planning (ERP) • Email web interfaces (Outlook Web Access) • Office apps (Google Apps, MS Office Live)
  • 7. Benefits of Web Apps • HTTP is lightweight and connectionless • Resilient in event of communications errors • Can be proxied and tunneled over other protocols • Web browsers run on many devices, highly functional, easy to use • Many platforms and development tools available
  • 8. Web App Security • Breaches are common • Attackers gets sensitive data, possibly complete control of back-end systems • Denial of Service at Application Level
  • 9. This Site is Secure
  • 11. Study by Text Authors
  • 15. The Core Security Problem • Users Can Submit Arbitrary Input • Alter parameters, cookies, HTTP headers • Client-side controls can't be trusted • Developers must assume all input is malicious • Attackers have attack tools like Burp; they are not restricted to using browsers
  • 16. Possible Attacks • Change the price of an item • Modify a session token to enter another user's account • Remove parameters to exploit logic flaws • SQL injection • SSL doesn't stop any of these
  • 17. Key Problem Factors • Underdeveloped Security Awareness • Custom Development • Deceptive Simplicity • Easy to make a website, but hard to secure it • Rapidly Evolving Threat Profile • Resource and Time Constraints • Overextended Technologies • Increasing Demands on Functionality
  • 18. The New Security Perimeter • Edge firewalls and "bastion hosts" are no longer enough • Keeping the attacker out of critical systems • Customers can now send transactions to servers holding private data • Via the Web app • Web app must act as a security barrier • Often it includes components from others, like widgets • Errors by other companies can compromise your servers
  • 19. • Attackers can attack users instead of servers • XSS, drive-by downloads, etc. • E-mail used for password recovery • A compromised email account exposes many other services also The New Security Perimeter
  • 20. The Future • Some vulnerabilities are decreasing • #1 security measure: UPDATES • Logic flaws and failure to use controls properly are not decreasing • Link Ch 1e
  • 21. CNIT 129S: Securing Web Applications Ch 2: Core Defense Mechanisms
  • 22. Core Defense Elements • Limiting user access to app's data and functionality • Limiting user input to prevent exploits that use malformed input • Frustrating attackers with appropriate behavior when targeted • Administrative monitoring and configuring the application
  • 23. Handling User Access • Authentication • Session management • Access Control
  • 24. Authentication • Username and password is most common method • Better: additional credentials and multistage login • Best: client certificates, smartcards, challenge- response tokens • Also: self-registration, account recovery, password change
  • 26. Common Login Problems • Predictable usernames • Password that can be guessed • Defects in logic
  • 27. Session Management • Session: a set of data structures that track the state of the user • A token identifies the session, usually a cookie • Can also use hidden form fields or the URL query string • Sessions expire
  • 28. Common Session Problems • Tokens are predictable (not random) • Tokens poorly handled, so an attacker can capture another user's token
  • 29. Access Control • Each request must be permitted or denied • Multiple roles within application • Frequent logic errors and flawed assumptions
  • 30. Handling User Input • "Input Validation" is the most common solution
  • 31. Types of Input • Arbitrary text, like blog posts • Cookies • Hidden form fields • Parameters • HTTP header fields, like User-Agent
  • 32. "Reject Known Bad" • Also called "blacklisting" • Least effective method • Difficult to identify all bad inputs
  • 33. "Accept Known Good" • Also called "whitelisting" • Most effective technique, where feasible • However, sometimes you can't do it • Human names really contain apostrophes, so you can't filter them out
  • 34. Sanitization • Render dangerous input harmless • HTML-Encoding: Space becomes %20, etc. • Difficult if several kinds of data may be present within an item of input • Boundary validation is better (four slides ahead)
  • 35. Safe Data Handling • Write code that can't be fooled by malicious data • SQL parameterized queries • Don't pass user input to an OS command line • Effective when it can be applied
  • 36. Semantic Checks • Some malicious input is identical to valid input • Such as changing an account number to another customer's number • Data must be validated in context • Does this account number being to the currently logged-in user?
  • 37. Difficulties with Simple Input Validation • Data coming from user is "bad" or "untrusted" • The server-side app is "good" and trusted • Many different types of input with different filtering requirements • Apps may chain several processing steps together • Data may be harmless at one stage, but be transformed into harmful data at another stage
  • 38. Boundary Validation • Trust boundary • Divides a trusted zone from an untrusted zone • Clean data that passes a boundary • Such as from the user into an application
  • 39. Boundary Validation • Each component treats its input as potentially malicious • Data validation performed at each trust boundary • Not just between client and server
  • 42. Boundary Validation Example • 1. App gets login: username and password • Allows only good characters, limits length, removes known attack signatures • 2. App performs a SQL query to verify credentials • Escape dangerous characters
  • 43. Boundary Validation Example • 3. Login succeeds; app passes data from user profile to a SOAP service • XML metacharacters are encoded to block SOAP injection • 4. App displays user's account information back to the user's browser • User-supplied data is HTML-encoded to block XSS
  • 44. Filtering Problems • App removes this string: • <script> • So attacker sends this • <scr<script>ipt>
  • 45. Multistep Validation • App first removes ../ • Then removes .. • Attacker sends ..../
  • 46. Canonicalization • App gets URL-encoded data from Web browser • Apostrophe is %27 • Percent is %25 • To block apostrophes, app filters %27 • But URL is decoded twice by mistake • %2527 becomes %27 becomes apostrophe
  • 47. Handling Attackers • Handling errors • Maintaining audit logs • Alerting administrators • Reacting to attacks
  • 48. Handling Errors • Show appropriate error messages • Unhanded errors lead to overly-informative error messages like this
  • 49. Audit Logs • Authentication events: login success and failure, change of password • Key transactions, such as credit card payments • Access attempts that are blocked by access control mechanisms • Requests containing known attack strings • For high security, log every client request in full
  • 50. Protecting Logs • Logs should contain time, IP addresses, and username • May contain cookies and other sensitive data • Attackers will try to erase and/or read logs • Log must be protected • Place on an autonomous system that only accepts update messages • Flush logs to write-once media
  • 51. Alerting Administrators • Usage anomalies, like a large number of requests from the same IP address or user • Business anomalies, such as a large number of funds transfers to/from the same account • Requests containing known attack strings • Requests where hidden data has been modified
  • 52. Firewalls • Web App Firewalls can detect generic attacks • But not subtle ones that are specific to your app • Most effective security control is integrated with app's input validation mechanisms • Check for valid values of your parameters
  • 53. Reacting to Attacks • Attackers probe for vulnerabilities • Sending many similar requests • Automated defenses • Respond increasingly slowly to requests • Terminate the attacker's session
  • 54. Managing the Application • Management interface allows administrator to control user accounts, roles, access monitoring, auditing, etc.
  • 55. Attacking the Administration Panel • Defeat weak authentication • Some administrative functions might not require high privileges • XSS flaws can allow cookie theft and session hijacking