A Widely Used Python Library Has an Auth Flaw

TL;DR: A popular Python library for authentication, PyJWT, has two new vulnerabilities. One could let attackers bypass security checks, while another could crash applications, creating a denial-of-service risk for services that rely on it.
Key facts
- Category
- Cybersecurity
- Impact
- High
- Published
- Source
- Ubuntu Security Notices
Full summary
A widely used Python library for authentication has two new security flaws, one of which could allow attackers to bypass security checks.
Ubuntu Security Notices has reported two significant vulnerabilities in PyJWT, a widely used Python library for creating and verifying JSON Web Tokens (JWTs). These tokens are a cornerstone of modern web authentication, acting as digital passports that allow users to securely access different parts of an application or service. The first vulnerability could allow an attacker to crash an application, causing a denial of service. The second, more severe flaw, could potentially allow an attacker to bypass authentication checks entirely. Given PyJWT’s popularity within the Python ecosystem, these vulnerabilities have a broad potential impact, affecting countless web services, APIs, and backend systems that rely on it for secure user session management. The discovery underscores the critical importance of maintaining the security of foundational software libraries that power a large portion of the internet's infrastructure.
The two vulnerabilities operate in distinct ways. The denial-of-service issue, identified as CVE-2026-102265, stems from how PyJWT handles errors when parsing token headers. An attacker can craft a JWT with a deeply nested header structure. When the library attempts to process this malformed token, it fails to manage the resulting errors correctly, leading to an unhandled exception that can crash the entire application server. The second vulnerability is more subtle and concerns the library's internal state management. It was found that PyJWT would modify the configuration object, or `options` mapping, that a developer provides when verifying a token. Specifically, if a developer disabled signature verification for one operation and then reused that same configuration object for a subsequent, security-critical operation, the "disable verification" setting would persist. This could allow an attacker to present a token with an invalid signature that the application would mistakenly accept as legitimate, effectively bypassing a core security mechanism.
This incident fits into a broader pattern of security challenges surrounding JWTs and the libraries that implement them. While the JWT standard itself is robust, its flexibility can lead to complex and sometimes insecure implementations. A famous historical example is the `alg: none` vulnerability, where attackers could specify that no signature algorithm was used, tricking some libraries into accepting any token as valid. The PyJWT flaw involving the mutable `options` object is a modern variant of this theme, where a seemingly innocuous programming practice—reusing a configuration object—leads to a critical security failure. It serves as a powerful reminder that security is not just about strong cryptography but also about predictable and safe API design. When a library modifies a user-supplied object unexpectedly, it violates the principle of least astonishment and creates hidden pitfalls for developers who are focused on building application features, not auditing the internal behavior of their dependencies.
For developers, CTOs, and security teams, the immediate takeaway is the need for vigilance and prompt action. The primary recommendation is to update the PyJWT library to a patched version across all projects where it is used. This event also highlights the importance of robust dependency management practices. Using automated tools to scan for and report vulnerable dependencies, such as GitHub's Dependabot or third-party services, is no longer optional for professional software development. Furthermore, this specific vulnerability provides a valuable lesson in defensive programming: developers should treat configuration objects passed to third-party libraries as potentially mutable and avoid reusing them across different contexts, especially when security settings are involved. Looking ahead, the discovery of this type of state-management bug in a popular library will likely inspire security researchers to audit other JWT implementations in different languages for similar patterns, potentially uncovering related vulnerabilities elsewhere in the web ecosystem.
Why it matters
PyJWT is a foundational library for handling authentication in countless Python applications. A flaw that allows authentication bypass is critical, as it could let attackers gain unauthorized access to systems and user data. The denial-of-service vulnerability also poses a significant risk to application availability and reliability.
Business impact
This vulnerability exposes companies using PyJWT to significant security risks, including data breaches from unauthorized access and service downtime from denial-of-service attacks. Failing to patch this could lead to reputational damage, loss of customer trust, and potential regulatory fines depending on the data compromised.
⚡ Action needed
Developers and security teams should immediately update their PyJWT library to a patched version to mitigate these vulnerabilities.
Action checklist
- 1Identify all projects using the PyJWT library.
- 2Check the current version of PyJWT in your dependencies.
- 3Update to the latest patched version of PyJWT.
- 4Review code for any reuse of 'options' objects in token verification logic.
- 5Run tests to ensure the update does not break authentication flows.
Related on Notifire
Related stories
Primary source: Ubuntu Security Notices