Make sure GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN is not set in a production environment. So the following is correct:
assert os.getenv("GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN") is None
Vulnerability Overview
Vulnerable Code Analysis
PoC Description
curl Example
https://localhost/auth-codespace?redirect_to=http://google.com
Phishing/Social Engineering Attacks
Users can be exploited by immediately redirecting from a trusted domain to external malicious sites, taking advantage of user trust. This enables login page spoofing, credential harvesting, and redirection to malware distribution pages.
Authentication/Session Flow Disruption
When users with valid sessions/cookies from the same origin click the link, they are redirected to unintended external domains, which can bypass or disrupt authentication/authorization flows. When combined with redirect-based flows like OAuth/OIDC, this can escalate into security incidents.