Skip to content

Conversation

@masci
Copy link
Contributor

@masci masci commented May 28, 2025

Description

Introduce a max_depth parameter an exception handler to avoid hitting Python's recursion limits. This should avoid DoS attacks carried using a deeply nested JSON object.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 28, 2025
@AstraBert AstraBert self-requested a review May 28, 2025 10:49
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 28, 2025
@masci masci force-pushed the massi/max-recursion branch from c6bffff to 7c6b0a6 Compare May 28, 2025 17:38
self.collapse_length,
[],
self.ensure_ascii,
try:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are too many points in this reader where a recursion error can happen. Since the goal is ultimately being defensive against attacks, I think this is the simplest and most robust solution

@masci masci requested a review from logan-markewich May 28, 2025 17:45
@logan-markewich logan-markewich merged commit c032843 into main May 29, 2025
10 checks passed
@logan-markewich logan-markewich deleted the massi/max-recursion branch May 29, 2025 00:32
@colca colca mentioned this pull request Jun 9, 2025
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants