Nuno Antunes, Marco Vieira
nmsa@dei.uc.pt, mvieira@dei.uc.pt University of Coimbra – Portugal
Comparing the Effectiveness of Penetration Testing and Static Code - - PowerPoint PPT Presentation
Comparing the Effectiveness of Penetration Testing and Static Code Analysis Detection of SQL Injection Vulnerabilities in Web Services Nuno Antunes, Marco Vieira PRDC 2009 nmsa@dei.uc.pt, mvieira@dei.uc.pt University of Coimbra
nmsa@dei.uc.pt, mvieira@dei.uc.pt University of Coimbra – Portugal
2
n Well defined interface
n Any existing vulnerability will most probably be
Marco Vieira PRDC 2009, November 16-18, Shangai, China
3
Marco Vieira PRDC 2009, November 16-18, Shangai, China
4
public String auth(String login, String pass) throw SQLException { String sql = "SELECT * FROM users WHERE "+ "username='" + login + "' AND "+ "password='" + pass + "'"; ResultSet rs = statement.executeQuery(sql); (…) } public void delete(String str) throw SQLException{ String sql = "DELETE FROM table "WHERE id='" + str + "'"; statement.executeUpdate(sql); } ' OR 1=1 -- "SELECT * FROM users WHERE username='' OR 1=1 -- ' AND password=''“; "DELETE FROM table WHERE id='' OR '' = ''"; ' OR ''='
Marco Vieira PRDC 2009, November 16-18, Shangai, China
5
n Manual code analyses (reviews, inspections) n Automated static code analysis
n Manual penetration testing n Automated penetration testing (vulnerability scanners)
Marco Vieira PRDC 2009, November 16-18, Shangai, China
6
n “black-box” approach n Uses specific malicious inputs
n e.g., for SQL Injection: ‘ or 1=1
n Many tools available
n Including commercial and open-source
Marco Vieira PRDC 2009, November 16-18, Shangai, China
7
n Among other types of software defects
n These tools provide an automatic way for highlighting
Marco Vieira PRDC 2009, November 16-18, Shangai, China
8
n In a controlled environment
n Coverage
n Portrays the percentage of existing vulnerabilities that are
n False positives rate
n Represents the number of reported vulnerabilities that in fact
n Extremely relevant in Web Services
Marco Vieira PRDC 2009, November 16-18, Shangai, China
9
n Select the penetration testers and static code analyzers n Select the Web Services to be considered
n Use the tools to identify potential vulnerabilities
n Perform manual verification to confirm that the
n i.e., are not false positives
n Analyze the results obtained and systematize the
Marco Vieira PRDC 2009, November 16-18, Shangai, China
10
n A total of 25 operations
Marco Vieira PRDC 2009, November 16-18, Shangai, China
11
Marco Vieira PRDC 2009, November 16-18, Shangai, China
12
n HP WebInspect n IBM Rational AppScan n Acunetix Web Vulnerability Scanner n [Antunes 2009]
n FindBugs n Yasca n IntelliJ IDEA
n VS1, VS2, VS3, VS4 (without any order in particular) n SA1, SA2, SA3 (without any order in particular)
Marco Vieira PRDC 2009, November 16-18, Shangai, China
13
n Underlying database restored before each test
n This avoids the cumulative effect of previous tests n Guarantees that all the tools started the service testing in a
n If allowed by the testing tool, information about the
n If the tool requires an exemplar invocation per operation, the
n All the tools in this situation used the same exemplar
n Configured to fully analyze the services code n For the analyzers that use binary code, the
Marco Vieira PRDC 2009, November 16-18, Shangai, China
14
n False positives were eliminated by cross-checking the
n Penetration testing: a vulnerability for each vulnerable
n Static analysis: a vulnerability for each vulnerable line
Marco Vieira PRDC 2009, November 16-18, Shangai, China
15
Marco Vieira PRDC 2009, November 16-18, Shangai, China
16
Marco Vieira PRDC 2009, November 16-18, Shangai, China
17
Marco Vieira PRDC 2009, November 16-18, Shangai, China
public void operation(String str) { try { String sql = "DELETE FROM table" + "WHERE id='" + str + "'"; statement.executeUpdate(sql); } catch (SQLException se) {} } public String dumpDepositInfo(String str) { try { String path = "//DepositInfo/Deposit"+ "[@accNum='" + str + "']"; return csvFromPath(path); } catch (XPathException e) {} return null; }
18
Marco Vieira PRDC 2009, November 16-18, Shangai, China
19
Marco Vieira PRDC 2009, November 16-18, Shangai, China
public void operation(String str) { int i = Integer.parseInt(str); try { String sql = "DELETE FROM table" + "WHERE id='" + str + "'"; statement.executeUpdate(sql); } catch (SQLException se) {} } public String dumpDepositInfo(String str) { try { String path = "//DepositInfo/Deposit"+ "[@accNum='" + str + "']"; return csvFromPath(path); } catch (XPathException e) {} return null; }
20
Marco Vieira PRDC 2009, November 16-18, Shangai, China
21
Marco Vieira PRDC 2009, November 16-18, Shangai, China
22
n But have more impact in the case of static analysis;
n Even tools implementing the same approach frequently
Marco Vieira PRDC 2009, November 16-18, Shangai, China
23
n Increase representativeness of the workload n Guarantee high coverage n Improve the attacks performed n Improve the vulnerability detection algorithms
n Include new vulnerable code patterns
Marco Vieira PRDC 2009, November 16-18, Shangai, China
24
Marco Vieira PRDC 2009, November 16-18, Shangai, China