Drop request body on cross-origin 307/308 redirects - #923
Closed
benoitc wants to merge 1 commit into
Closed
Conversation
A 307/308 keeps the method and body, but the body was forwarded to the redirect target regardless of origin. maybe_strip_auth_on_redirect only filtered auth/cookie options, so a POST/PUT/PATCH body still reached a different host, leaking request contents (same in the HTTP/1.1, HTTP/2 and HTTP/3 paths). Clear the body when the redirect leaves the original host unless the caller set location_trusted, matching the credential-header stripping.
Owner
Author
|
After checking against RFC 9110, I close this one. For a 307/308 the client must keep the same method and the body, this is exactly why these codes exist. And the browsers, node-fetch, curl, they all keep the body on a cross-origin redirect too, they only strip the credential headers (Authorization, Cookie, Proxy-Authorization), which we already do. So dropping the body is not correct here, it would break the legit cases like the S3 presigned upload or an API gateway hand-off. The real risk on cross-origin is the credentials, and this part is already handled. So no need for this change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A 307/308 keeps the method and body, but the body was forwarded to the redirect target regardless of origin; only auth and cookie options were stripped. A POST/PUT/PATCH body still reached a different host and leaked request contents, across the HTTP/1.1, HTTP/2 and HTTP/3 paths. Clear the body when the redirect leaves the original host unless the caller set
location_trusted, matching the credential-header stripping.