1 / 5

Cross-site request forgery

Cross-site request forgery. (CSRF, XSRF, One-click attack, session riding). Intro – what is CSRF?. CSRF is a request made to the server that the server is not able to determain is coming from the user or an attacker. Example. Bank. Facebook. Browser. Bill. Favorite Forum/blog.

mandell
Download Presentation

Cross-site request forgery

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cross-site request forgery (CSRF, XSRF, One-click attack, session riding)

  2. Intro – what is CSRF? • CSRF is a request made to the server that the server is not able to determain is coming from the user or an attacker.

  3. Example Bank Facebook Browser Bill Favorite Forum/blog http://mybank.com/showaccount?id=bill http://mybank.com/withdraw?from=bill&amount=10000&for=someguy <img src=http://mybank.com/withdraw?from=bill&amount=10000&for=someguy />

  4. How to protect yourselves • Use POST instead of GET (when changing data) • Limiting the lifetime of session cookies • Re-authenticate on important requests • Save a unique ID in the session and verify each request

  5. Example <?php session_start(); if(!$_SESSION['UNIQUEID']) { $_SESSION['UNIQUEID'] = createRandomKey(); } if($_POST) { if($_POST['UNIQUEID'] != $_SESSION['UNIQUEID']) { exit('not a valid request'); } } public function createRandomKey() { $keyset = "abcdefghijklmABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $randkey = ""; $amount = "10"; for ($i=0; $i < $amount; $i++) { $randkey .= substr($keyset, rand(0, strlen($keyset)-1), 1); } return $randkey; } ?>

More Related