VYPR
High severityNVD Advisory· Published Oct 10, 2025· Updated Nov 3, 2025

Authlib is vulnerable to Denial of Service via Oversized JOSE Segments

CVE-2025-61920

Description

Authlib is a Python library which builds OAuth and OpenID Connect servers. Prior to version 1.6.5, Authlib’s JOSE implementation accepts unbounded JWS/JWT header and signature segments. A remote attacker can craft a token whose base64url‑encoded header or signature spans hundreds of megabytes. During verification, Authlib decodes and parses the full input before it is rejected, driving CPU and memory consumption to hostile levels and enabling denial of service. Version 1.6.5 patches the issue. Some temporary workarounds are available. Enforce input size limits before handing tokens to Authlib and/or use application-level throttling to reduce amplification risk.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
authlibPyPI
< 1.6.51.6.5

Affected products

1

Patches

1
867e3f87b072

fix(jose): add size limitation to prevent DoS

https://github.com/authlib/authlibHsiaoming YangOct 2, 2025via ghsa
3 files changed · +28 0
  • authlib/jose/rfc7515/jws.py+5 0 modified
    @@ -34,6 +34,8 @@ class JsonWebSignature:
             ]
         )
     
    +    MAX_CONTENT_LENGTH: int = 256000
    +
         #: Defined available JWS algorithms in the registry
         ALGORITHMS_REGISTRY = {}
     
    @@ -89,6 +91,9 @@ def deserialize_compact(self, s, key, decode=None):
     
             .. _`Section 7.1`: https://tools.ietf.org/html/rfc7515#section-7.1
             """
    +        if len(s) > self.MAX_CONTENT_LENGTH:
    +            raise ValueError("Serialization is too long.")
    +
             try:
                 s = to_bytes(s)
                 signing_input, signature_segment = s.rsplit(b".", 1)
    
  • authlib/jose/util.py+6 0 modified
    @@ -7,6 +7,9 @@
     
     
     def extract_header(header_segment, error_cls):
    +    if len(header_segment) > 256000:
    +        raise ValueError("Value of header is too long")
    +
         header_data = extract_segment(header_segment, error_cls, "header")
     
         try:
    @@ -20,6 +23,9 @@ def extract_header(header_segment, error_cls):
     
     
     def extract_segment(segment, error_cls, name="payload"):
    +    if len(segment) > 256000:
    +        raise ValueError(f"Value of {name} is too long")
    +
         try:
             return urlsafe_b64decode(segment)
         except (TypeError, binascii.Error) as exc:
    
  • tests/jose/test_jws.py+17 0 modified
    @@ -297,3 +297,20 @@ def test_ES256K_alg():
         header, payload = data["header"], data["payload"]
         assert payload == b"hello"
         assert header["alg"] == "ES256K"
    +
    +
    +def test_deserialize_exceeds_length():
    +    jws = JsonWebSignature()
    +    value = "aa" * 256000
    +
    +    # header exceeds length
    +    with pytest.raises(ValueError):
    +        jws.deserialize(value + "." + value + "." + value, "")
    +
    +    # payload exceeds length
    +    with pytest.raises(ValueError):
    +        jws.deserialize("eyJhbGciOiJIUzI1NiJ9." + value + "." + value, "")
    +
    +    # signature exceeds length
    +    with pytest.raises(ValueError):
    +        jws.deserialize("eyJhbGciOiJIUzI1NiJ9.YQ." + value, "")
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.