T10
Track
5/7/2009 11:15:00 AM"Practical Security Testing for
Web Applications"
Presented by:
Rafal Los
Hewlett-Packard Application Security Center
Rafal Los
Rafal Los is currently a Sr. Security Consultant with Hewlett-Packard’s Application Security Center (ASC). Rafal has over 13 years of experience in network and system design, security policy and process design, risk analysis, penetration testing and consulting. Over the past eight years, he has focused on Information Security and Risk Management, leading security
architecture teams and managing successful enterprise security programs for General Electric and other Fortune 100 companies, as well as SMB enterprises. Previously Rafal spent three years in-house with GE Consumer Finance, leading its security programs.
Practical Security Testing
for Web Applications
24 February 2009
1
for Web Applications
Rafal M. Los Rafal M. Los
HP ASC Sr. Security Solutions Expert HP ASC Sr. Security Solutions Expert
Agenda
Agenda
y
Understanding the QA/Security Relationshipy
Negative Testing 360°y
Building Negative Testsy
Implementation and ExecutionAgenda
Agenda
y
Understanding the QA/Security Relationshipy
Negative Testing 360°y
Building Negative Testsy
Implementation and Executiony
Looking Ahead24 February 2009
3
Looking Ahead
Background
Why do QA teams care about security?
• Traditionally securityis left to the security team
• Security issues must be addressed throughout SDL • QA teams add missing element
QA teams are crucial to security • Understand application test-cases • Understand application workflows • Security is a natural extension of quality
QA – Security Relationship
Similarities – core principles • Testing web application logic • Functional testing on live code • Specific data-sets used
Differences – outlying goals Differences – outlying goals
24 February 2009
5
• Stress-test vs. break test • Positive vs. negative data sets
• Reinforcing positive vs. uncovering negative
The “Hacker” Mindset
y Why would anyone want to break an application?
y Fun y Malice y Profit y Attack users y Attack systems y Mentality difference
y QA asks How does it perform? y QA asks – How does it perform? y Hacker asks – How can I break it?
Whose Problem is Security?
y Many components to the security “problem”
y Policyy
y Development frameworks/standards y Audit
y Metrics
y Security is a pillar of overall quality
y Does it function? f 24 February 2009 7 y Does it perform? y y Is it secure?Is it secure?
Agenda
Agenda
y
Understanding the QA/Security Relationshipy
Negative Testing 360°y
Building Negative Testsy
Implementation and ExecutionNegative Testing Overview
What is negative testing?
y Testing for unintended featuresy Testing using unintended data sets y Testing for unintended logic flow
“ l d d h l d
24 February 2009
9
“Negative testing involves understanding the application, and finding ways to manipulate the code to perform in ways as to create unintended exposures”
Negative Testing Overview
Selection bias
Æ
Confirmation bias
y Testing to confirm desired resultsconfirm desired results
y Testing using known desired data and flknown desired data and flows y Testing which completely misses the point…
“ confirmation bias is a tendency to search for or interpret …confirmation bias is a tendency to search for or interpret new information in a way that confirms one's preconceptions and to avoid information and interpretations which
Negative Testing Mindset
Traditional QA: proving the positive
• Prove certain activity functions as defined by business case
• Requirements are easily defined in application flow and function
Negative testing: finding the negative
24 February 2009
11
• Find negative (unintended) functions/results
• No way to clearly define “bad stuff ” as a requirement to test against
Negative Testing - Data
Types of negative data depends on purpose
•• Exploit a clientExploit a client
• Client-side script or technology •• Corrupt or crash a systemCorrupt or crash a system
• Database control characters
• Non-native character sets, system characters • S t d
• System commands
•• Retrieve data from the systemRetrieve data from the system
• Database queries, control language • System commands
Negative Testing - Flow
Goal is to manipulate application logic
Goal is to manipulate application logic
Identify “breakable” application logic
• Create a race condition
• Break application control-flow
• Force an out of processaction • Inject a rogue process
24 February 2009
13
Test-cases based off of proper application logic flows
Requires in-depth knowledge of application flow
Negative Testing - Tools
Tools are an integral part of
negative testing
•• Manual tools
Manual tools
• Flow diagrams
• Data sets
• Logic charts
•• Automated tools
Automated tools
g
g
•• Automated tools
Automated tools
• Black-box scanners
Negative Testing - Tools
W kfl b l biliti
Automated tools *cannot* perform all testing
• Workflow-base vulnerabilities…
• Analyze the application logic and data
Human beings must…
24 February 2009 15 • Guide tools • Interpret results
Agenda
Agenda
y
Understanding the QA/Security Relationshipy
Negative Testing 360°y
Building Negative Testsy
Implementation and ExecutionBuilding the Test
24 February 2009
17
Building Data-Negative Tests
All possible inputs All possible inputs
Negative Test Data Negative Test Data
Data-unknown (unknown impact) p p p p •Letters •Numbers •Special characters •Control characters Situational Refinement •Database ÆSQLi •Client-side ÆXSS •XMLdbÆX-Path.i Allowed (positive) characters Case-specific
malicious •Cross-site scripting •SQL Injection
Building Data-Negative Tests
y
y Manual human testingManual human testing
y Must build test data sets manuallyy
y Sniper approach (can be precise)
y Often very slow, methodical
y Identifies false-positives
y
y ToolsTools--based testingbased testing
y Builds test data sets automatically
h h
24 February 2009
19
y Shotgun approach (not precise)
y Ability to be extremely fast
y Trouble with false-positives
Negative Data Sets
Facts about negative datay Negative data sets are best generated by tools if the tester g g y is not
a security expert
y Many pre-built negative data sets already exist
y Sla.ckers.org – XSS cheat-sheet
y Tools can point Æclick Ætest
y Black-box testing tools save time & effort y Humans must analyze results
y Must mix positive/negative data for completeness
y Workflows often require good data to proceed
Flow Analysis Testing
Can a process step be bypassed? Can a process step be bypassed? Submit quoteCan a process step be injected? Can a process step be injected?
Step 1 Step 2 Step 3 Step 4
Verify Identity Request quote Receive quote Submit for purchase
Step 1 Step 2 Step 3 Step 4
Submit quote for someone
else?
24 February 2009
21
Verify Identity Request quote Receive quote
Injected!
Modify quote Submit for purchase
Flow Analysis Testing
y
y Manual human testingManual human testing
y Can analytically identify specific y y y p weakpointsp
y Distinguishes between success/failure readily
y Often very slow, methodical
y Ability to tailor testing to situation/process
y
y ToolsTools--based testingbased testing
y Attacks every point, cannot distinguish
ff l d h f l
y Difficulty distinguishing success/failure
y Ability to be extremely fast
Flow Analysis Testing
Facts about flow analysis testingy Tester must understand application flowpp
y Proper application flow to turn into negative y “Random manipulation” rarely works
y Focus on application control-points
y Key points in application logic
y Don’t leave your testing to tools-only
y Most tools can’t identify control points, dive deep into flows
24 February 2009
23
y Human analyst has an obvious advantage (critical thinking)
Agenda
Agenda
y
Understanding the QA/Security Relationshipy
Negative Testing 360°y
Building Negative Testsy
Implementation and ExecutionNegative Testing Process
Analyze Requirements
Build Test Sets
Test Negative Analyze Findings[3]
24 February 2009
25
Test Positive Data
Test Negative Data[1]
Test Positive Flow
Test Negative Flow[2]
Testing Negative Data
1. Identify all visible inputs (data “source”)i. Input positive datap p
y Analyze behavior
ii. Input negative data
y Analyze behavior
2. Identify all hidden fields (data “source”)
i. Input positive data
y Analyze behaviorAnalyze behavior
ii. Input negative data
Testing Negative Flow
… as we’ve learned this will be manual worky Map out all control-flowsp
y Identify a potentially weak logic element
y Walk the positive-control flow path
y Ensure proper positive path is understood
y Map possible negative-control flow paths y Execute negative-control flow paths
A l diff b i i / i
24 February 2009
27
y Analyst difference between positive/negative attempts y Repeat if necessary to adjust/adapt until satisfied
y Attempt at least 3-5 loop-repetitions
Identify Weaknesses
y How do you identify a weakness/defect
y Undesired application reactionpp
y Crash?
y Skip control step?
y Disclosure of unintended data
y Debug information
y Disclosure of internal data
Agenda
Agenda
y
Understanding the QA/Security Relationshipy
Negative Testing 360°y
Building Negative Testsy
Implementation and Executiony
Looking Ahead 24 February 2009 29 Looking AheadLooking Ahead
Looking Ahead
y Addressing “deep” defects
y
y WorkflowWorkflow--basedbased security defects
y Traditionally cannot be scanned for cannot be scanned for (with automated tools)
y Analysis of Defects
y When is a critical defectcritical defect… not?
Questions?
• Security Strategist• Application Security Specialist • Security Strategist
• Application Security Specialist
• Following the White Rabbit:
http://www.communities.hp.com/securitysoftware/blogs/rafal
• Digital Security SoapBox: http://preachsecurity.blogspot.com/
• Following the White Rabbit:
http://www.communities.hp.com/securitysoftware/blogs/rafal
• Digital Security SoapBox: http://preachsecurity.blogspot.com/
24 February 2009 31 • Email: [email protected] • Direct: (404) 606-6056 • Email: [email protected] • Direct: (404) 606-6056