retrofitting security in input parsing routines
play

Retrofitting Security in input parsing routines Jayakrishna Menon, - PowerPoint PPT Presentation

Retrofitting Security in input parsing routines Jayakrishna Menon, Christophe Hauser, Yan Shoshitaishvili, Stephen Schwab {jmenon, hauser, schwab}@isi.edu yans@asu.edu Modern defenses Vulnerabilities Many programs are still OS defenses


  1. Retrofitting Security in input parsing routines Jayakrishna Menon, Christophe Hauser, Yan Shoshitaishvili, Stephen Schwab {jmenon, hauser, schwab}@isi.edu yans@asu.edu

  2. Modern defenses Vulnerabilities Many programs are still ● OS defenses (ASLR, DEP). ● written in unsafe Compiler-level defenses ● languages like C/C++. (e.g., stack canaries). Memory corruption ● Code audit tools. ● vulnerabilities remain prominent.

  3. parsers Directly exposed to user input. ● Many custom implementations in unsafe languages (C/C++). ● Over 170 vulnerabilities reported in various parsing ● mechanisms since 1999. Varying semantics and the abundance of string ● manipulations make their implementation error-prone.

  4. Solution space

  5. Design time post-design security security Parser libraries. ● Code audits. ● Parser generators. ● Refactoring/inserting ● correct parsers. Formal methods. ● No source code? ●

  6. Binary-level approach Source code not always ● available (legacy code, uncooperative editors, untrusted IoT devices). What you see is not what ● you execute: compiler bugs, compiler “backdoors” WYSINWYX e.g., XCodeGhost (linking malicious code into executables).

  7. challenges

  8. Scaling problem Program analysis techniques are difficult to automate in a scalable and precise manner.

  9. Static analysis Symbolic execution Precise. ● Scalable. ● Unscalable. ● Imprecise. ●

  10. Dynamic analysis Precise. ● Low coverage. ●

  11. Source code Binary Types. ● Registers. ● Variable names. ● Memory locations. ● Functions. ● Basic blocks. ● ... ● ... ●

  12. How to scale to real world programs?

  13. template-based approach … to discover vulnerabilities based on templates corresponding to common classes of security bugs. … to retrofit security by patching programs at the binary-level.

  14. Initial approach classes/templates Focuses on overflows in ● buffers allocated Unconstrained input. ● statically on the stack. Under-constrained input ● size. template-based: ● Unchecked termination ● categorize causes of condition. vulnerabilities into ... ● three classes. Combines static analysis ● and symbolic execution.

  15. Unconstrained Improper usage of functions that do not check for sizes such as input. strcpy, sprintf etc.

  16. Example 1: CVE-2003-0390 int opt_atoi( char *s) { char buf[1024]; char *fmt = "String [ %s ] is not valid"; sprintf(buf, fmt, s); }

  17. Under-constrained Improper validation of size field in functions such as memcpy. input size.

  18. Example 2: CVE-2015-3329 void phar_set_inode( phar_entry_info *entry) { char tmp[1024]; memcpy(tmp, entry -> phar -> fname, entry->phar->fname_len); }

  19. Unchecked Performing operations on termination (possibly) incorrectly terminated strings. condition.

  20. 2-step Analysis approach Symbolic analysis Static analysis } Identify string Identify } program paths. } CFG manipulation destination functions. buffers (sinks). SE Dangerous Identify user Analyze backward DDG input. data-dependency. Path constraints. (Memory corruption caused by unsafe buffer manipulation)

  21. Analysis results Static Analysis Symbolic Overall execution False positive rate 6.6% 0% 0% * False negative rate 40% 0% * 40% Time 1-260s 1-400s 2-660s

  22. New bugs 2 new bugs found in the binary code of common opensource projects and libraries (in a semi-automatic setting)

  23. Retrofitting security: binary patching

  24. Remember: we focus on stack ● Adding the missing buffers. On the identified program ● checks paths, we constrain the user input such that: user_input_size < stack_buffer_size

  25. When the constraints are Adding the missing violated, we crash the program. checks This is equivalent to e.g., __sprintf_chk()

  26. Static reassembly problems: breaking internal program references. Patching the binary Partial solution: inject trampoline gadgets in padding bytes between functions (up to 15 consecutive NOPs).

  27. Inserting checks int opt_atoi(char *s) int opt_atoi(char *s) if(strlen(s)>1024) sprintf(buf, fmt, s); exit() sprintf(buf, fmt, s);

  28. More templates

  29. New template Memory allocation errors … authentication errors. … misuses of cryptographic APIs. … information leakage.

  30. New bugs 12 new bugs found in the binary code of common opensource programs and libraries (in a fully automated setting).

  31. discussion Lightweight and scalable approach. … but high rate of false negatives. … limited patching capabilities.

  32. Data structure recovery. Stumbling blocks Pointer aliasing.

  33. Future work Improve data dependence tracking. ● Leverage static reassembly techniques. ● More vulnerability templates. ● Apply to large corpus of IoT firmware. ●

  34. Key takeaways - Templates per vulnerability class. - Scalable, two-level approach based on a combination of static analysis + symbolic execution. - High-precision: we can infer semantic-agnostic patches for each class. - New bugs.

  35. ?

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