Summary
Starlet versions before 0.33 can send response bodies for HEAD requests and for responses with status 204 or 304, contrary to HTTP semantics. On persistent or pipelined connections, clients or proxies may mistake those extra bytes for the next response, potentially desynchronizing shared proxy connections.
Affected context
The issue affects Starlet's HTTP response handling when a connection is kept open, including persistent or pipelined HTTP/1.1 requests. The response writer does not receive the request method, so it may send a body even when the method or status requires one to be omitted. An empty body can still produce a chunked-encoding terminator when no Content-Length header is present.
Exploit preconditions
- Attack surface: HTTP requests handled by a Starlet server over a persistent or pipelined connection
- Required access: The ability to send requests to the affected service; authentication requirements depend on the application
- Trigger point: A HEAD request, or a response with status 204 or 304, followed by another response on the same connection
- Why exploitation is possible: Extra body or chunk-terminator bytes can be interpreted as the beginning of the next response; risk can increase when a proxy reuses a connection across clients
Why this happens
The response writer does not receive the request method and therefore cannot reliably suppress response bodies for HEAD requests. It also sends bodies for statuses such as 204 and 304, where HTTP semantics require no response body. These behaviors map to CWE-444: Inconsistent Interpretation of HTTP Requests, because the server and a client or intermediary can interpret the same connection's response boundaries differently.
Potential impact
- A client or proxy may misparse response boundaries on a persistent connection.
- A shared proxy connection could become desynchronized across requests or clients.
- Subsequent responses may be associated with the wrong request, potentially exposing or corrupting response data.
- Connection handling and service reliability may be disrupted.
General mitigation guidance
Defensive patterns focus on keeping response framing consistent with HTTP semantics and ensuring connection handling is safe by default.
- Pass request-method context to response generation and suppress bodies for HEAD responses.
- Enforce body suppression for status codes that do not permit response bodies, including 204 and 304.
- Use unambiguous, correct response framing and validate behavior for persistent and pipelined connections.
- Avoid sharing upstream connections across clients unless response boundaries are reliably enforced.
- Apply least privilege and limit access to exposed services where practical.
How teams detect issues like this
- Use static analysis or code review to identify response writers that lack request-method or status context.
- Review handling of HEAD, 204, and 304 responses, including chunked encoding and connection reuse.
- Test persistent and pipelined requests to verify that each response is framed and associated with the correct request.
- Apply HTTP parsing and proxy policies that reject malformed or ambiguous response framing.
- Automated security review tools may help identify inconsistent HTTP handling patterns.

