A great place to start is the Scenarios section, followed by the Demonstrating the exploits section.
- CS5331
[ browser ] <===> [ proxy (HAProxy) ] <===> [ backend (Gunicorn) ]
-
Background:
backend
has a/protected
page that is not meant to be accessible by the web browser as theproxy
maps/protected
to/unauthorized
. This means that requesting for/protected
via theproxy
will result in getting the contents of/unauthorized
from thebackend
. -
Goal: View the contents of
/protected
page.
-
Background:
backend
has a/redirected
page which has anOpen Redirect
vulnerability. It redirects the user based on theHost
header of the request. This cannot be exploited for phishing-related acts on a victim as there is no way to override theHost
header using normal means. -
Goal: Force a victim to be redirected to an arbitrary URL.
-
Background:
backend
has a/reflected
page which has anReflected XSS
vulnerability. It prints the contents of theUser-Agent
header of the request. This cannot be exploited to execute Javascript payloads on the victim as there is no way to override theUser-Agent
header using normal means. -
Goal: Force a victim to execute arbitrary Javascript code.
-
Background:
backend
has a/captured
page that receivescontent
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.
- Gunicorn (Apparently this was not assigned a CVE???): https://grenfeldt.dev/2021/04/01/gunicorn-20.0.4-request-smuggling/
- HAProxy CVE-2021-40346: https://nvd.nist.gov/vuln/detail/CVE-2021-40346
./backend/*
: Contains files to build thebackend
container./proxy/*
: Contains files to build theproxy
container./poc/*
: Contains scripts to run attacks
- Make code changes
docker-compose build
docker-compose up
- Repeat.
poc1.py
: Exploits Gunicorn's vulnerability to poison the next user's requestpoc1_redirect.py
: Exploits Gunicorn's vulnerability to force the user to be redirected tohttp://www.example.com
.poc1_xss.py
: Exploits Gunicorn's vulnerability to force the user's browser to executealert(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 requestpoc2_redirect.py
: Exploits HAProxy's vulnerability to force the user to be redirected tohttp://www.example.com
.poc2_xss.py
: Exploits HAProxy's vulnerability to force the user's browser to executealert(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
- Execute
python3 poc1.py
. - Within the next 30s, browse to
http://localhost
.
- Execute
python3 poc1_redirect.py
. - Within the next 30s, browse to
http://localhost
.
- Execute
python3 poc1_xss.py
. - Within the next 30s, browse to
http://localhost
.
- Execute
python3 poc1_capture.py
. - Within the next 30s, execute the following:
curl http://localhost/ -H "Cookie: FLAG"
- Browse to
http://localhost/captured
.