Authlib is vulnerable to Denial of Service via Oversized JOSE Segments
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.
| Package | Affected versions | Patched versions |
|---|---|---|
authlibPyPI | < 1.6.5 | 1.6.5 |
Affected products
1Patches
1867e3f87b072fix(jose): add size limitation to prevent DoS
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- github.com/advisories/GHSA-pq5p-34cr-23v9ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2025-61920ghsaADVISORY
- github.com/authlib/authlib/commit/867e3f87b072347a1ae9cf6983cc8bbf88447e5eghsax_refsource_MISCWEB
- github.com/authlib/authlib/security/advisories/GHSA-pq5p-34cr-23v9ghsax_refsource_CONFIRMWEB
- lists.debian.org/debian-lts-announce/2025/10/msg00032.htmlghsaWEB
News mentions
0No linked articles in our index yet.