Documentation
¶
Overview ¶
Package envutil sanitizes subprocess environments so the daemon and CLI never leak secrets (SAGEOX_TOKEN, GITHUB_TOKEN, AWS_*, …) into untrusted or long-lived child processes (third-party adapters, user-defined hooks).
It is a leaf package: it imports only the standard library plus pkg/adapterprotocol (for the OX_PROTOCOL_VERSION default), so it can be safely imported by internal/session/adapters, internal/daemon, and internal/daemon/hooks without creating an import cycle.
See ADR-022 §6 (docs/adr/ADR-022-adapter-security-posture.md) for the first-party-vs-third-party trust distinction that motivates default-deny sanitization.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SafeCommand ¶
SafeCommand returns an exec.Cmd whose environment is pre-sanitized via SanitizedEnv(os.Environ(), nil) — a default-deny convenience for spawning untrusted children. Callers needing to pass through a declared required_env allowlist should build the command manually and set cmd.Env = SanitizedEnv(...).
func SanitizedEnv ¶
SanitizedEnv builds a sanitized environment for subprocess execution. It filters environ (typically os.Environ()) to only include:
- Exact-match allowlisted vars: HOME, PATH, TMPDIR
- Prefix-match allowlisted vars: XDG_*
- OX_* protocol vars (OX_PROTOCOL_VERSION, OX_REPO_ROOT, OX_REPO_ID, OX_TEAM_ID)
- Any additional vars declared in requiredEnv (e.g. an adapter's required_env list)
All other variables (API keys, tokens, secrets) are stripped. The denylist always wins: a requiredEnv name matching a denylisted pattern is never passed through, so a malicious adapter cannot exfiltrate credentials by declaring them.
Types ¶
This section is empty.