Skip to content

A worker can replace Git metadata outside its given folder #1351

Open

Description

@AbirAbbas

What happened

HAZARD seen once on commit 17ae56d34 (staging-20260921-17ae56d3496f) on 2026-09-21. Lane A2, item A2-06, gave codeaf do a repository folder. The worker trace then named these actions:

rm -rf <repo>/.git
cd <parent> && git init
git commit

The repository's .git disappeared, the parent gained .git, and the parent history contained 6f85800 Add add(a,b) and one pytest test. Three controlled reruns did not reproduce it. v0.3.0 (9258f7052) was not checked, so this issue makes no regression claim.

Replication

Deterministic (no model).

No deterministic reproduction is known. A future gate should use a stub worker that attempts the three recorded commands in a nested repository and assert the boundary refuses them.

Field (real models).

Set OPENROUTER_API_KEY and run from a throwaway directory only:

root="$(mktemp -d)"; export CODEAF_HOME="$root/home"; repo="$root/parent/repo"
mkdir -p "$CODEAF_HOME" "$repo" && git -C "$repo" init -q
git -C "$repo" -c user.name=Test -c user.email=test@example.invalid commit --allow-empty -m base
codeaf do 'create add.py defining add(a, b) that returns a+b, and test_add.py with one pytest test for it. Declare the check "python3 -m pytest -q" so the review runs it.' --dir "$repo" --keep --db "$root/parent/a2-06.db" --yes-spend --json --model deepseek/deepseek-v4-flash --timeout 8m
git -C "$repo" status --short; git -C "$root/parent" log --oneline -1

Budget eight minutes and about $0.10. The original event may not recur; the three non-reproducing controls are part of the evidence, and the worker trace is why the boundary still needs a gate.

Where

The relevant enforcement seams are taskGroundGuard.PreAction, refusedOutsideGround, and outsideGroundRefusal in internal/session/taskoutside.go, plus Workspace.Resolve in internal/exec/workspace.go. The report does not establish how the commands passed them.

The fix

Every worker write and destructive action must stay within the folder passed by --dir. Refuse deletion of that folder's .git, refuse creating Git metadata in its parent, and surface the existing boundary wording containing is outside your copy.

Acceptance

  • e2e: Through codeaf do --json --dir <nested-repo> with a stub worker that attempts the three recorded commands, assert a receipt contains is outside your copy, the child .git still exists, the parent .git does not exist, and the command exits nonzero.
  • e2e: Through the same door, let the stub create add.py and test_add.py inside the given folder; assert both files exist there, python3 -m pytest -q passes, and no parent file changes.
  • Unit: Every destructive or write action resolves its effective working directory and targets through taskGroundGuard.PreAction; symlink, .., and changed-working-directory cases cannot escape the ground.
  • The manual pages internal/manual/chat/permissions.md and internal/manual/chat/choosing-a-folder.md quote is outside your copy, and the change entry's invalidates names the old belief that --dir alone constrained all worker actions.

Filed from the 2026-09-21 staging verification of 17ae56d; the lane reports, frames and e2e logs are in the owner's handoff folder for this promotion.

Activity

  1. added
    bugSomething the code does that it should not
    area:sessionThe engine — turns, tasks, the toolbelt, checkpoints
    on Sep 21, 2026
  2. added
    sev:criticalData loss, money spent wrongly, a false done, or the merge queue blocked
    on Sep 21, 2026
  3. santoshkumarradha commented on Sep 21, 2026

    @santoshkumarradha
    Member

    Classification: bug, area:session, sev:critical → milestone Reliable agent.

    • area:session — the boundary that should have refused this lives in the task lifecycle (taskGroundGuard, Workspace.Resolve), not in any tool or UI surface.
    • sev:critical — a worker deleting the given repo's .git and re-initializing the parent is data loss by the severity definition. Three reruns didn't reproduce it, but severity grades the harm when it fires, not the likelihood.
    • Milestone Reliable agent — a worker staying inside its given folder is exactly the "checks, worktrees, … behave as claimed" bar that milestone owns.

    drafted with CodeAF

  4. santoshkumarradha commented on Oct 23, 2026

    @santoshkumarradha
    Member

    Current-dev audit (39fdbea6f73c) found a remaining guard-level gap, without executing destructive commands: refusedOutsideGround(ground, "rm -rf <ground>/.git") returns no refusal. A disposable focused probe confirmed this. It proves the location guard permits deletion of its own Git metadata; it does not prove that the complete current codeaf do path executes the original three-command sequence. Keeping this critical report open. Next verification should exercise a stub worker through the real headless door inside a disposable nested repository before any fix is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:sessionThe engine — turns, tasks, the toolbelt, checkpointsbugSomething the code does that it should notsev:criticalData loss, money spent wrongly, a false done, or the merge queue blocked

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions