Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper handling of requests containing both Content-Length and Transfer-Encoding headers #2560

Open
kenballus opened this issue Sep 5, 2023 · 0 comments

Comments

@kenballus
Copy link
Contributor

From RFC 7230:

If a message is received with both a Transfer-Encoding and a
Content-Length header field, the Transfer-Encoding overrides the
Content-Length. Such a message might indicate an attempt to
perform request smuggling (Section 9.5) or response splitting
(Section 9.4) and ought to be handled as an error. A sender MUST
remove the received Content-Length field prior to forwarding such
a message downstream.

This language was tightened up in RFC 9112:

If a message is received with both a Transfer-Encoding and a Content-Length header field, the Transfer-Encoding overrides the Content-Length. Such a message might indicate an attempt to perform request smuggling (Section 11.2) or response splitting (Section 11.1) and ought to be handled as an error. An intermediary that chooses to forward the message MUST first remove the received Content-Length field and process the Transfer-Encoding (as described below) prior to forwarding the message downstream.

In short, there are two appropriate responses to a request containing both a Content-Length and Transfer-Encoding header:

  1. Ignore the Content-Length header. (Recommended by RFC 7230) (this is what Apache, Caddy, and IIS do)
  2. Reject the message. (Recommended by RFC 9112) (this is what Nginx, Node, and LiteSpeed do)

Right now, uwsgi has the Content-Length header override the Transfer-Encoding header. This behavior should be updated to match the standards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant