GithubHelp home page GithubHelp logo

rizemon / cs5331 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 17 KB

Vulnerable environment and PoC scripts to demonstrate possible impacts of HTTP request smuggling

Dockerfile 4.11% Python 95.89%
http requestsmuggling gunicorn haproxy cve-2021-40346

cs5331's Introduction

CS5331

A great place to start is the Scenarios section, followed by the Demonstrating the exploits section.

Network Setup

[ browser ] <===> [ proxy (HAProxy) ] <===> [ backend (Gunicorn) ]

Scenarios

Bypassing access controls (/protected)

  • Background: backend has a /protected page that is not meant to be accessible by the web browser as the proxy maps /protected to /unauthorized. This means that requesting for /protected via the proxy will result in getting the contents of /unauthorized from the backend.

  • Goal: View the contents of /protected page.

Forcing open-directs onto other users (/redirected)

  • Background: backend has a /redirected page which has an Open Redirect vulnerability. It redirects the user based on the Host header of the request. This cannot be exploited for phishing-related acts on a victim as there is no way to override the Host header using normal means.

  • Goal: Force a victim to be redirected to an arbitrary URL.

Forcing reflected XSS onto other users (/reflected)

  • Background: backend has a /reflected page which has an Reflected XSS vulnerability. It prints the contents of the User-Agent header of the request. This cannot be exploited to execute Javascript payloads on the victim as there is no way to override the User-Agent header using normal means.

  • Goal: Force a victim to execute arbitrary Javascript code.

Stealing user's session cookies (/captured)

  • Background: backend has a /captured page that receives content from the body data of the request and stores it in an in-memory array, which can be viewed.

  • Goal: Force a victim's next request (containing a FLAG cookie) to be saved into the in-memory array.

Relevant vulnerabilities

Directory Layout

  • ./backend/*: Contains files to build the backend container
  • ./proxy/*: Contains files to build the proxy container
  • ./poc/*: Contains scripts to run attacks

Making Changes

  1. Make code changes
  2. docker-compose build
  3. docker-compose up
  4. Repeat.

PoC Scripts

  • poc1.py: Exploits Gunicorn's vulnerability to poison the next user's request
    • poc1_redirect.py: Exploits Gunicorn's vulnerability to force the user to be redirected to http://www.example.com.
    • poc1_xss.py: Exploits Gunicorn's vulnerability to force the user's browser to execute alert(document.domain).
    • poc1_capture.py: Exploits Gunicorn's vulnerability to capture the next user's request and store it into the server's in-memory array
  • poc2.py: Exploits HAProxy's vulnerability to poison the next user's request
    • poc2_redirect.py: Exploits HAProxy's vulnerability to force the user to be redirected to http://www.example.com.
    • poc2_xss.py: Exploits HAProxy's vulnerability to force the user's browser to execute alert(document.domain).
    • poc2_capture.py: Exploits HAProxy's vulnerability to capture the next user's request and store it into the server's in-memory array

Demonstrating the exploits

Bypassing access controls

  1. Execute python3 poc1.py.
  2. Within the next 30s, browse to http://localhost.

Forcing open-directs onto other users

  1. Execute python3 poc1_redirect.py.
  2. Within the next 30s, browse to http://localhost.

Forcing reflected XSS onto other users

  1. Execute python3 poc1_xss.py.
  2. Within the next 30s, browse to http://localhost.

Stealing user's session cookies

  1. Execute python3 poc1_capture.py.
  2. Within the next 30s, execute the following:
    curl http://localhost/ -H "Cookie: FLAG"
  3. Browse to http://localhost/captured.

cs5331's People

Contributors

rizemon avatar 3m0w33d avatar

Watchers

 avatar

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.