Skip to content
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

CVE-2023-49081/2 fix question #8058

Closed
1 task done
kylebambrick opened this issue Jan 25, 2024 · 12 comments
Closed
1 task done

CVE-2023-49081/2 fix question #8058

kylebambrick opened this issue Jan 25, 2024 · 12 comments
Labels

Comments

@kylebambrick
Copy link

kylebambrick commented Jan 25, 2024

Describe the bug

Hello,

Please let me know if I'm missing something. While looking into backporting the recent CVEs, I found the fixes for GHSA-q3qx-c6g2-7pw2 and GHSA-qvrw-v9rv-5rjx do not stop the PoCs at https://gist.github.com/jnovikov/184afb593d9c2114d77f508e0ccd508e and https://gist.github.com/jnovikov/7f411ae9fe6a9a7804cf162a3bdbb44b. It looks like 3.9.0 introduced checks/sanitization in the http_parser.py. However, the PoC demonstrates an attack in client.py.

See the #8057 for something that may catch the malformed parameters. For GHSA-q3qx-c6g2-7pw2, the changes add an HTTP version check to ClientSession(...) and throw an error if the version is not an HTTP version. For GHSA-qvrw-v9rv-5rjx, the changes add a check for the HTTP methods passed to request(...) and throw an error if the str is not an RFC 2616 method.

Given the attack path, it's reasonable to argue the vulnerability is informational. Using untrusted or tainted input for the HTTP version or method is really bad practice and very unlikely. In other projects, I've seen them state the parameters for a request like this (not response handling) are considered trusted input. It's up to the developer to validate the input before calling.

However, given the PoC already has a link to a CVE, every scanner is flagging older aiohttp libraries. For us downstream folks, arguing against fixing a published CVE (or NVD's severity) is harder than getting the issue fixed. It's equally painful to deal with a rejected or disputed CVE. So, I recommend fixing the issue and updating the CVEs with a new fix version (and a new severity). Whatever was fixed (with http_parser?) should get a new CVE. Anyway, your call.

Please let me know if you have any questions.

Regards,
Kyle

To Reproduce

See the PoCs at the PoCs at https://gist.github.com/jnovikov/184afb593d9c2114d77f508e0ccd508e and https://gist.github.com/jnovikov/7f411ae9fe6a9a7804cf162a3bdbb44b.

Expected behavior

We would expect to throw a value error when supplied an invalid RFC 2616 method or HTTP version.

Logs/tracebacks

N/A

Python Version

C:\git\aiohttp>python --version
Python 3.10.11

aiohttp Version

C:\git\aiohttp>python -m pip show aiohttp   
Name: aiohttp
Version: 3.9.1
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author:
Author-email:
License: Apache 2
Location: REDACTED
Requires: aiosignal, async-timeout, attrs, frozenlist, multidict, yarl
Required-by:

multidict Version

C:\git\aiohttp>python -m pip show multidict
Name: multidict
Version: 6.0.4
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: REDACTED
Requires:
Required-by: aiohttp, yarl

yarl Version

$ python -m pip show yarl
C:\git\aiohttp>python -m pip show yarl     
Name: yarl
Version: 1.9.4
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache-2.0
Location: REDACTED
Requires: idna, multidict
Required-by: aiohttp

OS

Windows 11
Version 22H2 (OS Build 22621.3007)

Related component

Client

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@Dreamsorcerer
Copy link
Member

The fix we implemented was basically a minimal change that stops the issue happening for the most part. The primary concern was accepting a JSON loaded value and passing it to the version. The change just switched from indexing the tuple to using the attributes, which means that no JSON object would be able to get past that code (as you'll now get an AttributeError).

We could take a PR to make it a bit tighter if desired, but the vulnerability was basically considered a longshot and with that change in place it now stretches credulity.

do not remediate the PoCs

If you find you can actually get an attacker modified output with a list, then we need to check it. But, you should be hitting that AttributeError instead.

@kylebambrick
Copy link
Author

kylebambrick commented Jan 25, 2024

The fix we implemented was basically a minimal change that stops the issue happening for the most part. The primary concern was accepting a JSON loaded value and passing it to the version. The change just switched from indexing the tuple to using the attributes, which means that no JSON object would be able to get past that code (as you'll now get an AttributeError).

Makes sense. I appreciate you taking the time to clarify.

We could take a PR to make it a bit tighter if desired, but the vulnerability was basically considered a longshot and with that change in place it now stretches credulity.

No need. I was confused given only the information in the PoC and advisory.

If you find you can actually get an attacker modified output with a list, then we need to check it. But, you should be hitting that AttributeError instead.

Sounds good. Thanks again!

Could you please link the PR(s) for the fix for future reference? I'm having trouble finding it. It might clear up future confusion in case anyone stumbles on this.

@kylebambrick kylebambrick changed the title CVE-2023-49081/2 fix issue CVE-2023-49081/2 fix question Jan 25, 2024
@webknjaz
Copy link
Member

@kylebambrick I'd like to call out that it is important to report anything security-sensitive and related concerns through the private channels as specified by https://github.com/aio-libs/aiohttp/security/policy and keep it that way until it's determined if it's acceptable to be shared publicly. So that such things are processed and disclosed responsibly.

@kylebambrick
Copy link
Author

Sorry. Given the PoC and CVE were public (and not novel), I felt it more appropriate to provide all the information in a public bug. I will follow that process in the future. Thanks for letting me know.

@webknjaz
Copy link
Member

Right. It's just that you claim that a CVE is not actually addressed and this information may mean there's something extra to consider. I think that the rule of thumb should be that whenever there's any hint or uncertainty that a post may point to some potential vulnerability, it's best to double-check and privately confirm whether it's okay to go public.

Of course, all parties here are volunteers, and I recognize that I do set the bar high. So I can't expect anybody to always be on top of everything. Just trying to be mindful of the responsibility to the community we're all a part of.

Is there anything that would make such messaging clearer? Maybe, an extra paragraph in the security policy or a warning in the issue forms?

@kylebambrick
Copy link
Author

No, I think it's fine how it is.

@webknjaz Do you know the PRs that fixed CVE-2023-49081 and CVE-2023-49082?

@webknjaz
Copy link
Member

It looks like they didn't make it into the changelog: https://docs.aiohttp.org/en/latest/changes.html#id177.
@Dreamsorcerer do you have proper links to the patches? When making security releases I'd normally include change fragments. Although, I was doing it in a way that I had local commits and a tag. I was pushing the tag first, to trigger publishing. And only when it succeeded, I was pushing the branch with those commits. Do you think you could integrate something similar into your release routine?

@Dreamsorcerer
Copy link
Member

@webknjaz Do you know the PRs that fixed CVE-2023-49081 and CVE-2023-49082?

https://github.com/aio-libs/aiohttp/pull/7835/files
https://github.com/aio-libs/aiohttp/pull/7806/files

When making security releases I'd normally include change fragments

If we're not disclosing the issue immediately, then it probably shouldn't be highlighted in the changelog, right? But, we could certainly update the CVE to include the PR.

@webknjaz
Copy link
Member

When making security releases I'd normally include change fragments

If we're not disclosing the issue immediately, then it probably shouldn't be highlighted in the changelog, right? But, we could certainly update the CVE to include the PR.

Don't we disclose on release? Anyway, it's useful to update the changelog even if it's disclosed later.

@Dreamsorcerer
Copy link
Member

These particular ones I think were snuck into a release candidate and disclosed around a week or so later. But, I think many others we've disclosed a day or 2 later (and there was the one you had in draft for years ;) ).

@Dreamsorcerer
Copy link
Member

Also, just realised I don't know how they've produced those severity ratings on the CVEs. That one for the version is rated as high, while our own advisory is rated low (internally, I suggested this was a 1/10 severity): GHSA-q3qx-c6g2-7pw2

@Dreamsorcerer
Copy link
Member

Anyway, I assume the questions are resolved, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants