Skip to content

security: replace python-jose with PyJWT for JWT handling#250

Closed
PeakPy wants to merge 1 commit intobenavlabs:mainfrom
PeakPy:feature/replace-python-jose-with-pyjwt
Closed

security: replace python-jose with PyJWT for JWT handling#250
PeakPy wants to merge 1 commit intobenavlabs:mainfrom
PeakPy:feature/replace-python-jose-with-pyjwt

Conversation

@PeakPy
Copy link

@PeakPy PeakPy commented Feb 11, 2026

Description

Replaces python-jose with PyJWT to address known security vulnerabilities (CVE-related to alg=none bypass and denial-of-service).

Partially addresses #248 (JWT security concern)

Changes

  • Removed python-jose>=3.3.0 dependency
  • Added PyJWT>=2.8.0 dependency
  • Updated JWT encoding/decoding in security.py to use PyJWT API
  • Updated exception handling in logout.py to catch jwt.PyJWTError
  • Converted exp claim to Unix timestamp for PyJWT compliance
  • Updated uv.lock with new dependency tree

Tests

All existing tests pass (11/11):

  • Authentication flow
  • Token creation and verification
  • User CRUD operations

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project (ruff, mypy pass)
  • I have added necessary documentation (if appropriate)
  • I have added tests that cover my changes (existing tests validate behavior)
  • All new and existing tests passed

Additional Notes

@LucasQR
Copy link
Collaborator

LucasQR commented Feb 17, 2026

Thanks for the PR! However, we tested this and the vulnerability doesn't actually apply to this project.

We're on python-jose 3.5.0, which already rejects alg=none tokens when algorithms=["HS256"] is explicitly specified which is what we do on every jwt.decode
call in security.py. You can verify this by running the test script in test_jose_vulnerability.py on the repo.

The CVE was valid for older versions of the library, but 3.5.0 already addresses it. Since there's no actual security issue here and the migration introduces
churn (different API, timestamp handling changes, new exception types) without a concrete benefit, I'm going to close this.

Appreciate you looking into it though!

@LucasQR LucasQR closed this Feb 17, 2026
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

Comments