/** * Build a sanitized child-process environment. * * The bash/exec tools and MCP stdio transports execute LLM-generated or * configured commands. The parent process carries provider API keys * (ANTHROPIC_API_KEY, OPENAI_API_KEY, ...), VCS tokens (GITHUB_TOKEN), * and cloud credentials. Forwarding those to a child is an exfiltration * vector even with `permission: 'confirm'` — a compromised MCP server * or a cleverly composed shell pipeline can leak secrets. * * Strategy: copy a small, explicit allowlist of variables that real builds * need, then copy anything else that does NOT look secret-bearing. This * preserves user-friendly behavior (locale, terminal, npm config) while * blocking the obvious leak channels. Two value-side guards back up the * name-based filter: * - any value carrying an embedded URI credential (`scheme://user:pass@host`, * e.g. `DATABASE_URL`/`REDIS_URL`/`*_DSN`) is dropped (WS-01); * - `NODE_OPTIONS` is forwarded but with module-preload directives * (`--require`/`--import`/`--loader`) stripped so a parent-set value can't * inject code into node children (WS-02). * * Override with `WRONGSTACK_CHILD_ENV_PASSTHROUGH=1` to forward the full * parent environment unchanged (opt-in for advanced users who understand * the risk). */ /** * Strip module-preload directives from a `NODE_OPTIONS` value while preserving * benign flags (`--no-warnings`, `--max-old-space-size=…`, etc.). Handles both * the `--require=./x.js` and space-separated `--require ./x.js` forms. Returns * the sanitized string (possibly empty). */ export declare function sanitizeNodeOptions(value: string): string; export interface BuildChildEnvOptions { /** Session ID to inject as WRONGSTACK_SESSION_ID. */ sessionId?: string | undefined; /** Additional env vars to merge (takes priority over filtered parent env). */ extra?: NodeJS.ProcessEnv | undefined; } /** * Commit identity applied to every git-touching child process via the * `GIT_AUTHOR_*` / `GIT_COMMITTER_*` env vars. Env-var identity outranks * every `git config` layer (repo/global/system), so commits made by any * tool (git tool, bash/exec, worktree manager, plugins) carry this * name/email without touching the user's git config — hand-made commits * in a normal terminal are unaffected. */ export interface GitIdentity { name?: string | undefined; email?: string | undefined; } /** * Set (or clear with `null`) the git commit identity injected by * `buildChildEnv()`. Wired at boot from the user-level `config.git.identity` * (the config loader strips `git` from repo-committed in-project configs — * identity spoofing must not be repo-controllable) and re-applied at runtime * by the `/gitid` slash command. */ export declare function configureChildEnvGitIdentity(identity: GitIdentity | null | undefined): void; /** Current configured git identity, or null when none is set. */ export declare function getChildEnvGitIdentity(): Readonly | null; /** * Build a filtered child-process environment suitable for bash, exec, and * MCP server subprocesses. Strips API keys, tokens, and other credentials * while preserving system/tooling variables. */ export declare function buildChildEnv(optsOrSessionId?: BuildChildEnvOptions | string): NodeJS.ProcessEnv; //# sourceMappingURL=child-env.d.ts.map