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

Partial issuer matches instead of InvalidTokenError in 2.10.0 #1020

Closed
awoimbee opened this issue Nov 22, 2024 · 2 comments
Closed

Partial issuer matches instead of InvalidTokenError in 2.10.0 #1020

awoimbee opened this issue Nov 22, 2024 · 2 comments

Comments

@awoimbee
Copy link

awoimbee commented Nov 22, 2024

Impacts 2.10.0, previous release (2.9.0) is not impacted.
Seems like if issuer is given as a string then any partial match is allowed.

Expected Result

InvalidTokenError due to bad iss.

Actual Result

Token is accepted and decoded 😬

Reproduction Steps

This is incomplete:

def decode_token(
    encoded_token: str
) -> dict[str, Any]:
    signing_key = _fetch_jwt_signing_key(encoded_token)
    decode_options = {
        "verify_signature": True,
        "require": ["exp", "iss", "sub", "iat", "aud"],
    }
    return jwt.decode(
        encoded_token,
        key=signing_key.key,
        algorithms=["RS256", "ES256"],
        options=decode_options,
        issuer="https://test.example.com/auth",
    )

decode_token({
    ...,
    "iss": "http"
})

Note: this is fixed by replacing issuer="https://test.example.com/auth" by issuer=["https://test.example.com/auth"] (relates to #913).

System Information

$ python -m jwt.help
{
  "cryptography": {
    "version": "43.0.3"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.12.7"
  },
  "platform": {
    "release": "6.11.8-1-default",
    "system": "Linux"
  },
  "pyjwt": {
    "version": "2.10.0"
  }
}

This command is only available on PyJWT v1.6.3 and greater. Otherwise,
please provide some basic information about your system.

@awoimbee awoimbee changed the title Partial issuer matches instead of InvalidTokenError Partial issuer matches instead of InvalidTokenError in 2.10.0 Nov 22, 2024
@awoimbee
Copy link
Author

Caused by #970 that replaced list by Sequence in isinstance.

>>> from collections.abc import Sequence
>>> isinstance("bugged", list)
False
>>> isinstance("bugged", Sequence)
True

@awoimbee
Copy link
Author

awoimbee commented Dec 2, 2024

Fixed in 33022c2
GHSA-75c5-xw7c-p5pm

@awoimbee awoimbee closed this as completed Dec 2, 2024
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

No branches or pull requests

1 participant