Repository navigation
permissions: a project settings file incode cannot use fails closed and says why - #88
Merged
Merged
Conversation
…nd says why Found while running issue #19's steps with a real model: its .incode/settings.json was {"deny":["Write(secret.txt)"]}, a top-level `deny` incode does not read (rules go under "permissions"). The file parsed, the key was ignored, the rule was simply not there, and the Write it was written to stop ran: secret.txt was written. The only trace was a warning shown by /permissions, never on a -t run. Now read_project refuses a file with a key incode does not read, at the top level or inside `permissions` (a typo such as `denny`), as well as bad JSON or a non-object; and load() fails closed on any such file, as it already did for a broken managed file: every tool call is refused by a project-layer catch-all whose text carries the reason and the right shape, so the refusal the agent relays says what to fix. Measured live with the same file after the fix: `NOT RUN — Write is refused by the deny rule `*: .incode/settings.json has `deny` at the top level, which incode does not read (rules go under `permissions`: ...)``, and no secret.txt. Test: each unusable shape refuses Write, Read and Bash with that reason; the right shape denies only what it lists. Full suite: 2437 lib + 59 bin pass.
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.
Security fix, found while running #19's steps with a real model.
The bug
.incode/settings.jsonheld{"deny":["Write(secret.txt)"]}. incode reads rules only under"permissions", so the top-leveldenyparsed and was ignored. The rule simply wasn't there, and the Write it was meant to stop ran:secret.txtwas written. The only trace was a warning shown by/permissions, never on a-trun. The same happened for a typo insidepermissions(e.g.denny) and for invalid JSON (warning only, no rules).The fix (
src/permissions/rules/set.rs)read_projectrefuses a file with a key incode doesn't read, at the top level or insidepermissions, as well as bad JSON and a non-object.loadfails closed on any such file, as it already did for a broken managed file. Every tool call is refused by a project-layer catch-all whose text carries the reason and the right shape. A missing or empty file still means no rules.Verified
incode -t "write secret.txt with x"with that file now getsNOT RUN — Write is refused by the deny rule \*: .incode/settings.json has `deny` at the top level, which incode does not read (rules go under `permissions`: {"permissions": {"deny": [...], "ask": [...]}}); every tool call is refused until …`. Nosecret.txt` appeared, and the agent relayed the fix instead of retrying.-D warningsclean. Full suite: 2437 lib + 59 bin pass.#19's step is corrected to
{"permissions":{"deny":["Write(secret.txt)"]}}.