[3.0.x] Avoid running out of memory when parsing heavily nested arrays or objects (backport #1226) by @mkurz #1228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just like Jackson 2.15+ we restrict the maximum allowed number of nested arrays or objects (or mixed) to 1000.
Currently this limit is hardcoded, unlike Jackson, which allows to configure it.(we have sys property now, just like in the main branch as of #1072) 1000 should be enough for most real world use cases. We can still make it configurable later.Note this is about
OutOfMemoryError's, not aboutStackOverflowError's.StackOverflowError's are not a problem since we use a@tailrecoptimized method. Therefore this fix is not 100% about CVE-2025-52999 (which in theory we do not run into) but just an additional precaution.See
(however, again, technically we are not affected by that CVE, since it's about running out of stack. However in theory a bad actor could make an app run out of memory so it's more or less the same - if that bad actor bypasses any other security measurements, like max content size, any body parser max buffers, etc. )
This is an automatic backport of pull request [2.10.x] Avoid running out of memory when parsing heavily nested arrays or objects #1226 done by Mergify.