Skip to main content
Menu
Advisories

Repo-local .gortex.yaml index.transforms runs arbitrary commands when an untrusted repository is indexed (incomplete fix of #1201)

GHSA-CCJQ-25J8-M4PHPublished Updated GitHub

Description

Repo-local .gortex.yaml index.transforms runs arbitrary commands when an untrusted repository is indexed (incomplete fix of #1201)

Summary

A repository can commit a .gortex.yaml with an index.transforms rule whose command is an arbitrary argv. When the victim indexes that repository (for example gortex init --analyze in a freshly cloned repo, or tracking it with the daemon), Gortex runs that command for every matching file, as the victim, with no opt-in.

PR #1201 ("config: gate repo-local extractor plugins behind opt-in") fixed the same problem for index.extractor_plugins, and #1203 did the same for llm.custom. index.transforms is a sibling field that also runs an external process, but it is still copied from the repo-local config. The gate only covers the two fields it names.

Affected versions

  • main at eb3237d (2026-11-08), reproduced.
  • The latest release, v0.64.11, contains the same transform code and predates #1201 (so extractor plugins are ungated there too). I expect every version that has index.transforms to be affected.

Details

  • internal/config/manager.go#L459-L474: repoConfig copies the repo-local workspace config and clears only Index.ExtractorPlugins (unless GORTEX_ALLOW_LOCAL_EXTRACTOR_PLUGINS=1) and LLM.Custom (unless GORTEX_ALLOW_LOCAL_PROVIDERS=1). Index.Transforms is left as-is.
  • internal/config/config.go#L852-L856: IndexConfig.Transforms []TransformRule is loaded from index.transforms.
  • internal/indexer/indexer.go#L755: the indexer builds newTransformPipeline(cfg.Transforms, ...).
  • internal/indexer/transform.go#L81-L88: every rule with a non-empty Command becomes a command transform.
  • internal/indexer/transform.go#L376-L378: exec.CommandContext(ctx, c.argv[0], c.argv[1:]...), with the comment "argv is operator-declared config, not user-derived input". That is not true once the argv comes from the repository's own .gortex.yaml.
  • Load paths: cmd/gortex/init.go#L568-L569 (init --analyze) and internal/indexer/multi.go#L2289-L2291 (daemon track/reindex) both call LoadWorkspaceConfig(prefix, root) and then GetRepoConfig(prefix). The transform also runs again on incremental re-index of changed files (watcher/poller). This means a later malicious commit pulled into an already-tracked repository triggers it too.

Steps to reproduce

  1. Build gortex at eb3237d (go build ./cmd/gortex).
  2. Create a repository containing main.go (package main; func main() {}) and this .gortex.yaml: ```yaml index: transforms:
  • name: poc extensions: [".go"] command: ["sh", "-c", "id > /tmp/gortex-transform-poc-marker; cat"] `` git init && git add -A && git commit -m init`.
  1. In that directory run gortex init --analyze -y --no-hooks --no-skills .
  2. /tmp/gortex-transform-poc-marker now contains the output of id. Indexing still succeeds because the command echoes the file back through cat, so nothing looks wrong to the user.
  3. Control: put the same command under index.extractor_plugins in another repo and repeat. No marker is created, so the #1201 gate works for that field.

I reproduced this twice in fresh, network-isolated containers, with the control negative both times.

Impact

Anyone who can get a victim to index a repository can run arbitrary commands as the victim. This includes cloning a project to evaluate it, an agent tracking a repository it was pointed at, or pulling a new commit into a tracked repo. The attacker can then read source, credentials and tokens, or persist on the machine. #1201 already treats this as a security issue ("a cloned repo can force the victim's indexer to execute attacker-chosen code"), and index.transforms is the same capability through a different key.

Suggested fix

  • Clear out.Index.Transforms for repo-local config in repoConfig, as is done for ExtractorPlugins. Allow it only behind an explicit operator opt-in (reuse GORTEX_ALLOW_LOCAL_EXTRACTOR_PLUGINS or add GORTEX_ALLOW_LOCAL_TRANSFORMS).
  • Consider an allow-list instead of a deny-list: copy only known-safe fields from repo-local config, so that new exec-capable keys are not exposed by default. index.grammars (GrammarSpec.Library, loaded as a shared object) is another repo-local field that loads native code. It is weaker because it needs an absolute path on the victim's machine, but it is worth gating too.

This issue was found with automated analysis and manually verified.

Affected versions

References

GitHub · zzet/gortex