Skip to content

Conversation

kevin-mizu
Copy link
Contributor

Headers which contain _ shouldn't be allowed as they could create confusion in incoming requests, allowing, for example, the usage of CONTENT_LENGTH instead of Content-Length.

This has already been fixed in various WSGI/proxy servers:

@4383
Copy link
Member

4383 commented May 2, 2024

Thank you @kevin-mizu

Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56%. Comparing base (64d8516) to head (c0a715b).

Additional details and impacted files
@@          Coverage Diff          @@
##           master   #959   +/-   ##
=====================================
- Coverage      56%    56%   -1%     
=====================================
  Files          89     89           
  Lines        9767   9773    +6     
  Branches     1819   1821    +2     
=====================================
- Hits         5485   5483    -2     
- Misses       3913   3919    +6     
- Partials      369    371    +2     
Flag Coverage Δ
ipv6 23% <14%> (-1%) ⬇️
py310asyncio 52% <100%> (-1%) ⬇️
py310epolls 53% <100%> (-1%) ⬇️
py310poll 53% <100%> (-1%) ⬇️
py310selects 53% <100%> (-1%) ⬇️
py311asyncio 52% <100%> (-1%) ⬇️
py311epolls 53% <100%> (+<1%) ⬆️
py312asyncio 50% <100%> (-1%) ⬇️
py312epolls 51% <100%> (-1%) ⬇️
py37asyncio ?
py37epolls 51% <100%> (-1%) ⬇️
py38asyncio 51% <100%> (+<1%) ⬆️
py38epolls 53% <100%> (-1%) ⬇️
py38openssl 51% <100%> (-1%) ⬇️
py38poll 53% <100%> (-1%) ⬇️
py38selects 53% <100%> (-1%) ⬇️
py39asyncio 51% <100%> (-1%) ⬇️
py39dnspython1 51% <100%> (-1%) ⬇️
py39epolls 53% <100%> (-1%) ⬇️
py39poll 53% <100%> (-1%) ⬇️
py39selects 52% <100%> (-1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

eventlet/wsgi.py Outdated
@@ -748,6 +748,9 @@ def get_environ(self):

env['headers_raw'] = headers_raw = tuple((k, v.strip(' \t\n\r')) for k, v in headers)
for k, v in headers_raw:
if "_" in k:
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest either to internalize the treatment of this condition and of the following replacement (from line 751 to line 754) into a dedicated function with a an explicit naming (e.g formalize_key_naming) and with an explicit docstring explain the purpose of doing this, or to add a comment just before the condition you added here.

I think that without more explanations than that, at the implementation level, many people could wonders why this condition exist.

@4383
Copy link
Member

4383 commented May 2, 2024

Also, this patch brokes unit tests. I think unit testing need some adjustment to become compatible with this new rule.

@4383
Copy link
Member

4383 commented May 6, 2024

Do you plan to declare a new CVE?

@kevin-mizu
Copy link
Contributor Author

I will try to start the process this afternoon :D

@4383
Copy link
Member

4383 commented May 6, 2024

Awesome, thank you.
Lets merge this patch.

@4383 4383 merged commit ed743d7 into eventlet:master May 6, 2024
@4383 4383 mentioned this pull request Jul 22, 2024
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.

2 participants