hacker proof web app using functional tests

33
HACKER-PROOF WEB APP USING FUNCTIONAL TESTS Ankita Gupta Anamika Singh

Upload: ankita-gupta

Post on 14-Jun-2015

720 views

Category:

Engineering


2 download

DESCRIPTION

Learn how to Hacker proof app using Functional Tests. Presented at SeleniumConf 2014.

TRANSCRIPT

Page 1: Hacker Proof web  app using Functional tests

HACKER-PROOF WEB APP USING FUNCTIONAL TESTSAnkita Gupta

Anamika Singh

Page 2: Hacker Proof web  app using Functional tests

Presenters

Ankita GuptaSoftware Engineer, QA@LinkendIn

@_ankitag_

Page 3: Hacker Proof web  app using Functional tests

Presenters

Anamika SinghProduct Analyst @ IronWASP Information Security Services

Author of WiHawk – Router Vulnerability Scanner

@_Anamikas_

Page 4: Hacker Proof web  app using Functional tests

Importance of Web app Security

Page 5: Hacker Proof web  app using Functional tests

Importance of Web app Security• Web Application breach can lead to:

• Theft of data• Malware infection• Loss of consumer confidence• Failure to meet regulatory requirements• Eventual loss of hundreds of thousands, even millions of dollars.

• According to studies 8 out of 10 sites are Vulnerable.

Page 6: Hacker Proof web  app using Functional tests

Types of Attack• SQL Injection• Cross Site Scripting• Denial of Service• Code Execution• Cross Site Request Forgery

And many more …

Page 7: Hacker Proof web  app using Functional tests
Page 8: Hacker Proof web  app using Functional tests
Page 9: Hacker Proof web  app using Functional tests

Find Security Bugs

Security Experts• Expensive• Time consuming

Page 10: Hacker Proof web  app using Functional tests

Find Security Bugs

Automated Scanning using Web Security Scanners

Scanner :• A program which interacts to web application like an User.

• It performs Black box testing.

• It find misconfigurations and code level Vulnerabilities.• Cheap• runs 24*7

Page 11: Hacker Proof web  app using Functional tests

How Scanner Works• Crawls site and find injection points.

• Test Each point for Security problem by injecting different payloads.

• Payloads are not random text, predefined possible values for Security problems.

• For each security we have corresponding input.

Page 12: Hacker Proof web  app using Functional tests

How Scanner Works• Each scanner has their own algorithm

• What payloads , Analysis

• Passive Approach • It will look at request and response and tries to identify security

problems.

Page 13: Hacker Proof web  app using Functional tests

Challenges of Automated Scanning

Page 14: Hacker Proof web  app using Functional tests

Challenges of Automated Scanning

Page 15: Hacker Proof web  app using Functional tests

Challenges of Automated Scanning

• Automated Login

• Infinite Web Site

• Multipage Sequence

Page 16: Hacker Proof web  app using Functional tests

HOW?..??

Page 17: Hacker Proof web  app using Functional tests

Solutions:

• Manually provide all possible input to Scanner.• Time Consuming• Inefficient

Page 18: Hacker Proof web  app using Functional tests

Better Approach

• Use Functional test cases automation.

• Enterprises use framework like Selenium to automate Functional testing.

How about we integrate Selenium test cases and Automated Scanner?

Page 19: Hacker Proof web  app using Functional tests

Combine Selenium with IronWASP

Page 20: Hacker Proof web  app using Functional tests

IronWASP

• IronWASP is an open source Web Security Scanner.

• Its one among best Scanners.

• Checks for more than 25 Vulnerabilities.

• It stands better than commercial scanner in some parameters.

Page 21: Hacker Proof web  app using Functional tests

IronWASP is better than other Scanner

Page 22: Hacker Proof web  app using Functional tests

Benefits

• Automated Scanner has valid inputs now for all possible cases.

• Follows Correct flow on web page.

• Time/Cost effective.

Page 23: Hacker Proof web  app using Functional tests

Demo IronWasp

Page 24: Hacker Proof web  app using Functional tests

A Simple Functional Test

public void test() throws InterruptedException {

WebDriver driver = new FirefoxDriver();

driver.get(“abc.com");System.out.println(driver.getTitle());driver.quit();

}

Page 25: Hacker Proof web  app using Functional tests

Setup IronWasp Library• Add Library to Build Path.

• Add IronWaspConfig.xml to <MainFolder>/resources/

• AND WE ARE GOOD TO GO!!

Page 26: Hacker Proof web  app using Functional tests

Routing Traffic to IronWasppublic static WebDriver createDriver() { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.http", IronWasp.ipAddress); profile.setPreference("network.proxy.http_port", IronWasp.portNumber); profile.setPreference("network.proxy.ssl", IronWasp.ipAddress); profile.setPreference("network.proxy.ssl_port", IronWasp.portNumber); profile.setPreference("network.proxy.no_proxies_on",""); return driver = new FirefoxDriver(profile);}

Page 27: Hacker Proof web  app using Functional tests

An IronWasp Integrated Test Case

public void test() throws InterruptedException { IronWasp.workflowStart(); WebDriver driver=FirefoxBrowser.createDriver(); driver.get(“abc.com"); System.out.println(driver.getTitle()); IronWasp.workflowEnd(); driver.quit();}

Page 28: Hacker Proof web  app using Functional tests

Demo TestNG/Junit• Create a wrapper for creating broswers.

• Create A base class which calls IronWasp Library in start and end of every test case.

• All test cases should inherit the Base class.

Page 29: Hacker Proof web  app using Functional tests

Advantages• No special Security Auditing needed.

• Easy understandable reports.

• Can fix Security Issues early in SDLC.

• Can prevent major design/architectural changes.

• No more ransom to Bug Bounty Hunters.

Page 30: Hacker Proof web  app using Functional tests

Area of improvements• Speed and Effectiveness:

• Current system replays each test case repeatedly. Very time consuming.

• Current system does not work properly for JavaScript heavy websites.

• Coverage:• Current system does not test for client-side vulnerabilities.• Current system does not discover features that are not covered by

the test case.

• Reporting:• Current system only generates report, no integration with bug

tracking software.

Page 31: Hacker Proof web  app using Functional tests

Area of improvements• Management:

• Current system needs to be started every time a test suite needs to be run.

• If it crashes during a scan then it needs to be manually detected and restarted.

• Bug Fix verification can only be done by manually comparing the reports.

• Cannot handle parallel functional testing traffic from multiple users.

• Configuration wise:• Configuring proxy settings in web driver.• Sending API calls at the start and end of each test case.

Page 32: Hacker Proof web  app using Functional tests

Issue Types

• Scanners are unable to find flaws in business logic.

• More complicated attacks are found by people.

Page 33: Hacker Proof web  app using Functional tests

References• IronWasp : http://ironwasp.net / http://ironwasp.org

• Mutillidae : http://sourceforge.net/projects/mutillidae

• Github : https://github.com/Ankitagupta2309/IronWasp/

• Special Thanks to Lavakumar Kuppan, Author@IronWasp