Oct 1, 2026·6 min read·48 visits
A state pollution flaw in PyJWT's options merger mutates reused configuration dictionaries. When signature verification is toggled from False to True, critical claim verifications like expiration and audience checks remain permanently disabled, allowing expired or invalid tokens to be accepted.
PyJWT versions 2.11.0 through 2.13.0 suffer from a state pollution vulnerability in the `_merge_options` method. When an application passes a mutable configuration mapping with signature verification disabled, the library modifies the object in-place. If this same dictionary is reused for subsequent verified decode operations, standard claim verifications (such as expiration, audience, and issuer validation) are silently bypassed.
PyJWT is a Python implementation of JSON Web Token (JWT) standards widely used in web applications and backend microservices. Between versions 2.11.0 and 2.13.0, PyJWT is susceptible to a state pollution vulnerability within its internal option merging mechanism.
The vulnerability is triggered when a caller-supplied, mutable mapping (such as a standard Python dictionary) is passed to decode() or decode_complete() with signature verification set to disabled. Under these conditions, PyJWT's _merge_options() method directly modifies the caller's options mapping in-place, adding or modifying registered claim verification options to false.
This in-place modification permanently alters the configuration state of the reused mapping. If the calling application subsequently re-enables signature verification on that same object, the claim validation steps (such as expiration, audience, and issuer checks) remain disabled. This behavior allows attackers to present cryptographically valid but expired tokens, which the library accepts without throwing validation errors.
In Python, dictionary structures are passed by reference. When an application provides an options configuration dictionary to PyJWT.decode(), the library merges default options with user-provided settings inside jwt/api_jwt.py.
The logic in the vulnerable version of _merge_options() evaluates whether signature verification is disabled. If verify_signature is false, PyJWT defensively sets default verification flags to false directly within the input object itself rather than a localized copy. This operation mutates the caller's shared state directly.
When the application processes a second token and changes verify_signature back to true, the previously injected false parameters remain in the dictionary. Because PyJWT checks the specific dictionary keys for explicit verification overrides, the presence of these mutated keys bypasses checks for expiration (verify_exp), not-before (verify_nbf), issued-at (verify_iat), audience (verify_aud), issuer (verify_iss), subject (verify_sub), and JWT ID (verify_jti).
The vulnerability lies in jwt/api_jwt.py inside the _merge_options function. Prior to the patch, the mapping passed to the function was not isolated from the original reference.
Below is the vulnerable implementation:
def _merge_options(self, options: Options | None = None) -> FullOptions:
if options is None:
return self.options
# (defensive) set defaults for verify_x to False if verify_signature is False
if not options.get("verify_signature", True):
options["verify_exp"] = options.get("verify_exp", False)
options["verify_nbf"] = options.get("verify_nbf", False)
options["verify_iat"] = options.get("verify_iat", False)
options["verify_aud"] = options.get("verify_aud", False)
options["verify_iss"] = options.get("verify_iss", False)
options["verify_sub"] = options.get("verify_sub", False)
options["verify_jti"] = options.get("verify_jti", False)
return {**self.options, **options}The patch addresses this state pollution by converting the incoming mapping to a standard, shallow-copied dictionary utilizing dict(options) and casting it as an Options object. This ensures that any key assignment affects only the isolated copy of the options mapping.
Below is the patched implementation:
def _merge_options(self, options: Options | None = None) -> FullOptions:
if options is None:
return self.options
# Convert and isolate the incoming options mapping to prevent pollution
merged_options = cast("Options", dict(options))
# (defensive) set defaults for verify_x to False if verify_signature is False
if not merged_options.get("verify_signature", True):
merged_options["verify_exp"] = merged_options.get("verify_exp", False)
merged_options["verify_nbf"] = merged_options.get("verify_nbf", False)
merged_options["verify_iat"] = merged_options.get("verify_iat", False)
merged_options["verify_aud"] = merged_options.get("verify_aud", False)
merged_options["verify_iss"] = merged_options.get("verify_iss", False)
merged_options["verify_sub"] = merged_options.get("verify_sub", False)
merged_options["verify_jti"] = merged_options.get("verify_jti", False)
return {**self.options, **merged_options}Exploitation of this vulnerability requires that the target application reuse an options configuration dictionary across multiple decode requests. An attacker targeting the application must provide an expired or claim-mismatched token that has been cryptographically signed by the correct backend secret.
The following Python script reproduces the state pollution and demonstrates the subsequent verification bypass:
import jwt
import time
SECRET_KEY = "super_secure_secret_key"
ALGORITHM = "HS256"
# Generate a token that expired in the past
expired_payload = {
"user_id": 1337,
"exp": int(time.time()) - 3600
}
expired_token = jwt.encode(payload=expired_payload, key=SECRET_KEY, algorithm=ALGORITHM)
# Create a reusable options mapping
shared_options = {
"verify_signature": False
}
# Trigger state pollution via unverified decoding
jwt.decode(jwt=expired_token, options=shared_options)
# Attempt to enforce signature verification while reusing the polluted mapping
shared_options["verify_signature"] = True
try:
# This call should raise ExpiredSignatureError, but it returns the decoded payload
decoded = jwt.decode(
jwt=expired_token,
key=SECRET_KEY,
algorithms=[ALGORITHM],
options=shared_options
)
print("Vulnerable: Token accepted despite expiration check being active")
print(decoded)
except jwt.ExpiredSignatureError:
print("Secure: Expired signature exception raised")If the application utilizes the vulnerable version of PyJWT and reuses shared_options, the script will bypass the expiration check. If the PyJWT installation has been upgraded or patched, an ExpiredSignatureError is raised.
The impact of this state pollution vulnerability is classified as Medium (CVSS 6.5). The complexity of the attack is High, as exploitation relies entirely on how the consuming application implements PyJWT and manages configuration lifecycles. If an application never reuses options mappings, the vulnerability cannot be triggered.
For systems that do reuse options configuration mappings, the vulnerability bypasses critical logical controls. Attackers can replay expired authentication tokens or present tokens intended for different audiences, which can result in privilege escalation or session hijacking.
The vulnerability is a regression of similar mutable dictionary issues identified in previous developer discussions (such as Issue 679). No active exploitation in the wild has been reported, and the vulnerability has not been added to CISA's Known Exploited Vulnerabilities catalog.
To fully remediate CVE-2026-103001, update PyJWT to version 2.14.0 or higher. The fixed version ensures that all input mapping parameters are localized through copy operations prior to modifications.
In scenarios where immediate upgrading is not feasible, developers should adjust their implementation code to prevent dictionary reuse. Instead of modifying or referencing a shared dictionary, code should instantiate a fresh dictionary for each decode call:
# Insecure reuse pattern
jwt.decode(token, key, options=settings.JWT_CONFIG)
# Secure non-reused instantiation
jwt.decode(token, key, options=dict(settings.JWT_CONFIG))Security teams can identify vulnerable patterns by scanning codebases with static analysis rules that alert on modified dictionary parameters passed directly to jwt.decode interfaces.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
PyJWT PyJWT Project | >= 2.11.0, <= 2.13.0 | 2.14.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-471: Modification of Assumed-Immutable Data (MAID) |
| Attack Vector | Network (Unauthenticated, high complexity due to application logic dependence) |
| CVSS v3.1 | 6.5 (Medium) |
| EPSS Score | N/A |
| Impact | Claim verification bypass (Expiration, Audience, Issuer checks bypassed) |
| Exploit Status | Proof-of-Concept (PoC) available |
| CISA KEV Status | Not Listed |
The product allows input to modify data that is assumed to be immutable, causing a state mutation which can be leveraged to bypass logical checks in subsequent program operations.
GHSA-fmc8-p6q7-75cc (associated with CVE-2026-48755) is a critical argument injection vulnerability in Canonical LXD (github.com/canonical/lxd). The vulnerability occurs during instance and storage volume backup operations when processing the user-supplied compression_algorithm configuration parameter. While LXD validates the primary executable token against an allowlist of supported compression binaries, it fails to sanitize or restrict subsequent tokens parsed via shellquote.Split. These additional arguments are passed directly to exec.Command. An authenticated attacker with privileges to trigger backups can inject command-line flags for utilities like zstd to read staged files from a container filesystem and write them to arbitrary paths on the underlying host filesystem, such as /etc/cron.d/, achieving root-level arbitrary code execution on the host.
A critical path traversal vulnerability caused by improper input validation (CWE-20) exists in the direct image download handler of Canonical LXD and Linux Containers Incus. When an authenticated user requests an image import using the URL source type, the daemon reads the image fingerprint from an untrusted HTTP response header (`Incus-Image-Hash` or `LXD-Image-Hash`) without validating that it conforms to a SHA-256 format. This unvalidated string is concatenated directly into a filesystem path via `filepath.Join` prior to file creation and cryptographic verification, allowing directory traversal sequences to write arbitrary files on the host filesystem as root.
CVE-2026-9639 (GHSA-j93m-3j9p-m5m8) is a null pointer dereference vulnerability in Canonical LXD affecting versions 5.0.0 through 5.21.4 and 6.0 through 6.8. The flaw resides in the (*lxdBackend).CreateCustomVolumeFromBackup method within lxd/storage/backend_lxd.go. An authenticated attacker with the can_create_storage_volumes permission can upload a crafted custom volume backup tarball that omits the expires_at field on a snapshot entry, triggering an unhandled SIGSEGV panic and terminating the LXD daemon.
An operating system command injection vulnerability (CWE-78) exists in GeoNode versions prior to 5.1.0. The vulnerability occurs in the vector upload processing pipeline when handling user-supplied geospatial files. By supplying a crafted layer name containing shell metacharacters, an authenticated attacker with basic data upload privileges can execute arbitrary commands on the underlying server or container hosting the GeoNode application and Celery worker processes.
GeoNode versions prior to 5.0.3 contain an unrestricted file upload vulnerability (CWE-434) within the document and dataset ingestion architecture. Authenticated low-privileged users can bypass upload validation via direct REST API interactions, file extension masquerading, metadata mutation via PATCH requests, or malicious archive submissions. This allows attackers to store and serve dangerous file types, alter on-disk file references, or trigger path traversal and resource exhaustion during archive extraction.
CVE-2026-55649 is a stored Cross-Site Scripting (XSS) vulnerability in GeoNode versions prior to 5.0.3. The flaw exists because document abstract metadata fields are ingested via the metadata management pipeline and stored in the backend database without HTML sanitization or input neutralization. An authenticated attacker with privileges to create or edit document metadata can inject arbitrary HTML and JavaScript payloads into these fields. When another user, such as an administrator, views the affected document page or catalog listing, the unencoded payload is rendered into the Document Object Model (DOM) and executes within the victim's browser session.