-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Backwards incompatibility with header parsing from 3.8.4 to 3.8.5 #7468
Comments
This is expected result of fixing a request smuggling security vulnerability. Newer RFCs are stricter regarding what should be a header separator. It can't be just CR or LF anymore and must always be a CR LF pair. |
@Dreamsorcerer should that byte-string marker leak like this? It's probably confusing to people.. |
So the original script that caused the linked issue at the top of my post also included #!/bin/bash
SERVER=127.0.0.1
nc -i 1 ${SERVER} 8080 <<< unix2dos<<EOF
GET /world HTTP/1.1
Host: 127.0.0.1
EOF I stripped that out for this issue report since I was trying to keep the steps to reproduce as simple as possible. I was able to reproduce it even with that in there but upon further testing it looks like the underlying problem is really that So thanks for the explanation and in agreement, this is not an aiohttp issue. Although if considering improving the error message I would appreciate that. It was quite confusing, I wasn't sure what that marker was pointing to or trying to tell me as it appeared to be pointing to the single quote beyond the end of the header. |
I'm pretty sure in testing, I saw errors with |
OK, it's because I'm splitting on |
Actually, I can just split it on |
) **This is a backport of PR #7480 as merged into master (1fb06bb).** Fixes #7468. Co-authored-by: Sam Bull <[email protected]>
I wonder if we could use https://docs.python.org/3/library/unicodedata.html#unicodedata.name for anything non-ASCII in the error representation. |
Seems like it doesn't really work for any of the characters we'd particularly want it for (it also requires str, which means we need to encode it first and it might not be valid utf-8):
It'd also become more complex to figure out the pointer positioning. I think bytes is pretty clear, a developer can look up the characters themselves if they are unfamiliar with it. |
) **This is a backport of PR #7480 as merged into master (1fb06bb).** Fixes #7468. Co-authored-by: Sam Bull <[email protected]>
@Dreamsorcerer true. Though, it'd be nice to have something like this conceptually, maybe not through unicode but with code-points for everything non-ASCII.. I was wondering whether to task one of my mentees with this research, it doesn't seem too complicated. |
Up to you, but I'm not sure it adds much, and there are a bunch of other tasks I think would be more useful to look at. |
Maybe we could just do |
Yeah, if you think that's preferable. I was just thinking it would be clear what format it is being displayed in, so a user knows that |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [aiohttp](https://togithub.com/aio-libs/aiohttp) | `==3.8.5` -> `==3.8.6` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/aiohttp/3.8.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/aiohttp/3.8.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/aiohttp/3.8.5/3.8.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/aiohttp/3.8.5/3.8.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>aio-libs/aiohttp (aiohttp)</summary> ### [`v3.8.6`](https://togithub.com/aio-libs/aiohttp/blob/HEAD/CHANGES.rst#386-2023-10-07) [Compare Source](https://togithub.com/aio-libs/aiohttp/compare/v3.8.5...v3.8.6) \================== ## Security bugfixes - Upgraded the vendored copy of llhttp\_ to v9.1.3 -- by :user:`Dreamsorcerer` Thanks to :user:`kenballus` for reporting this, see GHSA-pjjw-qhg8-p2p9. .. \_llhttp: https://llhttp.org `#​7647 <https://github.com/aio-libs/aiohttp/issues/7647>`\_ - Updated Python parser to comply with RFCs 9110/9112 -- by :user:`Dreamorcerer` Thanks to :user:`kenballus` for reporting this, see GHSA-gfw2-4jvh-wgfg. `#​7663 <https://github.com/aio-libs/aiohttp/issues/7663>`\_ ## Deprecation - Added `fallback_charset_resolver` parameter in `ClientSession` to allow a user-supplied character set detection function. Character set detection will no longer be included in 3.9 as a default. If this feature is needed, please use `fallback_charset_resolver <https://docs.aiohttp.org/en/stable/client_advanced.html#character-set-detection>`\_. `#​7561 <https://github.com/aio-libs/aiohttp/issues/7561>`\_ ## Features - Enabled lenient response parsing for more flexible parsing in the client (this should resolve some regressions when dealing with badly formatted HTTP responses). -- by :user:`Dreamsorcerer` `#​7490 <https://github.com/aio-libs/aiohttp/issues/7490>`\_ ## Bugfixes - Fixed `PermissionError` when `.netrc` is unreadable due to permissions. `#​7237 <https://github.com/aio-libs/aiohttp/issues/7237>`\_ - Fixed output of parsing errors pointing to a `\n`. -- by :user:`Dreamsorcerer` `#​7468 <https://github.com/aio-libs/aiohttp/issues/7468>`\_ - Fixed `GunicornWebWorker` max_requests_jitter not working. `#​7518 <https://github.com/aio-libs/aiohttp/issues/7518>`\_ - Fixed sorting in `filter_cookies` to use cookie with longest path. -- by :user:`marq24`. `#​7577 <https://github.com/aio-libs/aiohttp/issues/7577>`\_ - Fixed display of `BadStatusLine` messages from llhttp\_. -- by :user:`Dreamsorcerer` `#​7651 <https://github.com/aio-libs/aiohttp/issues/7651>`\_ *** </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/allenporter/pyrainbird). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjMiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Describe the bug
I received home-assistant/supervisor#4454 in my project and the root cause turned out to be the update of aiohttp from 3.8.4 to 3.8.5. I was able to clearly reproduce it in a vanilla aiohttp server set up from the example here and having a script make a call providing a
Host
header. The same script works when the server is running on 3.8.4 and fails if I update to 3.8.5.To Reproduce
hello world
response as expectedExpected behavior
The same script should work on 3.8.4 and 3.8.5
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
macOS
Also have been able to reproduce it on a variety of systems running the Home Assistant software which depends on aiohttp, as described in the issue I linked at the top.
Related component
Server
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: