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

Mitigate CVE-2024-33663 #285

Closed
scy opened this issue Dec 12, 2024 · 5 comments · Fixed by #292
Closed

Mitigate CVE-2024-33663 #285

scy opened this issue Dec 12, 2024 · 5 comments · Fixed by #292
Assignees
Labels
area:backend Related to the server component flag:security Impacts the overall security of the system prio:A Blocker, needs to be addressed type:bug Something isn't working

Comments

@scy
Copy link
Collaborator

scy commented Dec 12, 2024

The library we're using for JWT-based authentication (i.e., the tokens the frontend is using to authenticate with the backend), python-jose, has an open security vulnerability, CVE-2024-33663, since April. There is no fix available, and development of the library seems to have stalled.

Having skimmed the details, I wonder whether we can mitigate this short-term by pinning the list of allowed algorithms. However, we might also just switch to a library that doesn't have this problem and that's actively maintained, e.g. PyJWT.

@scy scy added type:bug Something isn't working area:backend Related to the server component flag:security Impacts the overall security of the system labels Dec 12, 2024
@scy scy added this to the 4.0: public release milestone Dec 12, 2024
@jbethune
Copy link
Collaborator

jbethune commented Dec 12, 2024

I would like to fix this if you don't mind. IIRC I also implemented the original JWT support in dearmep.

Relevant docs: https://fastapi.tiangolo.com/tutorial/security/oauth2-jwt/

@scy
Copy link
Collaborator Author

scy commented Dec 12, 2024

Thanks for the offer. I'm still not super confident that it's a good time right now, because of the changes that might still be coming while I'm working on #269 and #286, but the JWT implementation is fairly isolated (basically just dearmep/api/authtoken.py), so I don't think that the chances for conflicts are super high.

Feel free to try! I assume you're planning on migrating to PyJWT instead of trying to pin the protocols with jose?

Also, I've noticed that there is no test coverage for that file. I'd appreciate some tests a lot.

@jbethune jbethune self-assigned this Dec 13, 2024
@scy scy added the prio:A Blocker, needs to be addressed label Dec 15, 2024
@jbethune
Copy link
Collaborator

I assume you're planning on migrating to PyJWT instead of trying to pin the protocols with jose?

Yes. I finished the migration and I will push once I have added some tests. I need to figure out how we do tests in this project...

@scy
Copy link
Collaborator Author

scy commented Dec 15, 2024

Basically it's just standard pytest, but there are some wild things going on with some of the fixtures, in order to be able to modify the config on the fly or something, I don't even really remember. At some point we basically stopped writing tests altogether due to lack of time 😔 but we should start doing them again.

I guess you'd probably best start a new file like tests/test_tokens.py or something. I leave it up to you whether you're only testing the JWT functions themselves or do actual requests against the API. The latter is probably going to be significantly more complicated because you'd need to mock the SMS sending and stuff.

Maybe I don't leave it up to you then 😅 I'd recommend you do unit tests on just the token functions and not against the API. If you're eager to add some against the API, let's do a separate PR for those, to not endanger the upcoming release.

@jbethune
Copy link
Collaborator

jbethune commented Dec 15, 2024

I'll only test the tokens then. Edit: Using the fixtures wasn't that hard after all.

jbethune pushed a commit that referenced this issue Dec 15, 2024
Because of security issues.
Package description: https://pypi.org/project/PyJWT/

fix #285

Signed-off-by: Jörn Bethune <jö[email protected]>
jbethune pushed a commit that referenced this issue Dec 15, 2024
Because of security issues.
Package description: https://pypi.org/project/PyJWT/

fix #285

Signed-off-by: Jörn Bethune <jö[email protected]>
jbethune pushed a commit that referenced this issue Dec 15, 2024
Because of security issues.
Package description: https://pypi.org/project/PyJWT/

fix #285

Signed-off-by: Jörn Bethune <jö[email protected]>
@scy scy closed this as completed in #292 Dec 19, 2024
@scy scy closed this as completed in 47dc5c1 Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:backend Related to the server component flag:security Impacts the overall security of the system prio:A Blocker, needs to be addressed type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants