Skip to content

chore(hardening): ask before writing files a later command executes - #9

Merged
devGregA merged 1 commit into
mainfrom
hardening/execution-trigger-writes
Aug 13, 2026
Merged

chore(hardening): ask before writing files a later command executes#9
devGregA merged 1 commit into
mainfrom
hardening/execution-trigger-writes

Conversation

@devGregA

Copy link
Copy Markdown
Contributor

Problem

git-cwd-write-approve approves any Write/Edit whose target is inside the git workspace, with no prompt. For source files that is the right call — editing them is the job, and the change is visible in the diff before anything runs it.

A small set of files break that assumption. Nothing executes when they are written; the next routine command executes what they now say:

  • package.jsonscripts.postinstall / prepare run on the next npm install
  • Makefile, justfile, Taskfile.yml → next make / just / task
  • .github/workflows/*, .circleci/*, .gitlab-ci.yml, Jenkinsfile → next CI run
  • conftest.py, setup.py → next test/install run
  • .pre-commit-config.yaml, .husky/* → next commit

So an instruction the model picked up from repo content could rewrite one of these with no prompt, and the payload runs later under whatever ran the build. This was the last remaining "injected content reaches execution" path after the earlier hardening PRs.

What changed

New execution-trigger-write-ask policy, placed immediately after the git-control ask and before auto-mode-approve — the same position the sensitive-file check occupies, and for the same reason: "it was inside the repo" is not a good enough justification to skip the prompt for these particular files.

Deliberate limits:

  • Write access only. Reading package.json is routine and stays unprompted; there is a test for that.
  • Basename and directory-prefix matching against the workspace-relative path, so src/package.json.ts and docs/Makefile.md are unaffected — also tested.
  • Session approvals and user allow rules still win, since they sit earlier in the chain. Approving once does not mean being asked again.

Testing

  • New: each trigger file asks; still asks in auto mode; ordinary source writes keep the git-cwd-write-approve fast path; a read of package.json does not fire the policy.
  • Verified as real tests — and worth noting how: my first negative control was invalid. git stash push silently ignores untracked files, so the new policy file was never removed and the tests "passed" against unchanged code. Re-ran it by unregistering the policy from the chain instead, which correctly fails the 2 positive tests.
  • Full agent-core-v2 suite green: 310 files / 4905 tests.
  • oxlint clean on changed files (one pre-existing warning in user-configured-rule.ts, untouched here); tsc --noEmit clean.

Checklist

  • Problem explained above (fork-local hardening; no upstream issue).
  • Tests added that prove the change works.
  • Changeset added (minor).
  • No doc update needed.

In-workspace writes are approved without a prompt, which is the right
default for source files: editing them is the job, and the change shows up
in the diff before anything runs it. A handful of files do not fit that
shape. Nothing happens when package.json, a Makefile, a workflow under
.github, conftest.py or a pre-commit config is written, and then the next
install, test run or CI job executes whatever they now say — so the write
is the dangerous act and that is where the prompt has to be.

Add execution-trigger-write-ask ahead of the blanket in-workspace write
approval and ahead of auto mode, matching where the sensitive-file and
git-control checks sit. Session approvals and user allow rules keep their
precedence, so a decision already made is not re-asked. Only write access
counts: reading package.json stays routine.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@devGregA
devGregA merged commit bf705b4 into main Aug 13, 2026
14 checks passed
@devGregA
devGregA deleted the hardening/execution-trigger-writes branch August 13, 2026 04:01
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