ben smith and laurie williams

25
1 Using SQL Hotspots in a Prioritization Heuristic for Detecting All Types of Web Application Vulnerabilities Ben Smith and Laurie Williams

Upload: kaiyo

Post on 21-Jan-2016

38 views

Category:

Documents


0 download

DESCRIPTION

Using SQL Hotspots in a Prioritization Heuristic for Detecting All Types of Web Application Vulnerabilities. Ben Smith and Laurie Williams. Input Validation Vulnerabilities. There is a plethora of proposed mitigation techniques, no solution eliminates all vulnerabilities. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Ben Smith and Laurie Williams

1

Using SQL Hotspots in a Prioritization Heuristic for Detecting All Types of Web

Application Vulnerabilities

Ben Smith and Laurie Williams

Page 2: Ben Smith and Laurie Williams

2

Page 3: Ben Smith and Laurie Williams

Input Validation Vulnerabilities

• There is a plethora of proposed mitigation techniques, no solution eliminates all vulnerabilities.

• In the CWE/SANS Top 25 for 2009.• Continue to be in the CWE/SANS Top 25

for 2010.• Also indicated by SANS as the most

common attacks for compromising web sites.

3

Page 4: Ben Smith and Laurie Williams

How do we stop this?

• Development organizations do not have the time or resources to detect vulnerabilities in every source file before release.

• Validation and verification must be prioritized to start with vulnerable files first.

• SQL hotspots may help with this prioritization process.

• Though typically associated with SQL injection, hotspots may be useful for predicting any type of vulnerability.

4

Page 5: Ben Smith and Laurie Williams

Goal

The goal of this research is to improve the prioritization of security fortification efforts by investigating the ability of SQL hotspots to be used as the basis for a heuristic for the prediction of all vulnerability types.

5

Page 6: Ben Smith and Laurie Williams

Agenda

• What are SQL hotspots?

• Case Studies– Projects– Methodology

• Results: Eight Hypotheses about Hotspots

• Conclusion: A heuristic for prioritizing V&V efforts

6

Page 7: Ben Smith and Laurie Williams

SQL Hotspot

A SQL Hotspot is any point in the application source code where the program interacts with a database management system.

Typically indicated with mysql_query() or other library functions in PHP.

7

Page 8: Ben Smith and Laurie Williams

8

SQL Hotspots (2)

$username = $_POST[‘username’];$password = $_POST[‘password’];

$result = mysql_query(“select * from users where username =‘$username’ AND password = ‘$password’”);

$firstresult = mysql_fetch_array($result);

$role = $firstresult[‘role’];

$_COOKIE[‘userrole’] = $role

Page 9: Ben Smith and Laurie Williams

Study Subjects

• WordPress– Advanced blog management– 74% bloggers run WordPress– Uses MySQL and PHP– 138,967 SLOC

• WikkaWiki– Wiki management system– 532 websites are using WikkaWiki– Uses MySQL and PHP– 46,025 SLOC

9

Page 10: Ben Smith and Laurie Williams

10

Page 11: Ben Smith and Laurie Williams

CWE Classifications

11

WordPress WikkaWiki

Page 12: Ben Smith and Laurie Williams

Tracing Vulnerabilities to Files

12

WikkaWiki WordPress

Page 13: Ben Smith and Laurie Williams

Detecting Hotspots

13

Page 14: Ben Smith and Laurie Williams

Prediction Model

• Contained two terms: no. hotspots, SLOC

• Logistic regression

• Trained on releases 1…N, tested on release N+1. (1.0 to 1.3, tested on 1.4).

• tp, tn, fp, fn

14

Page 15: Ben Smith and Laurie Williams

Descriptive Statistics

WordPress WikkaWiki

Releases Analyzed Nine Six

Security reports analyzed

97 61

Vulnerable files 26% (85 / 326) 29% (44 / 209)

Average hotspots 255 92

Average files having at least one hotspot

14.2% 8.42%

15

Used open source tools R to test statisticalhypotheses, and Weka for model evaluation.

Page 16: Ben Smith and Laurie Williams

Hypotheses about Files

H1: The more hotspots a file contains per line of code, the more likely it is that the file contains any type of web application vulnerability (Logit, p < 0.05).

H2: The more hotspots a file contains, the more times that file was changed due to any kind of vulnerability (SLR, p < 0.0001, Adjusted R2 = 0.4208, 0.3802).

16

Page 17: Ben Smith and Laurie Williams

Hypotheses about Issue Reports

H3: Input validation vulnerabilities result in a higher number average repository revisions than any other type of vulnerability.

(Consistent with SANS report).

Mann-Whitney-Wilcoxon Test

(p < 0.05)

17

Page 18: Ben Smith and Laurie Williams

Hypotheses about Prediction

H4: Hotspots can be used to predict files that will contain any type of web application vulnerability in the current release (predictive model that does better than a random guess).

H5: The more hotspots a file contains, the more likely that file will be vulnerable in the next release (coefficients on predictive model).

18

Page 19: Ben Smith and Laurie Williams

Model Performance - WordPress

19

Page 20: Ben Smith and Laurie Williams

Hypotheses Comparing Projects

H6: The average number of hotspots per file is more variable in WordPress than WikkaWiki. (F-test, p < 0.000001)

H7: WordPress suffered a higher proportion of input validation vulnerabilities than WikkaWiki. (Chi-Squared Test, p = 0.0692)

H8: In WordPress, more lines of code that were changed due to security issues were hotspots than in WikkaWiki. (Chi-Squared Test, p < 0.000001)

20

Page 21: Ben Smith and Laurie Williams

Limitations

• We can never find or know all vulnerabilities.

• Our definition of a hotspot may be insufficient or incorrect.

• Issue reports were subject to human error both in reporting and in analyzing.

• We are limited to these two open source projects.

21

Page 22: Ben Smith and Laurie Williams

Conclusion

• Hotspots can be used in a V&V prioritization heuristic as follows:More SQL and non-SQL vulnerabilities will be found

in files that contain more hotspots per line of code.

• Input validation vulnerabilities: prominent problem, no single solution.

• Separating the concern of database interaction is associated with a decrease in the proportion of reported input validation vulnerabilities.

22

Page 23: Ben Smith and Laurie Williams

Thank you!

• Any questions?

23

Page 24: Ben Smith and Laurie Williams

Precision & Recall

24

A measure of the level of exactness exhibited by the model

The number of vulnerable files the model retrieves.

Page 25: Ben Smith and Laurie Williams

25

$username = $_POST[‘username’];$password = $_POST[‘password’];

$result = mysql_query(“select * from users where username =‘’ OR 1=1 ---’ AND password = ‘$password’”);

$firstresult = mysql_fetch_array($result);

$role = $firstresult[‘role’];

$_COOKIE[‘userrole’] = $role

SQL Injection Attacks

‘ OR 1=1 --