Skip to content

Strip header trailing ows#52

Open
ioquatix wants to merge 2 commits intomainfrom
strip-header-trailing-ows
Open

Strip header trailing ows#52
ioquatix wants to merge 2 commits intomainfrom
strip-header-trailing-ows

Conversation

@ioquatix
Copy link
Member

@ioquatix ioquatix commented Mar 10, 2026

Fixes #47.

Types of Changes

  • Bug fix.

Contribution

@kenballus
Copy link

This patch introduces a vulnerability, and should not be merged as-is.

Because rstrip strips \x0b and \x0c in addition to the characters we want, this causes the server to interpret Transfer-Encoding: chunked\x0c equivalently to Transfer-Encoding: chunked. This renders the server vulnerable to request smuggling when used with proxies that forward unrecognized transfer-codings (of which there are many).

This is why my original patch used a regex; rstrip alone is not the right tool for the job.

@ioquatix
Copy link
Member Author

Thanks for your feedback. In Ruby 4+, we can write rstrip(" \t") which is fast. We can probably use a combination of sub on Ruby < 4 and rstrip(" \t") on Ruby 4+.

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

Successfully merging this pull request may close these issues.

Whitespace is not stripped from the right side of header values, as the RFCs require

2 participants