python-jose icon indicating copy to clipboard operation
python-jose copied to clipboard

Algorithm validation is optional - potential signature verification bypass

Open LHMisme420 opened this issue 1 month ago • 0 comments

Summary

The algorithm validation in _verify_signature() at jose/jws.py line 258 is conditional and can be bypassed.

Details

The current code only validates the algorithm when algorithms is not None:

if algorithms is not None and alg not in algorithms:
    raise JWSError("The specified alg value is not allowed")

When algorithms is None (or not provided), the function accepts any algorithm from the JWT header without validation.

Impact

This could allow signature verification to succeed with unexpected or weaker algorithms than intended, potentially leading to security issues depending on how the library is used.

Suggested Fix

Consider making algorithm validation mandatory or enforcing a secure default list of allowed algorithms.

Environment

  • Library: python-jose
  • Affected code: jose/jws.py, _verify_signature() function

LHMisme420 avatar Oct 12 '26 12:10 LHMisme420