Skip to content
Access control Write-up Intermediate

The Question Mark That Broke Authentication Across Half the Pytho

Starlette reconstructed request.url from an unvalidated Host header, so a crafted Host header containing a question mark made request.url.path differ from the real path used by the router. Middleware that authorised requests based on request.url.path could therefore be bypassed, allowing unauthenticated access to protected endpoints.

Aditya Inamdar Follow

Published on inamdaraditya.medium.com

Click here to access this for free: https://inamdaraditya.medium.com/the-question-mark-that-broke-authentication-across-half-the-python-ai-stack-1c64d42a3d26?sk=d49be65f6f6bb165a1650b77396d5309

Aditya Inamdar, on inamdaraditya.medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Starlette concatenated the unvalidated Host header with the raw path to build request.url, so characters like ?, / and # in the Host header changed the apparent path while the router still dispatched on the raw ASGI scope path.

Impact

An unauthenticated attacker could reach protected endpoints on any affected Starlette-based service whose middleware read request.url.path, and chaining this with a separate LiteLLM command injection flaw could yield unauthenticated remote code execution; the text notes that an upstream proxy or WAF validating the Host header blocks the bypass.

What the attacker needed

Target runs Starlette before 1.0.1; Path-based auth middleware reads request.url.path; Attacker can set the Host header

The fix

Starlette 1.0.1 was released to validate the Host header against the RFC grammar before using it to reconstruct request.url, falling back to the ASGI server value when invalid.

How it was found

  1. Send a request to a protected endpoint with a normal Host header and observe it is blocked.
  2. Send the same request with a question mark appended to the Host header.
  3. Observe that the protected endpoint now returns a successful response without credentials.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A web framework called Starlette builds a full web address for each incoming request by gluing together the address the client claims to be asking for (the Host header) and the path. It never checked that the Host header was a plain hostname. By adding a question mark to the Host header, an attacker could make the framework think the request was for a harmless path like /abc, while the router still sent it to the protected /admin endpoint. Any security check that looked at the framework's rebuilt address was fooled.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.