Skip to content

extractor-plugin: strip secret env vars from plugin subprocess - #1205

Merged
zzet merged 1 commit into
mainfrom
fix/extractor-plugin-secret-env-strip
Oct 31, 2026
Merged

zzet merged 1 commit into
mainfrom
fix/extractor-plugin-secret-env-strip

Conversation

@zzet

@zzet zzet commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Problem

internal/parser/languages/extractor_plugin.go launches the configured
plugin with cmd.Env = append(os.Environ(), "GORTEX_FILE_PATH=…"). That
inherits the daemon's entire environment — OPENAI_API_KEY,
GOOGLE_API_KEY, GORTEX_LLM_API_KEY, GITHUB_TOKEN, AWS_SECRET_ACCESS_KEY,
and the like — into the plugin process. A plugin command is config that a
repo-local .gortex.yaml can declare, so such a command could call
os.Environ() and exfiltrate those secrets.

Fix

Strip secret-shaped entries from the environment before launching the
plugin. stripSecretEnv keeps only vars whose name is not secret-shaped
(matching the shapes the LLM/embedding/network backends use —
*_API_KEY, APIKEY, _TOKEN, _SECRET, _BEARER, and Authorization),
so no future key escapes by an unknown name. PATH and other non-secret
vars are inherited so the command still resolves; GORTEX_FILE_PATH is
added after filtering.

Test

TestStripSecretEnv verifies API keys/tokens/secrets/bearer vars are
dropped while PATH, GORTEX_FILE_PATH, and a non-secret var survive.
The existing extractor-plugin suite passes unchanged.

internal/parser/languages/extractor_plugin.go launches the configured
plugin with cmd.Env = append(os.Environ(), "GORTEX_FILE_PATH=…"), inheriting
the daemon's whole environment — OPENAI_API_KEY, GOOGLE_API_KEY,
GORTEX_LLM_API_KEY, GITHUB_TOKEN, AWS_SECRET_ACCESS_KEY, and the like — into
the plugin process. A plugin command is config a repo-local .gortex.yaml can
declare, so it could read os.Environ() and exfiltrate those secrets.

Strip secret-shaped entries before launching: stripSecretEnv keeps only vars
whose name is not secret-shaped (matching the shapes the LLM/embedding/network
backends use: *_API_KEY, APIKEY, _TOKEN, _SECRET, _BEARER, Authorization), so
no future key escapes by an unknown name. PATH and other non-secret vars are
inherited so the command still resolves; GORTEX_FILE_PATH is added after
filtering.
@zzet
zzet force-pushed the fix/extractor-plugin-secret-env-strip branch from 0a525b0 to 18eb06c Compare October 31, 2026 14:00
@zzet
zzet merged commit 017db84 into main Oct 31, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant