re targetable grammar based test case generation
play

RE-TARGETABLE GRAMMAR BASED TEST CASE GENERATION 2 TESTING PARSERS - PowerPoint PPT Presentation

JOE ROZNER / @JROZNER RE-TARGETABLE GRAMMAR BASED TEST CASE GENERATION 2 TESTING PARSERS IS HARD 3 HOW WE GOT HERE Mostly clean room (ish) implementation of complex languages (context-free- ish) ~35k lines of grammar in total


  1. JOE ROZNER / @JROZNER RE-TARGETABLE GRAMMAR BASED TEST CASE GENERATION

  2. � 2 TESTING PARSERS IS HARD

  3. � 3 HOW WE GOT HERE ▸ Mostly clean room (ish) implementation of complex languages (context-free- ish) ▸ ~35k lines of grammar in total (ANTLR) ▸ Implemented from incomplete, inaccurate, and contradictory documentation ▸ Radically different parsing algorithm(s) from original implementations ▸ Lack of public test cases for most dialects

  4. � 4 ARE WE CORRECT? ▸ What is correct? ▸ Can we be 100% correct? ▸ How do we quantify how correct an implementation is? ▸ How do we test the implementations? ▸ How do we get better?

  5. � 5 GETTING MORE TEST CASES? ▸ Request query logs from customers ▸ Stand up applications and record their queries ▸ Automatically generate test cases with a fuzzer

  6. PROBLEMS WITH TRADITIONAL TEST CASE GENERATION ▸ Inflexibility with using test cases ▸ Inflexibility with providing feedback ▸ Existing tools solve many cases but as you deviate they become less useful

  7. STYLES OF FUZZING

  8. � 8 INSTRUMENTATION + RANDOM MUTATION ▸ Focus on path exploration and code coverage ▸ No concept of syntax/semantics ▸ Wont necessarily provide lot’s of coverage for variations of a specific parse tree ▸ Might spend a lot of time on uninteresting/non-relevant code paths ▸ Not immediately clear how to build a proper test harness ▸ Example of this strategy is AFL (American Fuzzy Lop) ▸ https://lcamtuf.blogspot.com/2014/11/pulling-jpegs-out-of-thin-air.html

  9. “THE FIRST IMAGE, HIT AFTER ABOUT SIX HOURS ON AN 8-CORE SYSTEM…”

  10. “…CERTAIN TYPES OF ATOMICALLY EXECUTED CHECKS WITH A LARGE SEARCH SPACE MAY POSE AN INSURMOUNTABLE OBSTACLE TO THE FUZZER…”

  11. if (strcmp(header.magic_password, "h4ck3d by p1gZ ” )) goto terminate_now;

  12. “IN PRACTICAL TERMS, THIS MEANS THAT AFL- FUZZ WON'T HAVE AS MUCH LUCK ‘INVENTING’ PNG FILES OR NON-TRIVIAL HTML DOCUMENTS FROM SCRATCH…”

  13. � 13 INSTRUMENTATION + SOLVING ▸ Focus on path exploration and code coverage ▸ Instrument the code and solve for new paths ▸ Still doesn’t care about syntax/semantics ▸ Still not clear how to build a more customer test harness ▸ Not necessarily easy to gate off specific paths that are uninteresting ▸ Example of this is KLEE

  14. � 14 GRAMMAR BASED ▸ Uses a grammar to generate syntactically correct sentences ▸ Typically provide their own grammar language ▸ Mostly targeted at regular/context-free text based languages ▸ Example of this is Mozilla Dharma ▸ https://github.com/MozillaSecurity/dharma

  15. � 15 LET’S ITERATE ▸ Create a platform with parser primitives that can generate instead of parse ▸ Provide support for multiple frontends so manual translation from one grammar language to another is not required ▸ Be expressive enough for regular, context-free, and context-sensitive languages both text and binary ▸ Embeddable and usable from any language ▸ Composable and flexible

  16. � 16 STRUCTURE ▸ Composable libraries ▸ Target + Generation ▸ Frontends ▸ Test harnesses

  17. DEMO

  18. � 18 WHAT’S NEXT? ▸ Expose a C-compatible API ▸ Starting work on frontends ▸ Better negation logic ▸ Context-Sensitive/Introspective generators ▸ Functional comparison between results with traditional fuzzers

  19. JOE@DEADBYTES.NET / @JROZNER QUESTIONS?

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