Skip to content

Drop untrusted values from trusted proxy headers - #452

Merged
digitalresistor merged 2 commits into
Pylons:mainfrom
simonk52:drop-untrusted-proxy-values
Nov 15, 2024
Merged

digitalresistor merged 2 commits into
Pylons:mainfrom
simonk52:drop-untrusted-proxy-values

Conversation

@simonk52

@simonk52 simonk52 commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

Headers such as X-Forwarded-For, X-Forwarded-Host and Forwarded can contain more values than are actually trusted, leading to the possibility that the downstream application could interpret those headers differently to waitress.

This change rewrites the trusted headers so that they only contain the values from the trusted proxies.

Relates to issue #451

@digitalresistor

Copy link
Copy Markdown
Member

There is no reason to return a new dict called environ_rewrites, we can just update the environment inside the function, we already do that for updating other values in the environment.

Headers such as X-Forwarded-For, X-Forwarded-Host and Forwarded can
contain more values than are actually trusted, leading to the
possibility that the downstream application could interpret those
headers differently to waitress.

This change rewrites the trusted headers so that they only contain the
values from the trusted proxies.
@digitalresistor

Copy link
Copy Markdown
Member

Could you sign CONTRIBUTORS.txt please unless you already have and I missed it.

@mmerickel mmerickel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@digitalresistor
digitalresistor merged commit 291d9cb into Pylons:main Nov 15, 2024
@simonk52

Copy link
Copy Markdown
Contributor Author

Thank you! 👍

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Feb 5, 2025
3.0.2 (2024-11-16)

Security

- When using Waitress to process trusted proxy headers, Waitress will now
  update the headers to drop any untrusted values, thereby making sure that
  WSGI apps only get trusted and validated values that Waitress itself used to
  update the environ. See Pylons/waitress#452 and
  Pylons/waitress#451


3.0.1 (2024-10-28)

Backward Incompatibilities

- Python 3.8 is no longer supported.
  See Pylons/waitress#445.

Features

- Added support for Python 3.13.
  See Pylons/waitress#445.

Security

- Fix a bug that would lead to Waitress busy looping on select() on a half-open
  socket due to a race condition that existed when creating a new HTTPChannel.
  See Pylons/waitress#435,
  Pylons/waitress#418 and
  GHSA-3f84-rpwh-47g6

  With thanks to Dylan Jay and Dieter Maurer for their extensive debugging and
  helping track this down.

- No longer strip the header values before passing them to the WSGI environ.
  See Pylons/waitress#434 and
  Pylons/waitress#432

- Fix a race condition in Waitress when `channel_request_lookahead` is enabled
  that could lead to HTTP request smuggling.
arnout pushed a commit to buildroot/buildroot that referenced this pull request Feb 7, 2025
Both 3.0.1 and 3.0.2 fix security issues.

In 3.0.1:

* Fix a bug that would lead to Waitress busy looping on select() on a
  half-open socket due to a race condition that existed when creating a
  new HTTPChannel. See Pylons/waitress#435,
  Pylons/waitress#418 and
  GHSA-3f84-rpwh-47g6

* With thanks to Dylan Jay and Dieter Maurer for their extensive
  debugging and helping track this down.

* No longer strip the header values before passing them to the WSGI
  environ. See Pylons/waitress#434 and
  Pylons/waitress#432

* Fix a race condition in Waitress when channel_request_lookahead is
  enabled that could lead to HTTP request smuggling.
  See GHSA-9298-4cf8-g4wj

In 3.0.2:

* When using Waitress to process trusted proxy headers, Waitress will
  now update the headers to drop any untrusted values, thereby making sure
  that WSGI apps only get trusted and validated values that Waitress
  itself used to update the environ. See
  Pylons/waitress#452 and
  Pylons/waitress#451

Full Changelog:
https://docs.pylonsproject.org/projects/waitress/en/latest/#change-history

Signed-off-by: Marcus Hoffmann <[email protected]>
Signed-off-by: Peter Korsgaard <[email protected]>
msk pushed a commit to msk/pkgsrc that referenced this pull request May 11, 2026
3.0.2 (2024-11-16)

Security

- When using Waitress to process trusted proxy headers, Waitress will now
  update the headers to drop any untrusted values, thereby making sure that
  WSGI apps only get trusted and validated values that Waitress itself used to
  update the environ. See Pylons/waitress#452 and
  Pylons/waitress#451


3.0.1 (2024-10-28)

Backward Incompatibilities

- Python 3.8 is no longer supported.
  See Pylons/waitress#445.

Features

- Added support for Python 3.13.
  See Pylons/waitress#445.

Security

- Fix a bug that would lead to Waitress busy looping on select() on a half-open
  socket due to a race condition that existed when creating a new HTTPChannel.
  See Pylons/waitress#435,
  Pylons/waitress#418 and
  GHSA-3f84-rpwh-47g6

  With thanks to Dylan Jay and Dieter Maurer for their extensive debugging and
  helping track this down.

- No longer strip the header values before passing them to the WSGI environ.
  See Pylons/waitress#434 and
  Pylons/waitress#432

- Fix a race condition in Waitress when `channel_request_lookahead` is enabled
  that could lead to HTTP request smuggling.
jperkin pushed a commit to TritonDataCenter/pkgsrc that referenced this pull request May 14, 2026
3.0.2 (2024-11-16)

Security

- When using Waitress to process trusted proxy headers, Waitress will now
  update the headers to drop any untrusted values, thereby making sure that
  WSGI apps only get trusted and validated values that Waitress itself used to
  update the environ. See Pylons/waitress#452 and
  Pylons/waitress#451


3.0.1 (2024-10-28)

Backward Incompatibilities

- Python 3.8 is no longer supported.
  See Pylons/waitress#445.

Features

- Added support for Python 3.13.
  See Pylons/waitress#445.

Security

- Fix a bug that would lead to Waitress busy looping on select() on a half-open
  socket due to a race condition that existed when creating a new HTTPChannel.
  See Pylons/waitress#435,
  Pylons/waitress#418 and
  GHSA-3f84-rpwh-47g6

  With thanks to Dylan Jay and Dieter Maurer for their extensive debugging and
  helping track this down.

- No longer strip the header values before passing them to the WSGI environ.
  See Pylons/waitress#434 and
  Pylons/waitress#432

- Fix a race condition in Waitress when `channel_request_lookahead` is enabled
  that could lead to HTTP request smuggling.
tsutsui pushed a commit to tsutsui/pkgsrc that referenced this pull request Oct 17, 2026
3.0.2 (2024-11-16)

Security

- When using Waitress to process trusted proxy headers, Waitress will now
  update the headers to drop any untrusted values, thereby making sure that
  WSGI apps only get trusted and validated values that Waitress itself used to
  update the environ. See Pylons/waitress#452 and
  Pylons/waitress#451


3.0.1 (2024-10-28)

Backward Incompatibilities

- Python 3.8 is no longer supported.
  See Pylons/waitress#445.

Features

- Added support for Python 3.13.
  See Pylons/waitress#445.

Security

- Fix a bug that would lead to Waitress busy looping on select() on a half-open
  socket due to a race condition that existed when creating a new HTTPChannel.
  See Pylons/waitress#435,
  Pylons/waitress#418 and
  GHSA-3f84-rpwh-47g6

  With thanks to Dylan Jay and Dieter Maurer for their extensive debugging and
  helping track this down.

- No longer strip the header values before passing them to the WSGI environ.
  See Pylons/waitress#434 and
  Pylons/waitress#432

- Fix a race condition in Waitress when `channel_request_lookahead` is enabled
  that could lead to HTTP request smuggling.
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.

3 participants