Repo-local .gortex.yaml index.transforms runs arbitrary commands when an untrusted repository is indexed (incomplete fix of #1201)
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
mainateb3237d(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.transformsto be affected.
Details
internal/config/manager.go#L459-L474:repoConfigcopies the repo-local workspace config and clears onlyIndex.ExtractorPlugins(unlessGORTEX_ALLOW_LOCAL_EXTRACTOR_PLUGINS=1) andLLM.Custom(unlessGORTEX_ALLOW_LOCAL_PROVIDERS=1).Index.Transformsis left as-is.internal/config/config.go#L852-L856:IndexConfig.Transforms []TransformRuleis loaded fromindex.transforms.internal/indexer/indexer.go#L755: the indexer buildsnewTransformPipeline(cfg.Transforms, ...).internal/indexer/transform.go#L81-L88: every rule with a non-emptyCommandbecomes 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) andinternal/indexer/multi.go#L2289-L2291(daemon track/reindex) both callLoadWorkspaceConfig(prefix, root)and thenGetRepoConfig(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
- Build gortex at
eb3237d(go build ./cmd/gortex). - 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`.
- In that directory run
gortex init --analyze -y --no-hooks --no-skills . /tmp/gortex-transform-poc-markernow contains the output ofid. Indexing still succeeds because the command echoes the file back throughcat, so nothing looks wrong to the user.- Control: put the same command under
index.extractor_pluginsin 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.Transformsfor repo-local config inrepoConfig, as is done forExtractorPlugins. Allow it only behind an explicit operator opt-in (reuseGORTEX_ALLOW_LOCAL_EXTRACTOR_PLUGINSor addGORTEX_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.