using positive tainting and syntax aware evaluation to
play

Using Positive Tainting and Syntax-Aware Evaluation to Counter SQL - PowerPoint PPT Presentation

Using Positive Tainting and Syntax-Aware Evaluation to Counter SQL Injection Attacks William G.J. Halfond Alessandro Orso Panagiotis Manolios Georgia Institute of Technology Supported by NSF awards CCR-0205422 and CCR-0306372 to GA Tech and


  1. Using Positive Tainting and Syntax-Aware Evaluation to Counter SQL Injection Attacks William G.J. Halfond Alessandro Orso Panagiotis Manolios Georgia Institute of Technology Supported by NSF awards CCR-0205422 and CCR-0306372 to GA Tech and by DHS and US Air Force under Contract No. FA8750-05-C-0179. Group Group

  2. Introduction DB Internet End Users Web Server Other Systems Deployment context of a typical Web application. William Halfond – FSE 2006 – November 8 th , 2006 – Slide 2 Group Group

  3. Introduction DB Internet End Users Web Server Other Systems Deployment context of a typical Web application. William Halfond – FSE 2006 – November 8 th , 2006 – Slide 3 Group Group

  4. SQL Injection Attacks Easy to create a database query – hard to do it securely. • Open Web Application Security Project (OWASP) lists SQLIA in its top ten most critical web application security vulnerabilities • David Aucsmith (CTO of Security and Business Unit, Microsoft) defined SQLIA as one of the most serious threats to web apps • Successful attacks on Guess Inc., Travelocity, FTD.com, Tower Records, RIAA, … • Companies have built their business on detecting SQLIAs William Halfond – FSE 2006 – November 8 th , 2006 – Slide 4 Group Group

  5. Example of an SQLIA public Login(request, response) { String login = request.getParameter(“login”); String passwd = request.getParameter(“passwd”); String query = "SELECT info FROM userTable WHERE "; if ((! login.equals("")) && (! password.equals(""))) query += "login='"+login+"' AND pass='"+passwd +"'" else query+="login='guest'"; ResultSet result = stmt.executeQuery(query); if (result != null) displayAccount(result); else sendAuthFailed(); } William Halfond – FSE 2006 – November 8 th , 2006 – Slide 5 Group Group

  6. Example of an SQLIA public Login(request, response) { String login = request.getParameter(“login”); String passwd = request.getParameter(“passwd”); String query = "SELECT info FROM userTable WHERE "; if ((! login.equals("")) && (! password.equals(""))) query += "login='"+login+"' AND pass='"+passwd +"'" else query+="login='guest'"; ResultSet result = stmt.executeQuery(query); if (result != null) displayAccount(result); else sendAuthFailed(); } Normal Usage  User submits login “ doe ” and passwd “ xyz ”  SELECT info FROM users WHERE login= ` doe ’ AND pass= ‘ xyz’ William Halfond – FSE 2006 – November 8 th , 2006 – Slide 6 Group Group

  7. Example of an SQLIA public Login(request, response) { String login = request.getParameter(“login”); String passwd = request.getParameter(“passwd”); String query = "SELECT info FROM userTable WHERE "; if ((! login.equals("")) && (! password.equals(""))) query += "login='"+login+"' AND pass='"+passwd +"'" else query+="login='guest'"; ResultSet result = stmt.executeQuery(query); if (result != null) displayAccount(result); else sendAuthFailed(); } Malicious Usage  Attacker submits “ admin’ -- ” and passwd of “0”  SELECT info FROM users WHERE login=‘ admin’ -- ’ AND pass=‘0’ William Halfond – FSE 2006 – November 8 th , 2006 – Slide 7 Group Group

  8. Presentation Outline • Our Technique • Positive tainting • Syntax-aware evaluation • Implementation -- WASP • Evaluation • Related work • Conclusions and future work William Halfond – FSE 2006 – November 8 th , 2006 – Slide 8 Group Group

  9. Our Technique Basic approach => Only allow developer- trusted strings to form sensitive parts of a query Solution: 1. Positive tainting : Identify and mark developer- trusted strings. Propagate taint markings at runtime 2. Syntax-Aware Evaluation : Check that all keywords and operators in a query were formed using marked strings William Halfond – FSE 2006 – November 8 th , 2006 – Slide 9 Group Group

  10. Example: Positive vs. Negative Tainting public Login(request, response) { String login = request.getParameter(“login”); String passwd = request.getParameter(“passwd”); String query = "SELECT info FROM userTable WHERE "; if ((! login.equals("")) && (! password.equals(""))) query += "login='"+login+"' AND pass='"+passwd + "'" else query+="login='guest'"; ResultSet result = stmt.executeQuery(query); if (result != null) displayAccount(result); else sendAuthFailed(); } Identify and mark trusted data instead of untrusted data. Negative tainting. Positive tainting. William Halfond – FSE 2006 – November 8 th , 2006 – Slide 10 Group Group

  11. Benefits of Positive Tainting ⇒ Increased safety: Incompleteness leads to easy-to-eliminate false positives ⇒ Normal in-house testing causes set of trusted data to converge to complete set ⇒ Implements security principle of “fail-safe defaults” [Saltzer and Schroeder] ⇒ Increased automation: Trusted data readily identifiable in Web applications William Halfond – FSE 2006 – November 8 th , 2006 – Slide 11 Group Group

  12. Syntax-aware Evaluation • Cannot simply forbid the use of untrusted data in queries • Dependence on filtering rules requires unsafe assumptions ⇒ Syntax-aware evaluation • Performed right before the query is sent to the database • Consider the context in which trusted and untrusted data is used William Halfond – FSE 2006 – November 8 th , 2006 – Slide 12 Group Group

  13. Complete Example 1. String queryString = "SELECT info FROM userTable WHERE "; 2. if ((! login.equals("")) && (! password.equals(""))) { 3. queryString += "login='" + login + "' AND pass='" + password + "'"; } else { 4. queryString+="login='guest'"; } 5. ResultSet tempSet = stmt.executeQuery(queryString); login -> “doe”, password -> “xyz” William Halfond – FSE 2006 – November 8 th , 2006 – Slide 13 Group Group

  14. Complete Example 1. String queryString = "SELECT info FROM userTable WHERE "; 2. if ((! login.equals("")) && (! password.equals(""))) { 3. queryString += "login='" + login + "' AND pass='" + password + "'"; } else { 4. queryString+="login='guest'"; } 5. ResultSet tempSet = stmt.executeQuery(queryString); login -> “doe”, password -> “xyz” queryString [ S ][ E ][ L ][ E ][ C ][ T ] … [ W ][ H ][ E ][ R ][ E ][] William Halfond – FSE 2006 – November 8 th , 2006 – Slide 14 Group Group

  15. Complete Example 1. String queryString = "SELECT info FROM userTable WHERE "; 2. if ((! login.equals("")) && (! password.equals(""))) { 3. queryString += "login='" + login + "' AND pass='" + password + "'"; } else { 4. queryString+="login='guest'"; } 5. ResultSet tempSet = stmt.executeQuery(queryString); login -> “doe”, password -> “xyz” queryString [ S ][ E ][ L ][ E ][ C ][ T ] … [ W ][ H ][ E ][ R ][ E ][] tmp0 tmp1 tmp2 [ l ][ o ][ g ][ i ][ n ][ = ][ ‘ ] [ d ][ o ][ e ] [ ‘ ][][ A ][ N ][ D ][][ p ][ a ][ s ][ s ][ = ][ ‘ ] tmp4 tmp3 [ x ][ y ][ z ] [ ‘ ] William Halfond – FSE 2006 – November 8 th , 2006 – Slide 15 Group Group

  16. Complete Example 1. String queryString = "SELECT info FROM userTable WHERE "; 2. if ((! login.equals("")) && (! password.equals(""))) { 3. queryString += "login='" + login + "' AND pass='" + password + "'"; } else { 4. queryString+="login='guest'"; } 5. ResultSet tempSet = stmt.executeQuery(queryString); login -> “doe”, password -> “xyz” queryString … [ W ][ H ][ E ][ R ][ E ][][ l ][ o ][ g ][ i ][ n ][ = ][ ‘ ][ d ][ o ][ e ][ ‘ ][ A ][ N ][ D ][][ p ][ a ][ s ][ s ][ = ][ ‘ ][ x ][ y ][ z ][ ‘ ] William Halfond – FSE 2006 – November 8 th , 2006 – Slide 16 Group Group

  17. Complete Example 1. String queryString = "SELECT info FROM userTable WHERE "; 2. if ((! login.equals("")) && (! password.equals(""))) { 3. queryString += "login='" + login + "' AND pass='" + password + "'"; } else { 4. queryString+="login='guest'"; } 5. ResultSet tempSet = stmt.executeQuery(queryString); login -> “doe”, password -> “xyz” SELECT info FROM userTable WHERE login=‘doe‘ AND pass=‘xyz‘ William Halfond – FSE 2006 – November 8 th , 2006 – Slide 17 Group Group

  18. Complete Example 1. String queryString = "SELECT info FROM userTable WHERE "; 2. if ((! login.equals("")) && (! password.equals(""))) { 3. queryString += "login='" + login + "' AND pass='" + password + "'"; } else { 4. queryString+="login='guest'"; } 5. ResultSet tempSet = stmt.executeQuery(queryString); login -> “doe”, password -> “xyz” ✔ doe SELECT info FROM userTable WHERE login = pass xyz ‘ ‘ AND = ‘ ‘ William Halfond – FSE 2006 – November 8 th , 2006 – Slide 18 Group Group

Recommend


More recommend