GHSA-W42C-H7HR-F67P

Vulnerability from github – Published: 2026-11-19 20:36 – Updated: 2026-11-19 20:36
VLAI
Summary
Gortex: Arbitrary file write / repo-confinement escape in `write_file` / `edit_file` / `move_inline` MCP tools → code execution
Details

Summary

Gortex is an MCP server exposing write_file, edit_file, and move_inline tools. resolveFilePath exempts absolute paths from confinement, and the write handlers — unlike read_file / get_symbol_source — never call guardSymlinkWithinRepo. A single MCP write_file 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/tools_fileops.go (+ tools_move_inline.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/tools_fileops.go:54-62 resolveFilePath exempts absolute paths from the repo-root confinement; the write sink at :793 (AtomicWriteFile, write_file) and :676 (edit_file) run with no guardSymlinkWithinRepo. The asymmetry is the bug: read_file (:940) and get_symbol_source do call guardSymlinkWithinRepo; the write path does not.

PoC (executed)

The PoC (internal/mcp/poc_arbitrary_write_test.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   TestPoC_ArbitraryWrite_AbsolutePathEscapesEveryRepoRoot
  indexed repo root (confinement boundary): /var/folders/.../myrepo
  handler status=created path=/var/folders/.../003/pwn.txt bytes_written=50
  PROOF: /var/folders/.../003/pwn.txt now exists with attacker bytes "OWNED-by-gortex-write_file-outside-every-repo-root"
  RCE-PATH PROOF: wrote /var/folders/.../004/victim-home/.zshrc (parent dir auto-created) -> "echo PWNED_BY_GORTEX_RCE # injected via write_file"
  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

write_file / edit_file 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 write_file / edit_file / move_inline, identically to read_file / get_symbol_source. 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.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/zzet/gortex"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.55.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-62964"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-22",
      "CWE-73"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-11-19T20:36:31Z",
    "nvd_published_at": "2026-11-18T22:17:22Z",
    "severity": "HIGH"
  },
  "details": "### Summary\nGortex is an MCP server exposing `write_file`, `edit_file`, and `move_inline` tools. `resolveFilePath` **exempts absolute paths** from confinement, and the write handlers \u2014 unlike `read_file` / `get_symbol_source` \u2014 **never call `guardSymlinkWithinRepo`**. A single MCP `write_file` call with an absolute path writes any file the daemon user can, **outside every indexed repo root** (`AtomicWriteFile`\u0027s `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\u0027s own `SECURITY.md` invariant *\"File-path resolution is **confined to indexed repository roots**\"*\n\n### Affected\n`internal/mcp/tools_fileops.go` (+ `tools_move_inline.go`), HEAD `28fa017` (v0.53.0).\n**CWE-22** (Path Traversal) / **CWE-73** (External Control of File Name/Path) \u2192 **CWE-94** (code execution).\n\n### Vulnerable code\n`internal/mcp/tools_fileops.go:54-62` `resolveFilePath` exempts absolute paths from the repo-root confinement; the write sink at `:793` (`AtomicWriteFile`, `write_file`) and `:676` (`edit_file`) run with **no** `guardSymlinkWithinRepo`. The asymmetry is the bug: `read_file` (`:940`) and `get_symbol_source` **do** call `guardSymlinkWithinRepo`; the write path does not.\n\n### PoC (executed)\nThe PoC (`internal/mcp/poc_arbitrary_write_test.go`, package `mcp`) builds the server via the repo\u0027s **own** `newSingleRepoServer(t)` harness and invokes the real `srv.handleWriteFile` through the genuine `mcplib.CallToolRequest` shape:\n```\n=== RUN   TestPoC_ArbitraryWrite_AbsolutePathEscapesEveryRepoRoot\n  indexed repo root (confinement boundary): /var/folders/.../myrepo\n  handler status=created path=/var/folders/.../003/pwn.txt bytes_written=50\n  PROOF: /var/folders/.../003/pwn.txt now exists with attacker bytes \"OWNED-by-gortex-write_file-outside-every-repo-root\"\n  RCE-PATH PROOF: wrote /var/folders/.../004/victim-home/.zshrc (parent dir auto-created) -\u003e \"echo PWNED_BY_GORTEX_RCE # injected via write_file\"\n  VIOLATION of SECURITY.md line 17 (\"It does not write to source files\")\n--- PASS  (go test ok)\n```\nThe test asserts the handler did **not** return `IsError` and that the files exist outside every repo root. (Full PoC available on request.)\n\n### Impact\n`write_file` / `edit_file` 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 \u2014 startup/hook/cron files \u2192 arbitrary code execution on the host running the daemon. Confinement (the security property `SECURITY.md` promises) is broken on the write path.\n\n### Severity\n**High \u2014 CVSS v3.1 `AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N` \u2248 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 \u2192 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 \u2014 but the tool is shipped and the confinement guard is simply absent on the write path.\n\n### Remediation\nApply `guardSymlinkWithinRepo` (and reject absolute paths outside the indexed roots) on `write_file` / `edit_file` / `move_inline`, identically to `read_file` / `get_symbol_source`. Confinement must cover the write path.\n\n### Dedup / freshness (re-verified live)\n`gh api repos/zzet/gortex/security-advisories` \u2192 `[]` (none). `gh search prs/issues` for `resolveFilePath` / `guardSymlinkWithinRepo` / symlink / traversal / confinement \u2192 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`.",
  "id": "GHSA-w42c-h7hr-f67p",
  "modified": "2026-11-19T20:36:31Z",
  "published": "2026-11-19T20:36:31Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/zzet/gortex/security/advisories/GHSA-w42c-h7hr-f67p"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-62964"
    },
    {
      "type": "WEB",
      "url": "https://github.com/zzet/gortex/commit/5ba2f066dd6dcd726c4e61b74851862dc596d994"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/zzet/gortex"
    },
    {
      "type": "WEB",
      "url": "https://github.com/zzet/gortex/releases/tag/v0.55.0"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Gortex: Arbitrary file write / repo-confinement escape in `write_file` / `edit_file` / `move_inline` MCP tools \u2192 code execution"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Loading…

Loading…

Related by attack behaviour

Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.


Loading…