[2.10.x] Avoid running out of memory when parsing heavily nested arrays or objects#1226
Merged
mkurz merged 1 commit intoplayframework:2.10.xfrom Oct 10, 2025
Conversation
a1066a5 to
73d4ba8
Compare
mkurz
commented
Oct 10, 2025
| throw new RuntimeException("We should have been reading an object, something got wrong") | ||
| } | ||
|
|
||
| val defaultMaxDepth = 1000 // Same as Jackson's 2.15+ StreamReadConstraints.DEFAULT_MAX_DEPTH |
Member
Author
There was a problem hiding this comment.
Member
Author
There was a problem hiding this comment.
fyi, in Play itself we cap the depth for json form handling at just 64: https://github.com/playframework/playframework/blob/3.0.9/core/play/src/main/scala/play/api/data/Form.scala#L375-L381
So I guess 1000 should absolutely not be a problem.
mkurz
commented
Oct 10, 2025
|
|
||
| val defaultMaxDepth = 1000 // Same as Jackson's 2.15+ StreamReadConstraints.DEFAULT_MAX_DEPTH | ||
| // system property to override the max nesting depth for JSON parsing. | ||
| val maxNestingDepth: String = "play.json.parser.maxNestingDepth" |
Member
Author
There was a problem hiding this comment.
We introduced the same sys property in the main branch's pr when we upgraded jackson to 2.19: https://github.com/playframework/play-json/pull/1072/files
…ects Just like Jackson 2.15+ we restrict the maximum allowed number of nested arrays or objects (or mixed) to 1000. This default can be changed via a sys property. 1000 should be enough for most real world use cases. Note this is about OutOfMemoryError's, not about StackOverflowError's. StackOverflowError's are not a problem since we use a @tailrec optimized method. Therefore this fix is not 100% about CVE-2025-52999 (which in theory we do not run into) but just an additional precaution.
73d4ba8 to
90ad9c3
Compare
Member
Author
|
@Mergifyio backport main 3.0.x |
Contributor
✅ Backports have been createdDetails
|
mergify bot
pushed a commit
that referenced
this pull request
Oct 10, 2025
…ects (#1226) Just like Jackson 2.15+ we restrict the maximum allowed number of nested arrays or objects (or mixed) to 1000. This default can be changed via a sys property. 1000 should be enough for most real world use cases. Note this is about OutOfMemoryError's, not about StackOverflowError's. StackOverflowError's are not a problem since we use a @tailrec optimized method. Therefore this fix is not 100% about CVE-2025-52999 (which in theory we do not run into) but just an additional precaution. (cherry picked from commit 9722c66)
mergify bot
pushed a commit
that referenced
this pull request
Oct 10, 2025
…ects (#1226) Just like Jackson 2.15+ we restrict the maximum allowed number of nested arrays or objects (or mixed) to 1000. This default can be changed via a sys property. 1000 should be enough for most real world use cases. Note this is about OutOfMemoryError's, not about StackOverflowError's. StackOverflowError's are not a problem since we use a @tailrec optimized method. Therefore this fix is not 100% about CVE-2025-52999 (which in theory we do not run into) but just an additional precaution. (cherry picked from commit 9722c66)
mkurz
added a commit
that referenced
this pull request
Oct 10, 2025
…ects (#1226) (#1228) Just like Jackson 2.15+ we restrict the maximum allowed number of nested arrays or objects (or mixed) to 1000. This default can be changed via a sys property. 1000 should be enough for most real world use cases. Note this is about OutOfMemoryError's, not about StackOverflowError's. StackOverflowError's are not a problem since we use a @tailrec optimized method. Therefore this fix is not 100% about CVE-2025-52999 (which in theory we do not run into) but just an additional precaution. (cherry picked from commit 9722c66) Co-authored-by: Matthias Kurz <m.kurz@irregular.at>
mkurz
added a commit
that referenced
this pull request
Oct 10, 2025
…ects (#1226) Just like Jackson 2.15+ we restrict the maximum allowed number of nested arrays or objects (or mixed) to 1000. This default can be changed via a sys property. 1000 should be enough for most real world use cases. Note this is about OutOfMemoryError's, not about StackOverflowError's. StackOverflowError's are not a problem since we use a @tailrec optimized method. Therefore this fix is not 100% about CVE-2025-52999 (which in theory we do not run into) but just an additional precaution. (cherry picked from commit 9722c66)
mkurz
added a commit
that referenced
this pull request
Oct 10, 2025
…ects (#1226) (#1227) Just like Jackson 2.15+ we restrict the maximum allowed number of nested arrays or objects (or mixed) to 1000. This default can be changed via a sys property. 1000 should be enough for most real world use cases. Note this is about OutOfMemoryError's, not about StackOverflowError's. StackOverflowError's are not a problem since we use a @tailrec optimized method. Therefore this fix is not 100% about CVE-2025-52999 (which in theory we do not run into) but just an additional precaution. (cherry picked from commit 9722c66) Co-authored-by: Matthias Kurz <m.kurz@irregular.at>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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. )