Skip to content

fix(codex): reject external AGENTS.md symlinks - #4176

Closed
Ha1baraA11 wants to merge 1 commit into
rtk-ai:developfrom
Ha1baraA11:codex/fix-codex-agents-symlink
Closed

Ha1baraA11 wants to merge 1 commit into
rtk-ai:developfrom
Ha1baraA11:codex/fix-codex-agents-symlink

Conversation

@Ha1baraA11

@Ha1baraA11 Ha1baraA11 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Guard project-scoped AGENTS.md writes with the existing symlink containment check.
  • Fail closed for external targets and add a Unix regression proving the target is left unchanged.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected
  • Init-focused tests (292), the full binary suite (3,735), formatting, diff validation, and Clippy pass.
  • The two existing Git-output compatibility assertions still fail on pristine develop; they are unrelated to this change.

Fixes #4156

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working codex init security labels Sep 21, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Guards project-scoped AGENTS.md writes during rtk init --codex with the existing symlink containment check, failing closed with the resolved target named in the error when AGENTS.md is a symlink pointing outside the project. Adds a Unix regression test proving an externally-targeted symlink is rejected and left unchanged.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4156


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@KuSh

KuSh commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this. #4269 covers the Codex AGENTS.md case as part of one policy for every project write: a project file that resolves outside the project is named first, then --auto-patch writes it, the default mode asks, and --no-patch or a non-interactive run refuses it (the warning #4156 asks for), rather than refusing it outright. It is built on the split src/hooks/init/ modules, where this PR's init.rs change no longer applies.

Closing in favour of #4269.

@KuSh KuSh closed this Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codex init security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk init --codex writes through a symlinked AGENTS.md, so a cloned repo can redirect the write outside the project

2 participants