Coder Social home page Coder Social logo

csurf-attack-poc's Introduction

csurf-attack-poc

Demonstration of an attack against express that's using csurf library with cookie signing enabled.

To run it:

  • checkout the repo
  • go into csurf-signed-attacker and run npm i
  • go into csurf-signed-victim and run npm i
  • modify csurf-signed-attacker/node_modules/cookie-signature/index.js line 42 so it always returns str and does not check signature
  • run npm start for both apps
  • attacker website will run on :3001, victim one on :3000
  • to demonstrate it nicely setup hosts on your local to simulate domain and subdomain, for example add/modify line like this: 127.0.0.1 localhost csrftest.com 1.csrftest.com

There are two phases of the attack:

  1. preparation by the attacker
  2. victim visiting attacker website (phishing or so, as usual with CSRF)

Preparation

  • attacker visits victim website - csrftest.com:3000 and saves signed cookie value

Actual attack

  • victim visits attacker website on a subdomain - for example 1.csrftest.com:3001 in our case, I'm using different ports to make it easier to run on localhost with vanila setup
  • attacker website toses signed cookie value obtained previously into a cookie with domain set to .csrftest.com and with specific path - in our case /csrfprotected - that's happening by visiting http://1.csrftest.com:3000/toss?tossme=XYZ where XYZ is value previously captured by the attacker
  • attacker website tricks user into submitting (or submits via JS) form available on 1.csrftest.com:3001
  • CSRF token present on the attacker website gets accepted on victims website

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.