language agnostic injection language agnostic injection
play

LANGUAGE-AGNOSTIC INJECTION LANGUAGE-AGNOSTIC INJECTION DETECTION - PowerPoint PPT Presentation

LANGUAGE-AGNOSTIC INJECTION LANGUAGE-AGNOSTIC INJECTION DETECTION DETECTION Lars Hermerschmidt, Andreas Straub, Goran Piskachev injections grow on trees 1 SHOTGUN UNPARSER SHOTGUN UNPARSER 1 if (recursive || print_dir_name) 2 { 3 if


  1. LANGUAGE-AGNOSTIC INJECTION LANGUAGE-AGNOSTIC INJECTION DETECTION DETECTION Lars Hermerschmidt, Andreas Straub, Goran Piskachev injections grow on trees 1

  2. SHOTGUN UNPARSER SHOTGUN UNPARSER 1 if (recursive || print_dir_name) 2 { 3 if (!first) 4 DIRED_PUTCHAR ('\n'); 5 first = false ; 6 DIRED_INDENT (); 7 PUSH_CURRENT_DIRED_POS (&subdired_obstack); 8 dired_pos += quote_name (stdout, realname ? realname : name 9 dirname_quoting_options, NULL ); 10 PUSH_CURRENT_DIRED_POS (&subdired_obstack); 11 DIRED_FPUTS_LITERAL (":\n", stdout); 12 } https://github.com/wertarbyte/coreutils/blob/master/src/ls.c 1 mkdir "1 2 1" 3 mkdir 2 4 ls | wc -l 2

  3. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities 3

  4. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? 3

  5. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used 3

  6. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used But why? 3

  7. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used But why? IO is "soo simple", let's just use the core libs 3

  8. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used But why? IO is "soo simple", let's just use the core libs But why? 3

  9. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used But why? IO is "soo simple", let's just use the core libs But why? Core libs don't provide secure input handling 3

  10. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used But why? IO is "soo simple", let's just use the core libs But why? Core libs don't provide secure input handling But why? 3

  11. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used But why? IO is "soo simple", let's just use the core libs But why? Core libs don't provide secure input handling But why? Lacking Awareness for the problem 3

  12. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used But why? IO is "soo simple", let's just use the core libs But why? Core libs don't provide secure input handling But why? Lacking Awareness for the problem But why? 3

  13. WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST? Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used But why? IO is "soo simple", let's just use the core libs But why? Core libs don't provide secure input handling But why? Lacking Awareness for the problem But why? Core libs don't provide secure input handling 3

  14. RELATED WORK RELATED WORK Language specific static and dynamic analysis: SQLi, XSS, ... are well known Language agnostic dynamic aka fuzzing: Parsers are known to be broken AUTOGRAM uses dynamic taint tracking: Grammar reconstruction from a given parser Our contribution: Language agnostic detection of injections for textual languages Awareness Detection is never complete; Use a constructive approach like McHammerCoder to solve the injection problem. 4

  15. THE SOLUTION THE SOLUTION Show, don't tell 5

  16. PROBLEM SPACE PROBLEM SPACE Detecting unparsers Identifying injections in a given unparser Generate attacks Extract full grammar 6

  17. APPROACH OVERVIEW APPROACH OVERVIEW Guided fuzzing using language keyword information Keywords are extracted from unparse trees (UPTs) UPTs are inferred automatically using dynamic program analysis 7

  18. UPT INFERENCE UPT INFERENCE 8

  19. UPT INFERENCE UPT INFERENCE 9

  20. UPT INFERENCE UPT INFERENCE 10

  21. UPT INFERENCE UPT INFERENCE 11

  22. UPTS AND KEYWORDS UPTS AND KEYWORDS Keywords have no origin in any input They are created by the unparser Their location in the UPT shows where (structurally) they are valid in the language 12

  23. FUZZING FUZZING generate targeted injection candidates based on keywords example: "break out" of string-enclosing quotation marks evaluate injection success by comparing parse trees run both original input and modified input through unparser-parser round-trip compare structures of resulting parse trees if the parse tree changed, an injection was found 13

  24. RESULTS RESULTS Promising results in case studies very accurate UPTs found (implanted) injection vulnerabilities structural keyword information can significantly improve fuzzing caveat: not a quantitative evaluation Fuzzing automatically yields PoC exploits 14

  25. KEY OBSERVATIONS KEY OBSERVATIONS "Recursive descent unparsers" exist common in ad-hoc implementations Difference to Taint Tracking: leveraging structural information to identify keywords and their scope Requires structural variability in unparser outputs poor UPTs in "template-based" unparsers reduced to common taint tracking better use a sample output for mutation fuzzing 15

  26. CONCLUSION CONCLUSION Language-agnostic Injection Detection works for recursive descent unparsers use keywords from UPTs in fuzzing Awareness Creating output is not just writing an array of bytes Injections might exist in all your unparses Call to Action Every programming language's core library deserves an (un)parser 16

  27. QUESTIONS? QUESTIONS? Lars: @bob5ec on Twitter Andreas: andy@strb.org MARGOTUA code on GitHub 17

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend