GO-2026-7003: Gortex: Arbitrary file write / repo-confinement escape in `write_file` / `edit_file` / `move_inline` MCP tools → code execution
Summary Gortex is an MCP server exposing writefile, editfile, and moveinline tools. resolveFilePath exempts absolute paths from confinement, and the write handlers — unlike readfile / getsymbolsource — never call guardSymlinkWithinRepo. A single MCP writefile call with an absolute path writes any file the daemon user can, outside every indexed repo root (AtomicWriteFile's MkdirAll auto-creates missing parents). Writing ~/.zshrc, ~/.bashrc, .git/hooks/pre-commit, or a cron/systemd unit yields code execution on the next shell/commit. This directly violates the project's own SECURITY.md invariant "File-path resolution is confined to indexed repository roots"
Affected internal/mcp/toolsfileops.go (+ toolsmoveinline.go), HEAD 28fa017 (v0.53.0). CWE-22 (Path Traversal) / CWE-73 (External Control of File Name/Path) → CWE-94 (code execution).
Vulnerable code internal/mcp/toolsfileops.go:54-62 resolveFilePath exempts absolute paths from the repo-root confinement; the write sink at :793 (AtomicWriteFile, writefile) and :676 (editfile) run with no guardSymlinkWithinRepo. The asymmetry is the bug: readfile (:940) and getsymbolsource do call guardSymlinkWithinRepo; the write path does not.
PoC (executed) The PoC (internal/mcp/pocarbitrarywritetest.go, package mcp) builds the server via the repo's own newSingleRepoServer(t) harness and invokes the real srv.handleWriteFile through the genuine mcplib.CallToolRequest shape: === RUN TestPoCArbitraryWriteAbsolutePathEscapesEveryRepoRoot indexed repo root (confinement boundary): /var/folders/.../myrepo handler status=created path=/var/folders/.../003/pwn.txt byteswritten=50 PROOF: /var/folders/.../003/pwn.txt now exists with attacker bytes "OWNED-by-gortex-writefile-outside-every-repo-root" RCE-PATH PROOF: wrote /var/folders/.../004/victim-home/.zshrc (parent dir auto-created) -> "echo PWNEDBYGORTEXRCE # injected via writefile" VIOLATION of SECURITY.md line 17 ("It does not write to source files") --- PASS (go test ok) The test asserts the handler did not return IsError and that the files exist outside every repo root. (Full PoC available on request.)
Impact writefile / editfile are MCP tools driven by an LLM agent. A prompt-injected or adversarial agent (the standard MCP threat model) writes any file the daemon user can — startup/hook/cron files → arbitrary code execution on the host running the daemon. Confinement (the security property SECURITY.md promises) is broken on the write path.
Severity High — CVSS v3.1 AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N ≈ 8.x. UI:R reflects that a tool call must be elicited from the agent (standard MCP injected-tool model). The RCE is a chain (write a startup/hook file → execute on next trigger), so I:H + the code-execution path. Floor: if the deployment never exposes write tools to untrusted input, impact is lower — but the tool is shipped and the confinement guard is simply absent on the write path.
Remediation Apply guardSymlinkWithinRepo (and reject absolute paths outside the indexed roots) on writefile / editfile / moveinline, identically to readfile / getsymbolsource. Confinement must cover the write path.
Dedup / freshness (re-verified live) gh api repos/zzet/gortex/security-advisories → [] (none). gh search prs/issues for resolveFilePath / guardSymlinkWithinRepo / symlink / traversal / confinement → 0 (re-verified 2026-06-27; recent merges #175-#183 touch indexer/persistence, not the write path). resolveFilePath / guardSymlinkWithinRepo are gortex-own code (not vendored). Fresh at HEAD 28fa017.
Other sources
Gortex is a high-performance code-intelligence engine for AI agents and integrated development environments. Prior to 0.55.0, resolveFilePath in internal/mcp/toolsfileops.go accepts absolute paths without checking indexed repository roots, while writefile, editfile, and moveinline in internal/mcp/toolsmoveinline.go omit guardSymlinkWithinRepo before reaching AtomicWriteFile and related write sinks. A caller that can influence MCP tool arguments can therefore create or overwrite files anywhere the daemon user can access, including startup or hook files that execute code on a later trigger. The flaw violates Gortex's repository-confinement invariant and can lead to arbitrary host code execution. This issue is fixed in version 0.55.0.
— OSV
Gortex: Arbitrary file write / repo-confinement escape in writefile / editfile / moveinline MCP tools → code execution in github.com/zzet/gortex
— OSV
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/zzet/gortexto a version that resolves this vulnerability.Fixed in 0.55.0 - Upgrade
Upgrade
github.com/zzet/gortexto a version that resolves this vulnerability.Fixed in 0.55.0
Event History
Frequently Asked Questions
What access does an attacker need to exploit this issue?
An attacker needs to cause a single MCP call to write_file using an absolute path. The resulting write is limited by the permissions of the user running the Gortex daemon, but is not limited to indexed repository roots.
What systems and files are most at risk?
Any host running the affected MCP server is exposed for files writable by its daemon user, including files outside all indexed repositories. The described impact includes shell startup files, Git pre-commit hooks, and cron or systemd units, which can lead to code execution when they are subsequently used.
How can I determine whether my deployment is affected?
The affected code is identified as internal/mcp/tools_fileops.go and tools_move_inline.go at HEAD 28fa017, corresponding to v0.53.0. Affected behavior is present if resolveFilePath accepts absolute paths without repository-root confinement and the write_file or edit_file paths do not call guardSymlinkWithinRepo.