hello i nterw ebs
play

Hello, I nterw ebs Hi, and thanks for reading this. As I mentioned a - PowerPoint PPT Presentation

Hello, I nterw ebs Hi, and thanks for reading this. As I mentioned a number of times during the talk this was one long, hard slog of a topic for me. My intent was not to duplicate existing research (Johnson and Silberman @ BHUS05, others), but


  1. Hello, I nterw ebs Hi, and thanks for reading this. As I mentioned a number of times during the talk this was one long, hard slog of a topic for me. My intent was not to duplicate existing research (Johnson and Silberman @ BHUS05, others), but to try to make this topic comprehensible for the typical security professional, who (GASP! SHOCK! HORROR!) may not necessarily grasp all the hairy internals of exploit development, but still is tasked with protecting systems. For the other 90% of us out there, our job is not to be leet, but rather not to get owned, something I hope to get a little bit better at every day. Since exploit mitigation is something that might bring us all a little bit closer to that, I wanted to explore the topic. Thanks much to BH for giving me the opportunity to do so, and to all of you for listening. Thanks also to all the amazing people working on these technologies, especially the PaX team and Hiroaki Etoh of IBM. -- shawn P.S. It’s actually Thompson that had the Phil Collins hair, not Ritchie. Sorry, Dennis.

  2. 28 75 6e 29 53 6d 61 73 68 69 6e 67 20 74 68 65 20 53 74 61 63 6b 0d 0a ( un) Sm ashing the Stack 4f 76 65 72 66 6c 6f 77 73 2c 20 43 6f 75 6e 74 65 72 6d 65 61 73 75 72 65 73 20 61 6e 64 20 74 68 65 20 52 65 61 6c 20 57 6f 72 6c 64 Overflow s, Counterm easures and the Real W orld Shaw n Moyer :: Chief Researcher ---- SpearTip Technologies ---> blackhat [ at] cipherpunx [ dot] org

  3. Hey, w ho is this guy? Shaw nM: I nfoSec consultant, ( quasi-) developer, husband, father, and raging paranoid w ith obsessive tendencies Chief Researcher at SpearTip Technologies Security Consultancy in Saint Louis, MO Forensics, Assessment, MSSP, network analysis Weddings, Funerals, Bar Mitzvahs I like unsolvable problems, so I’m mostly interested in defense. My hat color is… Fuschia.

  4. # include std_ disclaim er.h I am not a ninja... I don’t even play one on tv. != Interest in exploit mitigation – no unified source of info. Patching / IPS / vendor voodoo don’t seem to work…

  5. W hat is this stuff? Exploit Mitigation A range of compiler, OS, library, and kernel features Intended to make successful exploitation more difficult Primary aim: make mass exploitation less feasible Limit exposure from memory corruption-based attacks Nonexectuable stacks, ASLR, canaries, memory integrity Compile-time and run time sanity checks for misuse Bonus stuff: MAC models, static analysis, others

  6. W hy am I here, w hy are you listening? W e’ll talk about Attempt to deconstruct this topic for mere mortals Some of the implementations out there Complexity of the approaches Plug some cool projects Make this make sense for the Humans (us)

  7. Let’s just start at the beginning.

  8. W hen dinosaurs roam ed the earth... This class of bugs has been around longer than ( alm ost) everyone in this room . Corruption of mismanaged memory space leads to control of execution flow. Hilarity ensues. With us since at least the 1960s (!) Intrinsic to Von Neumann model... Code / Data abstraction, breaking the membrane “Fandango on core”, “scribbling the stack”, “overrun screw” “Stale / Dangling pointer bug” in ALGOL / FORTRAN lexicon

  9. I t used to be such a nice neighborhood… Gene Spafford + RFC 1 1 3 5 , circa 1 9 8 8 : “The Helminthiasis of the Internet” Analysis of spread of the Morris worm Stack-based overflow in fingerd gets() one vector http:/ / w w w .securityfocus.com / bid/ 2 (Trivia: Bid 1 was input val bug in Sendmail... Makes sense.) I n his analysis, Spaff w arns against lack of bounds checking in C. Says gets( ) , scanf( ) , strcpy( ) and other unsafe calls should be avoided in the future. * * Class, this will be on the final. Nineteen years is correct.

  10. Meanw hile, back at the ranch... Thom as Lopatic, circa 1 9 9 5 : Hey, this is like the Morris worm fingerd bug... Stack-based BoF found in NCSA HTTPd for HTTP GET Mudge / L0 pht, circa 1 9 9 5 : Early walkthrough of process How to construct shellcode, NOP sleds

  11. Mesozoic Exploitation... Aleph One, circa 1 9 9 7 : Snapshot of attack landscape in late 90’s (“eggs”, NOPs) Tutorial on memory segments, data/ code/ heap/ bss/ stack Solar Designer, circa 1 9 9 7 : First documented example I found of ret2libc No shellcode, use preloaded function in memory

  12. Cenozoic Exploitation... Conover / w 0 0 w 0 0 , circa 1 9 9 9 : “w00w00 on heap overflows” Stack is but one target, grasshopper... Shellcode written to the heap, fuction ptr overwrites Okay, okay, enough already! Som eone’s been reading the Phrack archives… W hy do you care? Approaches evolved, but vectors are the sam e.

  13. Ah... There’s the ffw d button… Things continue to get ugly. NVD rem ote BoF’s up to end of 2 0 0 6 .

  14. 1 0 lbs. of crap in a 5 lb. bag Okay, so obviously w e all get this stuff, right?

  15. Brring, brring. “Cluephone. I t’s for you.” Hey… W ait a m inute. Data is data, code is code, right?

  16. Eventually, the cluephone rings.... Gotta keep ‘em se-pa-rated…

  17. Brrring, brrring... Solaris / uSPARC “noexec_ user_ stack” bit: / etc/ system “ no_exec_user_stack= 1 ” (or via ndd) Similar implementations on HP/ UX and other big iron Now adays, nX bit, DEP ( XD? Meh.) : Via PAE (Page Address Extension) et al , bit 63 0/ 1 Requires software hooks! A CPU does not make you safer.

  18. Brrring, brrring, BRRRRI NGGG... Em ulation in softw are: Solar Designer’s StackPatch was the first. W^ X, ExecShield, PaX, DEP, others. Software implementations (32-bit) are less fine-grained Segment-based rather than page-based (line in the sand) I n general, nonexecutable stacks are problem atic for apps that expect tram polines, JI T com pilers, em ulators, anything else that constructs code on the stack.

  19. New counterm easures beget new attacks W hoops! W ith a noexec stack, the vuln is still there, you’ve just reduced w hat’s possible. ret2 libc: First described by Solar in 1997 Most “0wn DEP / nX” talks / articles boil down to this Call existing, preloaded function(s): system() , execve() , etc Call mprotect() if OS honors it, then set allocation as rwx Requires(?) known address, useful function in mem (hence libc) Heap-based overflow s: Much more interesting now that noexec is everywhere See Sotirov’s talk, Justin of IOA, atlas’ DC talk, Ollie W.

  20. nX counter-counterm easures ( cont.) Pirom posa / Enbody: “Hannibal attack” or multistage overflow Overwrite function pointer to an arbitrary address Insert shellcode at predefined address via argv() , etc Skape / Skyw ing: Forcible OptOut for process in MS’s DEP via ret2libc DEP configurable via ProcessExecuteFlags at runtime MEM_EXECUTE_OPTION(ENABLE| DISABLE) Sum m ary: set “ / noexecute= Alw aysOn ” in boot.ini( !) PaX uses file header instead. Higher bar?

  21. nX counter-counterm easures ( cont.) “Opt in / out” ugliness: All implementations (DEP, gcc) allow disabling of checks via mprotect(), VirtualProtect(), -fno-stackprotector, / O Tunable via ELF header with chpax Skywing’s NoExecute Hall of Shame: http:/ / w w w .nynaeve.net/ ?p= 1 3 5 Personally, DEP / noexec has killed: Firefox, Acrobat, Java… BackupExec w/ SecureStack (interesting story… )

  22. Canary in a coalm ine: Tripw ire FTW ! Okay then, w hy not just check for m em ory corruption? Checksum s for the stack!

  23. Canary in a coalm ine StackGuard: Initial approach. Crispin Cowan / Immunix in ’99 “Canary” word in stack for RTA in function_prologue If canary word changed on function_epilogue , call exit() Later versions improved layout, different canary approaches

  24. Cheep, cheep… ProPolice / SSP: Hiroaki Etoh of IBM is teh awesome+ + + Integrated into gcc > 4.1, backports for 3.x in OBSD “Embraced and extended” by MS as / GS compiler flags GS “cookie” is ProPolice guard value Not exactly a canary approach. Hiroaki prefers “guard value” XOR of ptr and random value, stored off-stack Move beyond just return address to all registers, in prologue Well-ordered stack: variables and arrays at bottom, args at top

  25. Cheep, cheep ( Propolis) …

  26. ProPolice Safe Stack

  27. Canary interlude: ( un) Sm ashing the Heap! Heap Canary im plem entations: Same canary principle has been applied to protect the heap Guard value / canary, damage to guard triggers exception OpenBSD “G” option to malloc.conf ContraPolice http:/ / synflood.at/ contrapolice.htm l WKR -> dlmalloc http:/ / w w w .cs.ucsb.edu/ ~ w kr/ projects/

  28. Hey, w ho ate m y canary? I f the canary is the key elem ent in protecting against m em ory corruption, the defense is only as good as the canary. Gerardo Richarte / CoreSec: Global Offset Table writes “after” return address, SFP stuff Specific to StackShield, / GS, StackGuard Phrack 5 6 / Bulba and Kil3 r: Noted StackGuard weaknesses in canary for only return pointer Write pointer elsewhere in unbounded strcpy / memcpy Overwrite return pointer without harming canary

  29. Hey, w ho ate m y canary? ( cont.) Other approaches: Canary is somewhere in (readable) memory, right? (random XORed canary or off-stack approach helps here) Arbitrary memory reads could disclose canary value Format string bugs, / proc/ mem/ , info leakage

  30. Obfuscation and com plexity Hey… Let’s shuffle m em ory around! See: Art of W ar. Misdirection.

Recommend


More recommend