Skip to content

Security: refuse deeply nested config saves and clone before writing - #496

Merged
SandObserver merged 1 commit into
mainfrom
security/config-nesting-limit
Oct 18, 2026
Merged

SandObserver merged 1 commit into
mainfrom
security/config-nesting-limit

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Return 400 from POST /api/config when the body nests deeper than 32 levels. Real configs nest at most 6.
  • Clone the config in saveConfig before the temp-file write instead of after the rename, so a value structuredClone rejects fails before apps.json is replaced.

Testing
All green. Added 3 tests: a too-deep save is refused with the file unchanged, a realistic depth is accepted, and an unclonable value leaves the file and no temp file.

Changelog

Security

  • Refuse a config save or import nested too deeply, which could leave the config unreadable.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.

A config value nested thousands of levels deep was written to disk, then
failed the in-memory clone. Every later read cloned it too, so Settings,
export and sign-in failed until the file was edited by hand.

POST /api/config now refuses input nested deeper than 32 levels.
saveConfig clones before writing, so a value it cannot clone fails before
the file is replaced.
@SandObserver SandObserver added the security Security fix label Oct 18, 2026
@SandObserver
SandObserver merged commit c8d5bd4 into main Oct 18, 2026
6 checks passed
@SandObserver
SandObserver deleted the security/config-nesting-limit branch October 18, 2026 22:10
stackyard-release Bot pushed a commit that referenced this pull request Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Security fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant