# Gortex: Arbitrary file write / repo-confinement escape in `write_file` / `edit_file` / `move_inline` MCP tools → code execution

Gortex MCP write_file/edit_file exempt absolute paths from repo confinement and skip symlink guards, letting an injected agent write ~/.zshrc or git hooks for code execution.

- Payout: Research
- Severity: high
- Program: Gortex
- Found by: daniel-mertz
- Disclosed: 2026-11-19
- CVE: CVE-2026-62964
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-w42c-h7hr-f67p
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-w42c-h7hr-f67p
- Tags: area:ai domain:ai domain:oss impact:integrity impact:rce kind:research platform:ghsa sev:high tech:go technique:chained technique:source-review vuln:path-traversal vuln:prompt-injection vuln:rce

**Target:** MCP server file-operation tools (write_file, edit_file, move_inline)
**Root cause:** resolveFilePath exempts absolute paths from repo-root confinement, and the write handlers never call guardSymlinkWithinRepo, unlike read_file/get_symbol_source. AtomicWriteFile's MkdirAll also auto-creates missing parent directories.
**Steps:**
1. Index a repo so the server has a confinement root.
2. Invoke the MCP `write_file` tool with an absolute path outside every repo root, e.g. `/tmp/003/pwn.txt`, and attacker content.
3. Handler returns status=created and writes the file; parent dirs are auto-created.
4. Repeat with `~/.zshrc` or `.git/hooks/pre-commit` to plant code that executes on next shell/commit.
**How found:** Code review of the file-ops handlers revealed an asymmetry: read_file and get_symbol_source call guardSymlinkWithinRepo, but the write sinks do not, and resolveFilePath explicitly exempts absolute paths. Verified with the repo's own newSingleRepoServer test harness invoking the real handler.
**Exploitation:** A prompt-injected or adversarial LLM agent drives the write_file/edit_file MCP tool with an absolute path, writing startup files (~/.zshrc, ~/.bashrc), git hooks, or cron/systemd units as the daemon user; code executes on the next shell, commit, or scheduled trigger.
**Escalation:** Chained from arbitrary file write to host code execution by targeting shell startup files and git hooks rather than arbitrary data files.
**Insight:** When a codebase has a confinement/guard helper, grep every sink for its call sites — the bug is usually the one path that forgot it. Here the read path was guarded and the write path was not; also check whether path resolution special-cases absolute paths.

