Skip to content

permissions: a project settings file incode cannot use fails closed and says why - #88

Merged
blockmandev merged 1 commit into
mainfrom
fix/project-settings-fail-closed
Nov 13, 2026
Merged

blockmandev merged 1 commit into
mainfrom
fix/project-settings-fail-closed

Conversation

@blockmandev

Copy link
Copy Markdown
Member

Security fix, found while running #19's steps with a real model.

The bug

.incode/settings.json held {"deny":["Write(secret.txt)"]}. incode reads rules only under "permissions", so the top-level deny parsed and was ignored. The rule simply wasn't there, and the Write it was meant to stop ran: secret.txt was written. The only trace was a warning shown by /permissions, never on a -t run. The same happened for a typo inside permissions (e.g. denny) and for invalid JSON (warning only, no rules).

The fix (src/permissions/rules/set.rs)

  • read_project refuses a file with a key incode doesn't read, at the top level or inside permissions, as well as bad JSON and a non-object.
  • 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. A missing or empty file still means no rules.

Verified

  • Live, the same probe that showed the bug: incode -t "write secret.txt with x" with that file now gets 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`: {"permissions": {"deny": [...], "ask": [...]}}); every tool call is refused until …`. No secret.txt` appeared, and the agent relayed the fix instead of retrying.
  • New test: four unusable shapes each refuse Write, Read and Bash with the reason. The control, the right shape, denies only what it lists. It can't pass on the old code, which left no rules at all.
  • clippy -D warnings clean. Full suite: 2437 lib + 59 bin pass.

#19's step is corrected to {"permissions":{"deny":["Write(secret.txt)"]}}.

…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.
@blockmandev
blockmandev merged commit 7e12242 into main Nov 13, 2026
12 checks passed
@blockmandev
blockmandev deleted the fix/project-settings-fail-closed branch November 15, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant