FasterXML jackson-databind
jackson-databind: quadratic forward-reference completion in Collection and Map deserializers
Forward-reference completion for @JsonIdentityInfo object IDs in FasterXML jackson-databind performs a linear scan of the pending-reference accumulator for every resolved ID. The affected paths are CollectionDeserializer.CollectionReferringAccumulator.resolveForwardReference() and the equivalent implementation in MapDeserializer. When a document first creates N unresolved object-ID references in an identity-enabled collection or map and then defines those same IDs in reverse order, completion performs on the order of N * (N + 1) / 2 identity comparisons, so a shallow document whose size grows linearly causes quadratic CPU work during deserialization. The reporter instrumented equals() calls on the ID class and measured exactly 2,003,000 comparisons at N = 2,000, against zero comparisons in the pending-reference lookup path for an equally sized control in which every reference was already resolved. The input requires no deep nesting and no syntactically unusual JSON. Exploitation requires an application that deserializes attacker-influenced JSON into an identity-enabled collection or map. The fix replaces the repeated linear lookup with a keyed pending-reference structure.
Affected versions and mitigation
From the CVE record, GitHub Security Advisories and the vendor's references.Affected
- >= 2.5.0, <= 2.18.10
- >= 2.19.0, <= 2.21.6
- >= 2.22.0, <= 2.22.2
- >= 3.0.0, <= 3.1.6
- >= 3.2.0, <= 3.2.2
- >= 2.19.0, < 2.21.7
Fixed in 2.21.7
from GitHub Security Advisory GHSA-cxp5-3px4-pw24
- >= 3.0.0, < 3.1.7
Fixed in 3.1.7
from GitHub Security Advisory GHSA-cxp5-3px4-pw24
- >= 3.2.0, < 3.2.3
Fixed in 3.2.3
from GitHub Security Advisory GHSA-cxp5-3px4-pw24
- >= 2.5.0, < 2.18.11
Fixed in 2.18.11
from GitHub Security Advisory GHSA-cxp5-3px4-pw24
- >= 2.22.0, < 2.22.3
Fixed in 2.22.3
from GitHub Security Advisory GHSA-cxp5-3px4-pw24
Mitigation
Upgrade to com.fasterxml.jackson.core:jackson-databind 2.18.11, 2.21.7 or 2.22.3, or to tools.jackson.core:jackson-databind 3.1.7 or 3.2.3. Lines 2.5.x through 2.17.x, 2.19.x, 2.20.x and 3.0.x received no fix on their own branch and are no longer maintained upstream.
Workaround
Bound the size of JSON documents deserialized into @JsonIdentityInfo-enabled collections and maps, and cap the number of elements accepted for such types, so that the quadratic term cannot be driven large. Removing @JsonIdentityInfo from types reachable from attacker-influenced input avoids the code path entirely. Wall-clock timeouts on deserialization limit the impact of a single request.
References
Timeline
Days relative to CVE publicationNo public PoC found yet; not in CISA KEV.
PoC repositories
Found on GitHub.No PoC repositories found yet.