Skip to content

docs(governance): correct the security model around readonly rewrites - #383

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/readonly-security-model-comments
Aug 17, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/readonly-security-model-comments

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Corrects comments introduced in #381 that describe the security model incorrectly, and pins the real mechanism with tests.

The wrong claim

#381 stated — in the branch_is_readonly doc, a test comment, and its own PR description — that the git branch misclassification "was never exploitable" because GitTool is SideEffectClass::Write, so authorize still gates it.

That is wrong, and wrong in the direction that matters.

What actually happens

Approval is gated on tool identity, not side-effect class:

  • hitl_tools defaults to the shell-equivalent tools — bash, background_run, exec_command, mcp:*.
  • hitl_classes defaults to empty, and apply_mode clears it in both shipped modes (Manual and Accept Edits).
  • authorize returns Allow for any tool in neither set, before pattern rules are consulted.

git is in neither set. So SideEffectClass::Write on GitTool has no gating effect at all — as the pre-existing non_hitl_tools_still_allowed_without_prompting already asserts for write_file. And GitTool's own argument policy explicitly permits -u and --set-upstream-to (builtins.rs), so it does not reject them either.

There is no second gate below readonly.rs.

Consequence

readonly.rs is the security boundary, not a layer above one. A rewrite turns a call that would have prompted into one authorized outright — that is the entire purpose of the rewrite. So classifying a mutating git command as a read is an approval bypass, not a cosmetic mislabel: git branch --set-upstream-to=…, -u<upstream>, --unset-upstream and --edit-description were unprompted repository mutations before #381.

#381's fix was correct and remains correct. Only the reasoning recorded alongside it was wrong — which matters, because that reasoning is what a future reader would rely on when deciding how careful this classifier has to be.

Changes

  • Module header now states that this module is a security boundary and that every classifier in it must fail closed.
  • branch_is_readonly doc corrected to describe identity-based gating and the absence of a downstream catch.
  • Test comment corrected; it pointed at a backstop that does not exist.
  • Two new tests pin the mechanism so it cannot be misread again:
    • rewritten_git_calls_are_not_prompted — bash prompts (Hitl), the rewritten git call is Allow, making the privilege delta explicit.
    • shipped_modes_leave_hitl_classes_empty — both modes clear hitl_classes, so class-based gating never applies unless a caller opts in by hand.

No behavior change; comments and tests only.

Verification

cargo fmt --all -- --check, cargo clippy --workspace --all-targets --locked -- -D warnings, and cargo test --workspace --locked --no-fail-fast all green on a704821. forge-governance 87 → 89.

The comments added in #381 claimed the git branch misclassification was
never exploitable because GitTool is SideEffectClass::Write and authorize
still gates it. That is wrong, and it is wrong in the direction that
matters.

Approval is gated on tool identity, not side-effect class. hitl_tools
holds the shell-equivalent tools (bash, background_run, exec_command,
mcp:*) and apply_mode clears hitl_classes in every shipped mode, so
authorize returns Allow for any tool outside that set before pattern
rules are consulted. git is outside it, and GitTool's own argument policy
permits -u/--set-upstream-to. Nothing downstream catches a
misclassification.

So readonly.rs is the boundary, not a layer above one, and #381 closed an
approval bypass rather than fixing a cosmetic label: a mutating git
command classified as a read became an unprompted mutation.

Corrects the module header, the branch_is_readonly doc and the test
comment, and pins the mechanism with two tests so it cannot be misread
again: bash prompts while the rewritten git call is allowed outright, and
both shipped modes leave hitl_classes empty.
@github-actions
github-actions Bot enabled auto-merge (squash) August 17, 2026 02:31
@github-actions
github-actions Bot merged commit 7fdb7a0 into main Aug 17, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
…#383)

The comments added in #381 claimed the git branch misclassification was
never exploitable because GitTool is SideEffectClass::Write and authorize
still gates it. That is wrong, and it is wrong in the direction that
matters.

Approval is gated on tool identity, not side-effect class. hitl_tools
holds the shell-equivalent tools (bash, background_run, exec_command,
mcp:*) and apply_mode clears hitl_classes in every shipped mode, so
authorize returns Allow for any tool outside that set before pattern
rules are consulted. git is outside it, and GitTool's own argument policy
permits -u/--set-upstream-to. Nothing downstream catches a
misclassification.

So readonly.rs is the boundary, not a layer above one, and #381 closed an
approval bypass rather than fixing a cosmetic label: a mutating git
command classified as a read became an unprompted mutation.

Corrects the module header, the branch_is_readonly doc and the test
comment, and pins the mechanism with two tests so it cannot be misread
again: bash prompts while the rewritten git call is allowed outright, and
both shipped modes leave hitl_classes empty.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…#383)

The comments added in #381 claimed the git branch misclassification was
never exploitable because GitTool is SideEffectClass::Write and authorize
still gates it. That is wrong, and it is wrong in the direction that
matters.

Approval is gated on tool identity, not side-effect class. hitl_tools
holds the shell-equivalent tools (bash, background_run, exec_command,
mcp:*) and apply_mode clears hitl_classes in every shipped mode, so
authorize returns Allow for any tool outside that set before pattern
rules are consulted. git is outside it, and GitTool's own argument policy
permits -u/--set-upstream-to. Nothing downstream catches a
misclassification.

So readonly.rs is the boundary, not a layer above one, and #381 closed an
approval bypass rather than fixing a cosmetic label: a mutating git
command classified as a read became an unprompted mutation.

Corrects the module header, the branch_is_readonly doc and the test
comment, and pins the mechanism with two tests so it cannot be misread
again: bash prompts while the rewritten git call is allowed outright, and
both shipped modes leave hitl_classes empty.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…#383)

The comments added in #381 claimed the git branch misclassification was
never exploitable because GitTool is SideEffectClass::Write and authorize
still gates it. That is wrong, and it is wrong in the direction that
matters.

Approval is gated on tool identity, not side-effect class. hitl_tools
holds the shell-equivalent tools (bash, background_run, exec_command,
mcp:*) and apply_mode clears hitl_classes in every shipped mode, so
authorize returns Allow for any tool outside that set before pattern
rules are consulted. git is outside it, and GitTool's own argument policy
permits -u/--set-upstream-to. Nothing downstream catches a
misclassification.

So readonly.rs is the boundary, not a layer above one, and #381 closed an
approval bypass rather than fixing a cosmetic label: a mutating git
command classified as a read became an unprompted mutation.

Corrects the module header, the branch_is_readonly doc and the test
comment, and pins the mechanism with two tests so it cannot be misread
again: bash prompts while the rewritten git call is allowed outright, and
both shipped modes leave hitl_classes empty.
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