Repository navigation
fix(server): confine state reads to the .ai-engineering directory - #14
Merged
Merged
Conversation
CodeQL flagged py/path-injection where jload reads a path built from a request. Every route already limits names to NAME_RE, which has no '/', so no request can reach outside today; CodeQL cannot see a regex check in another function. The server's _jload now resolves the path (symlinks included) and refuses anything outside the state directory, as a second wall and a guard CodeQL can follow. New test covers '..' escapes and a planted symlink. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Closes code-scanning alert #3 (py/path-injection, harness/policy.py:57).
Assessment: not exploitable today: every route validates names with NAME_RE (no '/'), the POST body uses the same validator, and the server is loopback-only with a bearer token. CodeQL cannot see a regex check in another function as a sanitizer.
Change: the server's
_jloadresolves the path withos.path.realpath(symlinks included) and returns 400 unless it is inside.ai-engineering. All server reads go through it.Test:
test_state_reads_are_confined_to_the_state_directory(written first, seen failing): '..' escapes and a planted symlink are refused.Local (codespace, missing uv/ruff/PyYAML): 64 passed / 11 failed with the change vs 63 / 11 without; the 11 are the same environment failures (verify runs, test_ci). Full results: this PR's CI.
🤖 Generated with Claude Code