Repository navigation
Description
EDIT: related to to CVE-2020-36518 (see https://nvd.nist.gov/vuln/detail/CVE-2020-36518)
EDIT: Fix included in
- 2.14.0
- 2.13.3:
- Was also included in 2.13.2.1 and 2.13.2.2 (see https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.13); to be used with
jackson-bomversion2.13.2.20220328
- Was also included in 2.13.2.1 and 2.13.2.2 (see https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.13); to be used with
- 2.12.6.1: (see https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.12)
- use with
jackson-bomversion2.12.6.1.20220326
- use with
EDIT: included as one of Snyk's "top-10 vulns of 2022" CVEs -- see https://go.snyk.io/snyk-top-10-open-source-vulnerabilities-dwn-typ.html
Current implementation UntypedObjectDeserializer is relatively expensive for deeply nested Object and Array values as it uses recursion even for "vanilla" case (one where there are no custom List/array or Map deserializers).
In practical terms it is possible to exhaust typical modest JVM memory with documents having about ten thousand levels of nestings, due to size of call stack from recursive calls.
NOTE: specifically this ONLY APPLIES if the target type is "untyped" or generic Collection<Object> / Map<String, Object> -- it DOES NOT APPLY to cases where target is POJO (except if POJO itself has "untyped" property or properties).
Similar issue was already solved wrt JsonNode (see #3397), included in 2.13.0; this might show a way to approach this problem: by replacing simple recursion with iteration, either completely or at some inner levels.
Also note that it may ultimately be necessary to have lower-level constraints for streaming parser too, see: FasterXML/jackson-core#637
Ideally it should be:
- Possible to handle at least tens of thousands of levels of nesting (100k should be processable with 256M heap, say)
- Have streaming level limits that -- by default -- block documents with more than limit we deem safe (less than 100k -- perhaps 10k or something, to be determined).
This issue is specifically about (1) as (2) is about jackson-core.
Activity
Add failing test for #2816
cowtowncoder commentedon Aug 13, 2020
Looks like nesting of about 2000 works, 3000 fails, with default settings for both Arrays and Objects.
Bit more testing wrt #2816
cowtowncoder commentedon Aug 23, 2020
Tagging as "performance" (since resource consumption of call stack causes the exception). Also added similar test for
JsonNode. Hoping to eventually tackle for these types but realistically support from streaming parser (jackson-core) is probably needed (will file separate ticket) for more general complexity limits for input documents.cowtowncoder commentedon Feb 10, 2022
FWTW, similar issues does NOT affect
JsonNode, as of Jackson 2.13.0 and later on.Should have created separate issue to point to, but iterate version of
JsonNodeDeserializerwas merged in at around March 2021.Would be great to achieve the same here for 2.14.
Could start with
UntypedObjectDeserializer.Vanillafirst, see if generalizable to full case (should be).meier-th commentedon Mar 12, 2022
@cowtowncoder , could you please clarify if the same fix is planned to be backported to the versions
2.12.xand2.11.xof Jackson?cowtowncoder commentedon Mar 13, 2022
EDIT: fix actually backported, see initial Description (now Edited as well) for details.
@meier-th Very unlikely that I would try to backport this to anything prior to 2.14.0. The new implementation probably has non-trivial chance of regression and this functionality is widely used. Note that no implementation yet exists, but I fully intend to work on this to try to get it done for 2.14.0 (or someone else could beat me to it).
95 remaining items
update jackson deps per most recent recommendation
yhs0092 commentedon Apr 11, 2022
Hi, is this a typo mistake? I find the bom version of 2.12 mentioned above is
2.12.6.1.20220326, but in the release notes it's2.12.6.20220326.MaximilianTews commentedon Apr 13, 2022
Hi @cowtowncoder, any way to determine if one is affected or not?
You write that UntypedObjectDeserializer needs to be used in combination with Collection / Map<String, Object> - at least this is what I understand.
I scanned my code and we are not using UntypedObjectDeserializer, however, it might be used by other jackson-databind code that we use. Could you please clarify how to determine if one is affected by this CVE?
jtnord commentedon Apr 14, 2022
@cowtowncoder
the version for the bom here looks incorrect, should be
2.12.6.20220326?https://github.com/FasterXML/jackson-bom/tree/jackson-bom-2.12.6.20220326
stable version of 2.12
Fix #3473 (re-implementation of #2816 for 2.14)
MaximilianTews commentedon Jun 2, 2022
Hi @cowtowncoder, could you please clarify what methods are affected by this vulnerability? I am specifically interested if ObjectMapper.readTree and ObjectMapper.readValue are affected?
yawkat commentedon Jun 2, 2022
readTree is not affected, readValue is affected if you use untyped fields somewhere in the object graph youre deserializing
cowtowncoder commentedon Jun 2, 2022
@MaximilianTews see #2816 for more information. This is just a rewrite of that fix.
And @yawkat is correct:
readTree()is not affected.readValue()MAY be affected BUT ONLY if the nominal type is or includes target type ofjava.lang.Object. Term "untyped" in Jackson context meansjava.lang.Objectas binding target type (either explicitly, or via raw types,?type parameter and so on).chore(dependencies): fix CVE-2020-36518 by upgrading com.fasterxml.jaβ¦
chore(dependencies): fix CVE-2020-36518 by upgrading com.fasterxml.jaβ¦
Throw JsonMappingException for deeply nested JSON (FasterXML#2816, CVβ¦
update jackson databind to address RCE