clone guard: -o path that is a symlink into the checkout is followed, still overwrites the repo AGENTS.md (follow-up to #238/#275)

Open
#276 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, shell
Domain
security, tooling

Research direction

Start with adapters/codex/install.sh and reproduce the symlink case from the issue against a checkout containing AGENTS.md. Trace the -o path handling through the directory-resolution guard, then add the requested symlink test. Done means the target inside the checkout is refused with exit 2 and no file or backup is written.

Written by the indexing model from the issue text.

Description

From the PR #275 review (Cyra). #275 refuses in-checkout AGENTS.md writes by resolving the directory of -o. The guard does not resolve the final path component, so a symlink whose target lives inside the checkout is followed and the write lands in the repo anyway.

Repro on pr-275 (a9508c82):

cd /path/to/coco-checkout
ln -s "$PWD/AGENTS.md" /tmp/outlink.md
bash adapters/codex/install.sh -o /tmp/outlink.md
# exit 0, no refusal; /path/to/coco-checkout/AGENTS.md replaced (1294 lines), backup written as /tmp/outlink.md.backup-<ts>

Expected: same refusal as PR #275's other cases (-o inside the checkout), exit 2, nothing written.
Actual: the tracked contributor guide is overwritten through the symlink.

Lower severity than #238 — it needs a deliberately planted symlink, not the README path — so it does not block #275. Fix would be resolving the target (e.g. readlink loop / python3 -c os.path.realpath) before the inside $repo_root_phys comparison, plus a test case.

P2, non-blocking for #275. Evidence above, reproduced 2026-09-27.

Dominant language
HTML
Stars
347
Forks
12
Avg merge
2d 16h
Merged PRs (30d)
95

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coco-research/coco

All issues in coco-research/coco

Similar issues

More Security issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.