Skip to content

Algorithm validation is optional - potential signature verification bypass #424

Open

Description

@LHMisme420

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions