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

language agnostic injection language agnostic injection
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

LANGUAGE-AGNOSTIC INJECTION LANGUAGE-AGNOSTIC INJECTION DETECTION DETECTION

Lars Hermerschmidt, Andreas Straub, Goran Piskachev

injections grow on trees

1

slide-2
SLIDE 2

SHOTGUN UNPARSER SHOTGUN UNPARSER

DIRED_PUTCHAR ('\n'); DIRED_FPUTS_LITERAL (":\n", stdout); if (recursive || print_dir_name) 1 { 2 if (!first) 3 4 first = false; 5 DIRED_INDENT (); 6 PUSH_CURRENT_DIRED_POS (&subdired_obstack); 7 dired_pos += quote_name (stdout, realname ? realname : name 8 dirname_quoting_options, NULL); 9 PUSH_CURRENT_DIRED_POS (&subdired_obstack); 10 11 } 12

https://github.com/wertarbyte/coreutils/blob/master/src/ls.c

mkdir "1 1" mkdir 2 ls | wc -l 1 2 3 4

2

slide-3
SLIDE 3

WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST?

Shotgun Unparsers cause Injection Vulnerabilities

3

slide-4
SLIDE 4

WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST?

Shotgun Unparsers cause Injection Vulnerabilities But why?

3

slide-5
SLIDE 5

WHY DO INJECTIONS EXIST? WHY DO INJECTIONS EXIST?

Shotgun Unparsers cause Injection Vulnerabilities But why? Correct Unparser Generators are not used

3

slide-6
SLIDE 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

slide-7
SLIDE 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

slide-8
SLIDE 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

slide-9
SLIDE 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

slide-10
SLIDE 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

slide-11
SLIDE 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

slide-12
SLIDE 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

slide-13
SLIDE 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

slide-14
SLIDE 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 to solve the injection problem. McHammerCoder

4

slide-15
SLIDE 15

THE SOLUTION THE SOLUTION

Show, don't tell

5

slide-16
SLIDE 16

PROBLEM SPACE PROBLEM SPACE

Detecting unparsers Identifying injections in a given unparser Generate attacks Extract full grammar

6

slide-17
SLIDE 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

slide-18
SLIDE 18

UPT INFERENCE UPT INFERENCE

8

slide-19
SLIDE 19

UPT INFERENCE UPT INFERENCE

9

slide-20
SLIDE 20

UPT INFERENCE UPT INFERENCE

10

slide-21
SLIDE 21

UPT INFERENCE UPT INFERENCE

11

slide-22
SLIDE 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

slide-23
SLIDE 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

slide-24
SLIDE 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

slide-25
SLIDE 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

slide-26
SLIDE 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

slide-27
SLIDE 27

QUESTIONS? QUESTIONS?

Lars: Andreas: @bob5ec on Twitter andy@strb.org MARGOTUA code on GitHub

17