finding vulnerabilifes cs642 computer security
play

Finding vulnerabiliFes CS642: Computer Security - PowerPoint PPT Presentation

Finding vulnerabiliFes CS642: Computer Security Professor Ristenpart h9p://www.cs.wisc.edu/~rist/ rist at cs dot wisc dot edu University of Wisconsin CS 642


  1. Finding ¡vulnerabiliFes ¡ CS642: ¡ ¡ Computer ¡Security ¡ Professor ¡Ristenpart ¡ h9p://www.cs.wisc.edu/~rist/ ¡ rist ¡at ¡cs ¡dot ¡wisc ¡dot ¡edu ¡ University ¡of ¡Wisconsin ¡CS ¡642 ¡

  2. AdministraFve ¡ • Do ¡people ¡have ¡access ¡to ¡running ¡the ¡HW1 ¡ VM? ¡ • Are ¡people ¡sFll ¡on ¡wait ¡list? ¡ – send ¡me ¡your ¡name ¡and ¡ID ¡

  3. Finding ¡vulnerabiliFes ¡ Manual ¡analysis ¡ Simple ¡example: ¡double ¡free ¡ Fuzzing ¡tools ¡ StaFc ¡analysis, ¡dynamic ¡analysis ¡ … ¡ University ¡of ¡Wisconsin ¡CS ¡642 ¡

  4. "#$%&'()*(&)+&,-.&/)+',$&((&()#01) 2&$30,.,45)6,),76#80)#)(804*.#') 4,#.9):0;,'<#68,0)1,<80#0$& From ¡“How ¡Hackers ¡Look ¡for ¡Bugs”, ¡Dave ¡Aitel ¡

  5. "#$%&#&'#()*%&)+,-./0&1&#2-& #00#/$&30&+%(,0%*4 560#32&7+,-./0 7+,0,/,*&82#*4'3' <#2.#*&=%0>,+$& @,.+/%AB32#+4 9.::32; ?.*2%+#63*304&82#*4'3' 82#*4'3' 5)%2&@,.+/% G%'%#+/H 7+3F#0%&@,.+/% CD)*,30&E%F%*,)(%20 G%'%#+/H ! From ¡“How ¡Hackers ¡Look ¡for ¡Bugs”, ¡Dave ¡Aitel ¡

  6. Manual ¡analysis ¡ • You ¡get ¡a ¡binary ¡or ¡the ¡source ¡code ¡ • You ¡find ¡vulnerabiliFes ¡

  7. IDA ¡Pro ¡

  8. IDA ¡Pro ¡

  9. What ¡type ¡of ¡vulnerability ¡might ¡this ¡be? ¡ main( ¡ ¡int ¡argc, ¡char* ¡argv[] ¡) ¡{ ¡ ¡ ¡char* ¡b1; ¡ ¡ ¡char* ¡b2; ¡ ¡ ¡char* ¡b3; ¡ ¡ ¡ ¡b1 ¡= ¡(char*)malloc(248); ¡ ¡ ¡ ¡b2 ¡= ¡(char*)malloc(248); ¡ ¡ ¡free(b1); ¡ ¡ ¡ ¡free(b2); ¡ ¡ ¡b3 ¡= ¡(char*)malloc(512); ¡ ¡ ¡strncpy( ¡b3, ¡argv[1], ¡511 ¡); ¡ ¡ ¡free(b2); ¡ ¡ ¡free(b3); ¡ } ¡ Double-­‑free ¡vulnerability ¡

  10. Double-­‑free ¡vulnerabiliFes ¡ Can ¡corrupt ¡the ¡state ¡of ¡the ¡heap ¡management ¡ Say ¡we ¡use ¡a ¡simple ¡doubly-­‑linked ¡list ¡malloc ¡implementaFon ¡ with ¡control ¡informaFon ¡stored ¡alongside ¡data ¡ Chunk ¡has: ¡ ¡ chunk.leg ¡ 1) leg ¡ptr ¡(to ¡previous ¡chunk) ¡ 2) right ¡ptr ¡(to ¡next ¡chunk) ¡ chunk.right ¡ h ¡ 3) free ¡bit ¡which ¡denotes ¡if ¡chunk ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡this ¡reuses ¡low ¡bit ¡of ¡right ¡ptr ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡because ¡we ¡will ¡align ¡chunks ¡ user ¡data ¡ 4) ¡ ¡ ¡user ¡data ¡

  11. malloc() ¡ NULL ¡ -­‑ search ¡leg-­‑to-­‑right ¡for ¡free ¡chunk ¡ -­‑ modify ¡pointers ¡ chunk1.right ¡ 1 ¡ empty ¡ chunk2.leg ¡ NULL ¡ 1 ¡

  12. malloc() ¡ NULL ¡ -­‑ search ¡leg-­‑to-­‑right ¡for ¡free ¡chunk ¡ -­‑ modify ¡pointers ¡ chunk1.right ¡ 0 ¡ b1 ¡= ¡malloc( ¡BUF_SIZE1 ¡); ¡ data1 ¡ ¡ ¡ chunk3.leg ¡ chunk3.right ¡ 1 ¡ empty ¡ chunk2.leg ¡ NULL ¡ 1 ¡

  13. malloc() ¡ NULL ¡ -­‑ search ¡leg-­‑to-­‑right ¡for ¡free ¡chunk ¡ -­‑ modify ¡pointers ¡ chunk1.right ¡ 0 ¡ b1 ¡= ¡malloc( ¡BUF_SIZE1 ¡) ¡ ¡ data1 ¡ ¡ b2 ¡= ¡malloc( ¡BUF_SIZE2 ¡) ¡ chunk3.leg ¡ free() ¡ -­‑ Consolidate ¡with ¡free ¡neighbors ¡ chunk3.right ¡ 0 ¡ data2 ¡ chunk2.leg ¡ NULL ¡ 1 ¡

  14. malloc() ¡ NULL ¡ -­‑ search ¡leg-­‑to-­‑right ¡for ¡free ¡chunk ¡ -­‑ modify ¡pointers ¡ chunk1.right ¡ 1 ¡ b1 ¡= ¡malloc( ¡BUF_SIZE1 ¡) ¡ ¡ data1 ¡ ¡ b2 ¡= ¡malloc( ¡BUF_SIZE2 ¡) ¡ chunk3.leg ¡ free() ¡ -­‑ Consolidate ¡with ¡free ¡neighbors ¡ chunk3.right ¡ 0 ¡ free( ¡b1 ¡) ¡ ¡ data2 ¡ chunk2.leg ¡ NULL ¡ 1 ¡

  15. malloc() ¡ NULL ¡ -­‑ search ¡leg-­‑to-­‑right ¡for ¡free ¡chunk ¡ -­‑ modify ¡pointers ¡ chunk1.right ¡ 1 ¡ b1 ¡= ¡malloc( ¡BUF_SIZE1 ¡) ¡ ¡ data1 ¡ ¡ b2 ¡= ¡malloc( ¡BUF_SIZE2 ¡) ¡ chunk3.leg ¡ free() ¡ -­‑ Consolidate ¡with ¡free ¡neighbors ¡ chunk3.right ¡ 0 ¡ free( ¡b1 ¡) ¡ ¡ free( ¡b2 ¡) ¡ ¡ ¡ data2 ¡ chunk2.leg ¡ NULL ¡ 1 ¡

  16. malloc() ¡ NULL ¡ -­‑ search ¡leg-­‑to-­‑right ¡for ¡free ¡chunk ¡ -­‑ modify ¡pointers ¡ chunk1.right ¡ 0 ¡ b1 ¡= ¡malloc( ¡BUF_SIZE1 ¡) ¡ ¡ data1 ¡ ¡ b2 ¡= ¡malloc( ¡BUF_SIZE2 ¡) ¡ chunk3.leg ¡ free() ¡ -­‑ Consolidate ¡with ¡free ¡neighbors ¡ chunk3.right ¡ 0 ¡ free( ¡b1 ¡) ¡ ¡ free( ¡b2 ¡) ¡ ¡ b3 ¡= ¡malloc( ¡BUF_SIZE1 ¡+ ¡BUF_SIZE2 ¡) ¡ ¡ data2 ¡ chunk2.leg ¡ NULL ¡ 1 ¡

  17. malloc() ¡ NULL ¡ -­‑ search ¡leg-­‑to-­‑right ¡for ¡free ¡chunk ¡ -­‑ modify ¡pointers ¡ chunk1.right ¡ 0 ¡ b1 ¡= ¡malloc( ¡BUF_SIZE1 ¡) ¡ ¡ data1 ¡ ¡ b2 ¡= ¡malloc( ¡BUF_SIZE2 ¡) ¡ chunk3.leg ¡ free() ¡ -­‑ Consolidate ¡with ¡free ¡neighbors ¡ chunk3.right ¡ 0 ¡ free( ¡b1 ¡) ¡ ¡ free( ¡b2 ¡) ¡ ¡ b3 ¡= ¡malloc( ¡BUF_SIZE1 ¡+ ¡BUF_SIZE2 ¡) ¡ ¡ strncpy( ¡b3, ¡argv[1], ¡BUF_SIZE1+BUF_SIZE2-­‑1 ¡) ¡ data2 ¡ chunk2.leg ¡ NULL ¡ 1 ¡

  18. malloc() ¡ NULL ¡ -­‑ search ¡leg-­‑to-­‑right ¡for ¡free ¡chunk ¡ -­‑ modify ¡pointers ¡ chunk1.right ¡ 0 ¡ b1 ¡= ¡malloc( ¡BUF_SIZE1 ¡) ¡ ¡ data1 ¡ ¡ b2 ¡= ¡malloc( ¡BUF_SIZE2 ¡) ¡ chunk3.leg ¡ free() ¡ -­‑ Consolidate ¡with ¡free ¡neighbors ¡ chunk3.right ¡ 0 ¡ free( ¡b1 ¡) ¡ ¡ b2 ¡ free( ¡b2 ¡) ¡ ¡ b3 ¡= ¡malloc( ¡BUF_SIZE1 ¡+ ¡BUF_SIZE2 ¡) ¡ ¡ strncpy( ¡b3, ¡argv[1], ¡BUF_SIZE1+BUF_SIZE2-­‑1 ¡) ¡ data2 ¡ free( ¡b2 ¡) ¡ With ¡a ¡clever ¡argv[1]: ¡ Interprets ¡b2-­‑8 ¡as ¡a ¡chunk3.leg ¡ write ¡a ¡4-­‑byte ¡word ¡to ¡an ¡ Interprets ¡b2-­‑4 ¡as ¡a ¡chunk3.right ¡ arbitrary ¡loca9on ¡in ¡memory ¡ (b2 ¡-­‑ ¡8)-­‑>leg-­‑>right ¡= ¡(b2-­‑8)-­‑>right ¡ ¡ ¡ chunk2.leg ¡ (b2 ¡-­‑ ¡8)-­‑>right-­‑>leg ¡= ¡(b2-­‑8)-­‑>leg ¡ ¡ ¡ NULL ¡ 1 ¡

  19. What ¡type ¡of ¡vulnerability ¡might ¡this ¡be? ¡ This ¡is ¡ridiculously ¡simple ¡example. ¡ Manual ¡analysis ¡is ¡very ¡Fme ¡ consuming. ¡

  20. Program ¡Analyzers ¡ analyze ¡large ¡ ¡ code ¡bases ¡ Code ¡ Report ¡ ¡ Type ¡ Line ¡ 1 ¡ mem ¡leak ¡ 324 ¡ 2 ¡ buffer ¡oflow ¡ 4,353,245 ¡ false ¡alarm ¡ Program ¡ 3 ¡ sql ¡injecFon ¡ 23,212 ¡ Analyzer ¡ 4 ¡ stack ¡oflow ¡ 86,923 ¡ false ¡alarm ¡ 5 ¡ dang ¡ptr ¡ 8,491 ¡ Spec ¡ … ¡ … ¡ … ¡ 10,502 ¡ info ¡leak ¡ 10,921 ¡ poten9ally ¡ ¡ may ¡emit ¡ ¡ reports ¡many ¡ false ¡alarms ¡ warnings ¡ Slide ¡credit: ¡Prof ¡Mitchell ¡Stanford’s ¡CS ¡155 ¡

  21. Program ¡analyzers ¡ • StaFc ¡analysis ¡ – Do ¡not ¡execute ¡program ¡ ¡ • Dynamic ¡analysis ¡ – Execute ¡program ¡on ¡test ¡cases ¡

  22. Soundness, ¡Completeness ¡ Property ¡ Defini9on ¡ Soundness ¡ If ¡the ¡program ¡contains ¡an ¡error, ¡ the ¡analysis ¡will ¡report ¡a ¡warning. ¡ “Sound ¡for ¡reporFng ¡correctness” ¡ Completeness ¡ If ¡the ¡analysis ¡reports ¡an ¡error, ¡the ¡ program ¡will ¡contain ¡an ¡error. ¡ “Complete ¡for ¡reporFng ¡correctness” ¡ Slide ¡credit: ¡Prof ¡Mitchell ¡Stanford’s ¡CS ¡155 ¡

  23. Complete ¡ Incomplete ¡ Reports ¡all ¡errors ¡ Sound ¡ Reports ¡all ¡errors ¡ May ¡report ¡false ¡alarms ¡ Reports ¡no ¡false ¡alarms ¡ Undecidable ¡ Decidable ¡ Unsound ¡ May ¡not ¡report ¡all ¡errors ¡ May ¡not ¡report ¡all ¡errors ¡ May ¡report ¡false ¡alarms ¡ Reports ¡no ¡false ¡alarms ¡ Decidable ¡ Decidable ¡ Slide ¡credit: ¡Prof ¡Mitchell ¡Stanford’s ¡CS ¡155 ¡

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