saves: reject JSON nested deeper than 512 levels explicitly #8
No reviewers
Labels
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!8
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/8/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@wavehs on GitHub · 2026-11-24 01:30 UTC · original
wavehs:saves-json-nesting-limit→main· +41 −1 · 2 files · 1 commits · merged 2026-11-24 01:40 UTCClaimed in the coordination issue as: none — the original project's coordination issue was lost with its repository, and this repository has no such issue yet. No open pull request touches
tools/saves.py.Depends on: none.
What and why
Python 3.14's
jsondecoder is iterative, so a deeply nested document no longer raisesRecursionError.parse_jsavaccepted a body nesting 100,000 levels,infoprintedJSAV (200112 bytes),verifysaidOK, andextractdied with a 1,027-line traceback and exit 1 (json.dumpis still recursive).tests/test_saves.pyalready expects a validation error here and its comment notes that the C decoder's limit differs by platform, so the tool should not depend on the interpreter's.The tool now counts nesting itself (
JSON_NESTING_LIMIT = 512, brackets inside strings ignored) inparse_jsav, inverify's per-block check and when it reads a packed index. 512 is far above real saves (a few levels) and below the depth at which Python's recursive encoder fails around the default recursion limit.docs/saves.mdrecords the rule.Tested
main@30daa6958, macOS 15 arm64 (Apple M3 Pro), CPython 3.15.2, CPU only, no game files. Synthetic JSAV with one block{"nested":+ 100,000[+0+ 100,000]+}:main@30daa6958saves.py infoERROR: JSAV body is not valid UTF-8 JSON: nesting exceeds 512 levelssaves.py verifyOKsaves.py extractpython -I tests/test_saves.py→ 70 tests OK (skipped=1) with the fix,FAILED (failures=7)before it on this Python. Alltests/test_docs_*.pypass,compileallclean,check_no_game_data.pyclean.On Python 3.12 (CI) the depth guard is additional and the suite is green there before and after. Not run: Windows, any GPU test, the translator suite.
AI-assisted: yes.
Checklist
docs/design.md, with how it was confirmed. (Not applicable: no translator change.)