CS 3250 Software Testing

23
Spring 2021 – University of Virginia 1 © Praphamontripong Bypass Testing of Web Applications CS 3250 Software Testing [Offutt, Papadimitrious, Praphamontripong, “A Case Study on Bypass Testing of Web Applications”] [Based in part on SWE 642 (Software Engineering for the World Wide Web), by Offutt] [Offutt, Wu, Du, and Huang,“Bypass Testing ofWeb Applications”]

Transcript of CS 3250 Software Testing

Page 1: CS 3250 Software Testing

Spring 2021 – University of Virginia 1© Praphamontripong

Bypass Testingof Web Applications

CS 3250Software Testing

[Offutt, Papadimitrious, Praphamontripong, “A Case Study on Bypass Testing of Web Applications”][Based in part on SWE 642 (Software Engineering for the World Wide Web), by Offutt]

[Offutt, Wu, Du, and Huang, “Bypass Testing ofWeb Applications”]

Page 2: CS 3250 Software Testing

Spring 2021 – University of Virginia 2© Praphamontripong

Deploying Software • Bundled – pre-installed on computer

• Shrink-wrap – bought and installed by end-users

• Contract – purchaser pays developer to develop and install

• Embedded – installed on a device

• Web – hosted on web servers, executed across the Internet through HTTP

Page 3: CS 3250 Software Testing

Spring 2021 – University of Virginia 3© Praphamontripong

• Apr 2016: Clicking the browser back button while using the TurboTax web software caused a user to lose information

• Feb 2015: Anthem suffered data breach

• Jan 2014: Dropbox outage caused customers to lose information

• Aug 2013: Amazon hosting service failure caused business to lose information and revenue

• Sep 2012: Cyberattack on Bank of America, JPMorgan Chase, Citigroup, US Bank, Wells Fargo, and PNC resulted in denial of services

415

502

665

781

913

1,03

0

1,16

3

1,37

3

1,57

5

1,76

6

2,02

3

2,23

2

2,49

5

2,72

8

2,95

6

3,18

6

3,42

5

0

500

1,000

1,500

2,000

2,500

3,000

3,500

4,000

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

Years

Number of Internet Users World Widefrom 2000-2016 (in millions)

• Jun 2012: Clicking the browser back button after successfully logging off Amazon website exposed payment information of the recent order

• Mar 2012: BodyShop website turned a buy-one-get-one 50% off to a half price each item

• Feb 2011: Over 120,000 users were unable to access email accounts due to Google mail service outage

• Sep 2011: Failures at Target delayed and canceled many customers’ orders

Web App Software Failures

[http://www.cs.virginia.edu/~up3f/cs3250/slides/UP_defense.pdf]

Page 4: CS 3250 Software Testing

Spring 2021 – University of Virginia 4© Praphamontripong

Web Applications

Development and deployment methods – extremely loosely coupled, browser based clients, HTTP stateless,

vulnerable to input manipulation

Web server

Web client

Web component1

Web component2

Web componentn

DBHttpServlet

Request

HTTPRequest

HTTPresponse

HttpServletResponse

Data

Validate data

Validate data

Bad data:• Corrupts DB• Crashes server• Security attacks

Page 5: CS 3250 Software Testing

Spring 2021 – University of Virginia 5© Praphamontripong

Bypass testing• Users can easily “bypass” client-side constraint

enforcement

• Bypass testing constructs tests to intentionally violate constraints:

� Eases test automation� Validates input validation� Checks robustness� Evaluates security

[Offutt, Wu, Du, and Huang, “Bypass Testing ofWeb Applications”]

Page 6: CS 3250 Software Testing

Spring 2021 – University of Virginia 6© Praphamontripong

Simple Example Web AppLet’s consider a simple web app

http://www.cs.virginia.edu/~up3f/cs3250/inclass/client-side-validation.html

Proper behavior vs. bypass behavior

Users can save and modify the HTML, and then run the modified HTML (to interact with the server)

Page 7: CS 3250 Software Testing

Spring 2021 – University of Virginia 7© Praphamontripong

Applying Bypass Testing• Analyze HTML to extract form elements

• Model constraints imposed by HTML and JavaScript

• Rules for test input generation:

� From client-side constraints

� Typical security violations

� Common input mistakes

Page 8: CS 3250 Software Testing

Spring 2021 – University of Virginia 8© Praphamontripong

Analyze HTMLto extract form elements

Page 9: CS 3250 Software Testing

Spring 2021 – University of Virginia 9© Praphamontripong

POTD 10: Identify ElementsOpen the following web app via a web browser

https://cs3250.uk.r.appspot.com/calculategpa-bypass.jsp

1. Consider source code (open page source)

2. Identify elements that can be “bypassed”

Page 10: CS 3250 Software Testing

Spring 2021 – University of Virginia 10© Praphamontripong

Model constraints imposed by

HTML and JavaScript

Page 11: CS 3250 Software Testing

Spring 2021 – University of Virginia 11© Praphamontripong

Types of Client-side Validation• Performed by HTML form controls, their attributes, and client-side scripts that access DOM

• Two categories:

• HTML validation – uses elements in HTML to define input fields (controls) to limit user inputs

• Scripting validation – uses scripts to validate form data

Page 12: CS 3250 Software Testing

Spring 2021 – University of Virginia 12© Praphamontripong

HTML Validation• Length constraints

• Max number of characters allowed in a text field (maxlength)

• Value constraints• Sets of specific values the user can submit for an input selection

(hidden inputs, menu controls, boolean controls, read-only inputs)

• Transfer mode constraints• How data are transmitted from the browser to the web server (GET,

POST, PUT, DELETE, HEAD, TRACE, OPTIONS, CONNECT, PATCH)

• Field element constraints• Data fields that are submitted to the app (rendered and non-

rendered)

• Target URL constraints• URLs the users are allowed to navigate from the current screen

Page 13: CS 3250 Software Testing

Spring 2021 – University of Virginia 13© Praphamontripong

Scripting Validation• Data type constraints

• Types of data to be transmitted to the server (integer check)

• Data format constraints• Format of data to be transmitted to the server (phone format)

• Data value constraints• Data values when fields have semantic restriction (age range)

• Inter-value constraints• Fields that must be submitted together (credit # + expire date)

• Invalid characters constraints• Invalid strings that can cause reliability or security threats to the

server (<, >, ../, &)

Page 14: CS 3250 Software Testing

Spring 2021 – University of Virginia 14© Praphamontripong 14

Example Interface:Yahoo Registration Form

Limited Length (HTML)

Preset Values (HTML)Preset Transfer Mode in form definition (HTML)

Preset No of Fields (HTML)

URL with preset Values (HTML)

Data Value, Type, & Formatvalidation (script)

Inter Value validation (script)

[https://cs.gmu.edu/~offutt/documents/theses/vpapadim-thesispresent.ppt]

Page 15: CS 3250 Software Testing

Spring 2021 – University of Virginia 15© Praphamontripong

POTD 10: Model ConstraintsOpen the following web app via a web browser

https://cs3250.uk.r.appspot.com/calculategpa-bypass.jsp

1. Consider source code (open page source)

2. Identify client-side validation

Page 16: CS 3250 Software Testing

Spring 2021 – University of Virginia 16© Praphamontripong

Rules for test input generation

Page 17: CS 3250 Software Testing

Spring 2021 – University of Virginia 17© Praphamontripong

(some) Client-side Constraint Rules• Violate size restrictions on strings

• Introduce values not included in static choices (e.g., radio buttons, checkboxes, select (drop-down) lists)

• Violate hard-coded values

• Use values that are considered as errors (domain-specific)

• Change HTTP transfer mode (GET, POST, …)

• Change destination URLs

Page 18: CS 3250 Software Testing

Spring 2021 – University of Virginia 18© Praphamontripong

(some) Server-side Constraint Rules• Data type conversion

• Data format validation

• Inter-field constraint validation

• Inter-request data field (cookies, sessions, hidden inputs)

Page 19: CS 3250 Software Testing

Spring 2021 – University of Virginia 19© Praphamontripong

(some) Security Violation Rules

Potential illegal character SymbolEmpty stringCommas ,Single and double quotes ‘ or “Tag symbols < and >Directory paths ../Strings starting with a forward slash /Strings starting with a period .Ampersands &Control character NewlineScript symbols <javascript> or <vbscript>

[Offutt, Bypass Testing, November 2020]

Page 20: CS 3250 Software Testing

Spring 2021 – University of Virginia 20© Praphamontripong

POTD 10: Construct Bypass Tests1. Construct bypass tests for

https://cs3250.uk.r.appspot.com/calculategpa-bypass.jsp

2. For each test you designed, encode your test using URL rewriting

For example, to create a valid test with 2 courses

courseCount = 2courseName1 = C1, courseGrade1 = A, courseCredit1 = 3 courseName2 = C2, courseGrade2 = B, courseCredit2 = 3Expected output: GPA = 3.5

https://cs3250.uk.r.appspot.com/calculategpa-bypass.jsp?courseCount=2&courseName1=C1&courseCredit1=3&courseGrade1=A&courseName2=C2&courseCredit2=3&courseGrade2=B

Page 21: CS 3250 Software Testing

Spring 2021 – University of Virginia 21© Praphamontripong

• Actual output ≠ expected output à failure

• Failure behavior• Exception reports that should not be shown to the user

• Storing invalid data on the server

• Security access violations

• Valid responses – 4 types:• V1: The app acknowledges the invalid request and provides an

explicit message regarding the violation

• V2: The server produces a generic error message

• V3: The app apparently ignores the invalid request and produces an appropriate response

• V4: The app apparently ignores the request

Research: AutoBypass Testing

Page 22: CS 3250 Software Testing

Spring 2021 – University of Virginia 22© Praphamontripong

Result: AutoBypass Testing

v

[Offutt, Papadimitrious, Praphamontripong, “A Case Study on Bypass Testing of Web Applications”]

Page 23: CS 3250 Software Testing

Spring 2021 – University of Virginia 23© Praphamontripong

Wrap-Up• Bypass testing can reveal errors in web apps

• Inexpensive to test web apps (resources and human labor)

• Efficient method creating limited test cases

• The ideas have been applied to the server-side validation

Don’t trust users!!!

Apply input validation to all inputs