Repository navigation
fix: make the sensitive_data_exposure lab usable under Docker Compose - #581
Open
PRAteek-singHWY wants to merge 1 commit into
Open
PRAteek-singHWY wants to merge 1 commit into
PRAteek-singHWY wants to merge 1 commit into
Conversation
Lab hostnames used the lab name as is, which has underscores. The sensitive_data_exposure lab is a Django app and rejects those hosts with DisallowedHost, so the lab part of the hostname now uses dashes. traefik_auth_verify accepts both forms so running labs keep working. The lab also sets its own "sessionid" cookie, which replaced PyGoat's shared session cookie on the lab host and made ForwardAuth return 401 after logging into the lab. PyGoat's session cookie is now named "pygoat_sessionid". Fixes adeyosemanputra#580 Signed-off-by: PRAteek-singHWY <prateek23022004@gmail.com>
Author
|
Hi @RupakBiswas-2304 This PR fixes #580, where the Sensitive Data Exposure lab couldn't be used under Docker Compose. I tested it end to end on the Docker Compose stack, and the lab now loads and you stay logged into PyGoat after logging into it. Happy to iterate based on your review. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Sensitive Data Exposure lab couldn't be used under Docker Compose. Its hostname had underscores, which Django rejects, and once that was out of the way, logging into the lab replaced PyGoat's session cookie and ForwardAuth locked you out. This PR fixes both, so the lab loads and you can log into it while staying logged into PyGoat.
Problem / Motivation
lab-<user>-<lab_name>.<domain>, and every lab name has an underscore. The Flask labs don't care, but sensitive_data_exposure is a Django app and answers every request with DisallowedHost (400), so not even its login page loads.traefik_auth_verifycan check who owns the lab. The lab uses the same default cookie name,sessionid. After logging into the lab, the browser sends twosessionidcookies, Django keeps the lab's one, and ForwardAuth returns 401 for every page after the login.Fixes #580
Solution / Approach
_get_lab_hostname()builds the hostname with-in place of_in the lab part, for examplelab-alice-sensitive-data-exposure.lvh.me.start_labreturns that URL, and the TraefikHost()rule uses it. Container names don't change, so the quota, stop and list logic is untouched.traefik_auth_verifyaccepts both the dashed and the old underscore form of each known lab, so labs that are already running keep working until they're restarted.SESSION_COOKIE_NAME = "pygoat_sessionid"next to the other shared-cookie settings, so no lab can replace PyGoat's session. Nothing reads the cookie by name, so no other code changes.Files Changed
challenge/views.py_get_lab_hostname(), use it for the returned lab URL and the TraefikHost()ruleintroduction/views.pytraefik_auth_verifypygoat/settings.pySESSION_COOKIE_NAME = "pygoat_sessionid"challenge/tests.pystart_labreturns a dashed URL and Host rule, while the container name stays the sameintroduction/tests.pysessionidsent next to PyGoat'sImpact
lab-<user>-xss_lab...tolab-<user>-xss-lab.... The sidebar uses the URL the server returns, so nothing else needs updating.sessionidcookie isn't read anymore. They just log in again.sessionidcookie is present.demogoes to the profile page, and its other pages load. The XSS lab works on its new hostname, stopping one lab or all labs from PyGoat still works, and the PyGoat session stays logged in throughout.