Description
In PyJWT 1.5.0 and below the `invalid_strings` check in `HMACAlgorithm.prepare_key` does not account for all PEM encoded public keys. Specifically, the PKCS1 PEM encoded format would be allowed because it is prefaced with the string `-----BEGIN RSA PUBLIC KEY-----` which is not accounted for. This enables symmetric/asymmetric key confusion attacks against users using the PKCS1 PEM encoded public keys, which would allow an attacker to craft JWTs from scratch.
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 14 | pyjwt | 1.4.2-1.1 | — |
| Debian 13 | pyjwt | 1.4.2-1.1 | — |
| Debian 12 | pyjwt | 1.4.2-1.1 | — |
| Debian 9 | pyjwt | 1.4.2-1+deb9u1 | DSA-3979-1 |
| Debian 8 | pyjwt | 0.2.1-1+deb8u2 | DSA-3979-1 |
Ubuntu
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu 16.04 LTS | pyjwt | 1.3.0-1ubuntu0.1 | USN-3407-1 |
Affected packages
| Ecosystem | Package | Affected | Fixed | Record |
|---|---|---|---|---|
| PyPI | pyjwt | < 1.5.1 | 1.5.1 | GHSA-r9jw-mwhq-wp62 |
Advisories 2
- DSA-3979-1 pyjwt - security update Debian Security (DSA / DLA) · Mar 9, 2026
- USN-3407-1 pyjwt vulnerability Ubuntu Security Notices (USN) · Feb 10, 2026
References
- DSA-3979 vendor-advisory
- https://github.com/jpadilla/pyjwt/pull/277