Skip to content

fix(security): refuse process-configuration vault fields and scrub credentials from subprocesses - #93

Open
srstack wants to merge 1 commit into
mainfrom
fix/vault-env-and-subprocess-credentials
Open

srstack wants to merge 1 commit into
mainfrom
fix/vault-env-and-subprocess-credentials

Conversation

@srstack

@srstack srstack commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Two findings from the security review of main (182fdc8).

1. ti fs-vault run-with-secret injected process configuration into the child

run-with-secret turned every stored vault field name into a child environment variable after normalizeVaultEnvKey, but validated only the values (control bytes). A field named LD_PRELOAD, DYLD_INSERT_LIBRARIES, PATH, BASH_ENV, NODE_OPTIONS, PYTHONPATH, SSH_AUTH_SOCK, or GIT_SSH_COMMAND therefore let whoever can write the secret's fields choose which code the child loads or which helper it executes — code execution inside the child even though the attacker never sees ti's own credentials.

Field names that normalize to a process-configuration variable now fail with vault.env_key_forbidden (usage, exit 2) before the child is spawned. The rejection set is an exact-name table (vaultEnvKeyDenylist in internal/fs/vault.go) grouped by what the name controls: program lookup, shell startup/evaluation, dynamic loader, language-runtime startup, helper selection, and Windows shell/loader names.

  • The check runs on the normalized key, so path and PaTh hit PATH; case cannot bypass it.
  • It is exact-name, not prefix-based, so plausible secret names such as SSH_PRIVATE_KEY, GIT_TOKEN, or LD_PRELOAD_BACKUP stay injectable.
  • Trailing all-digit version segments are stripped before the lookup, because a runtime may read a versioned spelling first: LUA_INIT_5_4, LUA_PATH_5_4, LUA_CPATH_5_4, and LD_PRELOAD_32 resolve to their base entries. The rule only applies to a denied base name, so DB_URL_2 stays injectable.
  • A few families whose suffix the field name chooses are matched by prefix: DYLD_*, LD_32_*, LD_64_*, GIT_CONFIG_KEY_<n>, GIT_CONFIG_VALUE_<n>.
  • Every rejected name is listed in one error, in sorted order and with the behavior it would have configured, so the message is stable and actionable.
  • read-secret --format env still converts those names: it only prints values and never spawns a child.

2. internal/credentialenv existed but several subprocesses inherited credentials anyway

  • git (internal/fs/git.go, internal/fs/fuse_git.go): every invocation inherited the full environment. git runs hooks, clean/smudge filters, pagers, and helpers configured by the repository or the user, so TIDB_CLOUD_PRIVATE_KEY, TI_FS_TOKEN, and TI_VAULT_TOKEN were readable by that code. All git spawns are now built by newGitCommand, which applies the scrubbed environment at construction time, including the dormant native-FUSE reader. The unreferenced startGitHydrateBackground self-spawn is deleted: it spawns ti itself, so scrubbing it would have broken env-only credentials rather than hardened anything.
  • ti update (internal/update/update.go): validateInstalledBinary and the downloaded-companion help probe inherited os.Environ(), handing the TiDB Cloud keys and the filesystem bearer token to a freshly unpacked binary. Both now run with credentialenv.ScrubbedEnviron(); validateInstalledBinary keeps its TI_LOGGING=off override on top.

The credential-bearing spawn paths are unchanged: the companion environment still receives the DRIVE9_* values it needs, and the run-with-secret child still gets its existing scrub.

Verification

  • gofmt -l clean; go vet ./... clean on linux, GOOS=windows and GOOS=darwin clean.
  • go test -count=1 ./... passes; make e2e passes.
  • New tests: TestVaultSecretChildEnvRejectsProcessConfigurationKeys (versioned, prefixed, and runtime-hook spellings), TestVaultSecretChildEnvAllowsSecretLikeKeys, TestVaultSecretChildEnvForbiddenKeyMessageIsStable, TestTrimVaultEnvVersionSuffix, TestVaultSecretChildEnvCannotExportShellFunctions, TestRunVaultSecretCommandRefusesProtectedFieldBeforeSpawn, TestGitSubprocessesDoNotInheritCredentials (shim git records the environment it receives), TestUpdateValidationSubprocessesDoNotInheritCredentials.
  • Every new test was mutation-checked: it fails with the fix reverted and passes with it applied.

README.md and AGENTS.md document both rules.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 02:47
@ti-chi-bot ti-chi-bot Bot added the size/XL label Nov 17, 2026
@srstack
srstack requested review from mornyx and qiffang November 17, 2026 02:48
@srstack
srstack force-pushed the fix/vault-env-and-subprocess-credentials branch from 9202c85 to 1a34f1f Compare November 17, 2026 02:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

The change still has an unresolved mismatch between the stated behavior and the implementation in internal/fs/vault.go (line 642), where the code returns after the first forbidden key instead of deterministically reporting all rejected names as described, indicating remaining active issues to address before approval.

1 open issue
What changed in this PR

Hardens ti against environment-based subprocess attacks by blocking process-configuration vault field names for run-with-secret and ensuring sensitive credentials are scrubbed from selected subprocess environments.

Changes:

  • Reject vault fields whose normalized names match a process-configuration env var denylist before spawning the child.
  • Scrub credential-bearing environment variables from git and ti update validation/help probe subprocesses.
  • Add tests validating denylist behavior, pre-spawn refusal, and subprocess env scrubbing; update docs to describe the new rules.
File Description
README.md Documents the new run-with-secret vault field-name restrictions and their security rationale.
internal/​update/​update.go Updates ti update validation and helper-probe subprocesses to run under a credential-scrubbed environment while preserving required overrides.
internal/​update/​update_test.go Adds tests ensuring ti update validation/help-probe subprocesses do not inherit credential environment variables.
internal/​fs/​vault.go Introduces and enforces a normalized environment-key denylist for vault-derived child process environments in run-with-secret.
internal/​fs/​vault_secret_env_test.go Adds unit tests for forbidden/allowed vault field names, deterministic error messaging, and refusal before spawning a child process.
internal/​fs/​git.go Routes all git subprocess invocations through a scrubbed subprocess environment to prevent credential leakage.
internal/​fs/​git_subprocess_env_test.go Adds tests that shim git to verify credential variables are not passed into git subprocess environments.
internal/​credentialenv/​credentialenv.go Adds/standardizes a ScrubbedEnviron() helper for constructing subprocess environments without credential-bearing variables.
AGENTS.md Updates contributor/agent guidance to reflect the new subprocess environment-scrubbing and vault field-name security rules.

Review effort: Balanced

Comment thread internal/fs/vault.go Resolved
@srstack
srstack force-pushed the fix/vault-env-and-subprocess-credentials branch from 1a34f1f to a144c8e Compare November 17, 2026 03:00
@ti-chi-bot ti-chi-bot Bot added size/XXL and removed size/XL labels Nov 17, 2026

@qiffang qiffang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the vault read → normalization → validation → child spawn path, credential scrubber and platform matching, changed git/update subprocess sites, and regression tests. One blocking gap remains in the process-configuration filter, detailed inline.

Validation was static/source-based, including the official Lua startup contract; no local tests, child-process reproductions, or live service requests were executed. Current CI test and CLA checks pass. No sensitive information found in the submitted diff.

Comment thread internal/fs/vault.go Outdated
"_JAVA_OPTIONS": "Java startup",
"JAVA_OPTIONS": "Java startup",
"CLASSPATH": "Java class loading",
"LUA_INIT": "Lua startup",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Reject versioned Lua startup variables as executable configuration

LUA_INIT_5_4 is not in this exact-name table, survives normalizeVaultEnvKey unchanged, and its printable value passes control-byte validation. vaultSecretChildEnv then injects it into the child. When a consumer runs ti fs-vault run-with-secret ... -- lua script.lua with Lua 5.4 (without -E), Lua checks LUA_INIT_5_4 before LUA_INIT and executes its value before the requested script; this is the documented Lua standalone startup behavior. Thus a secret writer can still supply startup code through a field named LUA_INIT_5_4; even the harmless value print("vault-init") would execute despite LUA_INIT being forbidden. This leaves the exact code-execution boundary this PR intends to close open for a runtime already covered by the denylist. The versioned module-path variables LUA_PATH_5_4 and LUA_CPATH_5_4 likewise bypass the corresponding base-name entries. Please enforce the same startup/module-loading restriction for supported versioned names and cover them with regression tests, including normalization/case variants.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4a3cf, and generalized so the class cannot come back through another versioned spelling.

Denylist lookup now goes through vaultEnvKeyDenied: it checks the exact normalized name, then strips trailing all-digit segments (trimVaultEnvVersionSuffix, so LUA_INIT_5_4 -> LUA_INIT, LUA_PATH_5_4 -> LUA_PATH, LUA_CPATH_5_4 -> LUA_CPATH) and checks again. That covers every Lua release spelling instead of enumerating 5_1..5_4, and the suffix rule only applies to a denied base, so DB_URL_2 or LUA_VERSION stay injectable.

I also added the same-class runtime names I had missed: JDK_JAVA_OPTIONS (Java 9+ startup, next to JAVA_TOOL_OPTIONS), PHPRC / PHP_INI_SCAN_DIR (php.ini and scan-dir loading, e.g. auto_prepend_file), and RUBYGEMS_GEMDEPS (RubyGems dependency autoloading).

Tests: TestVaultSecretChildEnvRejectsProcessConfigurationKeys now includes LUA_INIT_5_4, lua_init_5_4, LUA_PATH_5_4, LUA_CPATH_5_1; TestVaultSecretChildEnvAllowsSecretLikeKeys pins LUA_VERSION, DB_URL_2, PGPASSWORD_5 as still allowed; TestTrimVaultEnvVersionSuffix pins the stripping edges (LUA_INIT_, _9LIVES, no-suffix names). The reject test fails if the version-suffix rule is disabled (mutation-checked). README and AGENTS document the version-segment rule. go vet ./... + go test ./... pass locally; CI is running on the new head.

@mornyx mornyx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

This PR hardens ti fs-vault run-with-secret against process-configuration environment variable injection and routes git and ti update validation subprocesses through a shared credentialenv.ScrubbedEnviron() helper. Multi-key deterministic error reporting from the earlier review round is cleanly resolved, and the credential-prefix scrubbing design is solid. Under a strict maintainability and security bar, one merge-blocking gap remains: modeling vaultEnvKeyDenylist purely as an exact-name lookup leaves pre-script and helper code-execution bypasses open in runtimes and tools the denylist explicitly covers (including the open thread item on versioned Lua startup variables, plus OpenJDK JDK_JAVA_OPTIONS, Git config/directory/diff variables, and CPython PYTHONUSERBASE). Separately, git subprocess construction in internal/fs can be simplified to eliminate open-coded env wiring, cover a missed dormant git call in fuse_git.go, and remove dead ti self-spawn code.

What looks good

  • Centralizing credentialenv.ScrubbedEnviron() with case-insensitive prefix matching (TIDB_CLOUD_*, TDC_*, DRIVE9_*, TI_FS_*, TI_VAULT_*) prevents scrub-list drift across Unix and Windows while keeping TI_PROFILE and test controls intact.
  • Enforcing vault.env_key_forbidden (exit 2) on normalized keys during run-with-secret—while keeping read-secret --format env readable—and reporting every rejected field in sorted order with per-variable explanations gives users a deterministic, actionable error without locking them out of existing secrets.
  • Regression tests use executable shims to assert the actual environment received by child processes and verify that run-with-secret refuses protected keys before spawning the child.

Blocking (please address before merge)

1. Exact-name-only vaultEnvKeyDenylist leaves code-execution bypasses in covered runtimes and tools (internal/fs/vault.go:550-653)
validateVaultEnvFields (internal/fs/vault.go:650) checks only vaultEnvKeyDenylist[key], which leaves direct startup and helper code-execution bypasses in families already inside this boundary:

  • Lua (internal/fs/vault.go:597-599): Standalone Lua 5.2+ (without -E) checks versioned LUA_INIT_<maj>_<min> (e.g. LUA_INIT_5_4) before LUA_INIT and executes inline Lua code or @file before the target script runs; LUA_PATH_5_4 and LUA_CPATH_5_4 likewise supersede LUA_PATH and LUA_CPATH. Fields such as LUA_INIT_5_4 or lua-init-5.4 survive normalizeVaultEnvKey and bypass the exact-name map.
  • Java (internal/fs/vault.go:593-596): JAVA_TOOL_OPTIONS and _JAVA_OPTIONS are blocked, but JDK_JAVA_OPTIONS—the standard OpenJDK 9+ launcher variable that prepends JVM options such as -javaagent:/path/evil.jar or @argfile before main (along with IBM_JAVA_OPTIONS / OPENJ9_JAVA_OPTIONS)—passes through.
  • Git (internal/fs/vault.go:605-617): GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, GIT_CONFIG_COUNT, GIT_TEMPLATE_DIR, and GIT_SSH_COMMAND are blocked, yet GIT_CONFIG_PARAMETERS (passes arbitrary config such as core.fsmonitor or core.sshCommand without needing GIT_CONFIG_COUNT), GIT_CONFIG_KEY_<N> / GIT_CONFIG_VALUE_<N> (effective whenever GIT_CONFIG_COUNT is set in the parent environment), GIT_EXTERNAL_DIFF (executed directly by git diff / git show / git log -p), and GIT_DIR / GIT_COMMON_DIR / GIT_WORK_TREE (pointing Git at an attacker-chosen .git/config and .git/hooks/) are allowed.
  • Python (internal/fs/vault.go:583-585): PYTHONPATH and PYTHONSTARTUP are blocked, but PYTHONUSERBASE is allowed; on default CPython startup (without -s/-S/-I), site scans <PYTHONUSERBASE>/lib/pythonX.Y/site-packages/*.pth and exec()s any line starting with import before the script runs (PYTHONBREAKPOINT similarly imports and calls an arbitrary callable on breakpoint()).

Suggested fix: Keep exact matching for broad prefixes so secret-like names (SSH_PRIVATE_KEY, GIT_TOKEN, PATH_EXTRA, LD_PRELOAD_BACKUP) remain usable, and replace the raw map lookup with a small forbiddenVaultEnvKey(key string) (controls string, blocked bool) helper that combines:

  1. Targeted pattern/prefix rules for versioned, indexed, or loader-only namespaces (LUA_INIT_<digits...>, LUA_PATH_<digits...>, LUA_CPATH_<digits...>, GIT_CONFIG_KEY_<digits>, GIT_CONFIG_VALUE_<digits>, DYLD_*, and _32/_64 or LD_32_* loader variants).
  2. Exact-name entries for JDK_JAVA_OPTIONS, IBM_JAVA_OPTIONS, OPENJ9_JAVA_OPTIONS, GIT_CONFIG_PARAMETERS, GIT_EXTERNAL_DIFF, GIT_DIR, GIT_COMMON_DIR, GIT_WORK_TREE, PYTHONUSERBASE, and PYTHONBREAKPOINT.

Please also cover versioned/indexed and normalized variants with regression tests and update the "exact name match" wording in README.md:53 and AGENTS.md:1164-1166 accordingly.

Should fix (non-blocking, strong)

2. Replace gitSubprocessEnv() with a single newGitCommand helper, cover fuse_git.go, and delete dead startGitHydrateBackground (internal/fs/git.go:1602-1623, internal/fs/fuse_git.go:196)

  • gitSubprocessEnv() (internal/fs/git.go:1602-1604) is a zero-argument one-line wrapper around credentialenv.ScrubbedEnviron() applied manually at individual exec.CommandContext sites, which missed (r *remoteFuseRuntime).gitReadFile in internal/fs/fuse_git.go:196 (exec.CommandContext(ctx, "git", "-C", repoRoot, "cat-file", "-p", objectSHA) still inherits os.Environ() verbatim; currently dormant because public mounts delegate to ti-drive9, but inconsistent with the AGENTS.md:1248-1252 rule).
  • startGitHydrateBackground (internal/fs/git.go:1606-1623) has zero callers anywhere in the repo and spawns os.Executable() (ti fs-git hydrate-git-workspace), not git—scrubbing TI_FS_TOKEN and TIDB_CLOUD_* there would strip env-only credentials if it were ever invoked.
  • Replacing gitSubprocessEnv() with a shared newGitCommand(ctx context.Context, args ...string) *exec.Cmd helper in package fs that sets cmd.Env = credentialenv.ScrubbedEnviron() in one place (used across internal/fs/git.go and internal/fs/fuse_git.go:196) makes unscrubbed git spawns impossible by construction and lets you delete the unreferenced startGitHydrateBackground from the 1,639-line internal/fs/git.go (updating AGENTS.md:1248 to match).

3. Cover adjacent native loader, OpenSSL, and CLR startup hooks in vaultEnvKeyDenylist (internal/fs/vault.go:568-602)
Several environment variables in the same threat class load attacker-chosen shared objects or startup assemblies into ordinary binaries before user code runs: OpenSSL config/engine/provider hooks read by TLS-linked tools (OPENSSL_CONF, OPENSSL_ENGINES, OPENSSL_MODULES), .NET startup/profiler hooks (DOTNET_STARTUP_HOOKS, CORECLR_PROFILER, CORECLR_PROFILER_PATH, COR_PROFILER, COR_PROFILER_PATH), ELF loader peers (LD_ORIGIN_PATH, GLIBC_TUNABLES), Windows PERL5SHELL, zsh/ksh FPATH, and SUDO_ASKPASS. Adding them alongside the item 1 updates closes obvious lateral bypasses in the same table.

Nits

  • internal/fs/vault.go:500-697: internal/fs/vault.go grew from 725 to 848 lines in this PR and will approach ~900 lines once pattern rules and extra entries are added. Moving the self-contained child-env normalization, denylist/pattern check, and env-merge helpers into internal/fs/vault_secret_env.go (alongside internal/fs/vault_secret_env_test.go) would keep vault.go focused on vault control/mount operations and comfortably below 1,000 lines.

Recommendation

Request changes. One verified blocking gap remains in the run-with-secret environment-key filter (LUA_INIT_5_4 and sibling versioned/indexed/runtime hooks bypass the exact-name denylist); please address before merge.

@srstack
srstack force-pushed the fix/vault-env-and-subprocess-credentials branch from a144c8e to 0c4a3cf Compare November 17, 2026 04:01
…dentials

Two findings from the security review of main 182fdc8.

1. `ti fs-vault run-with-secret` converted stored vault field names into child
   environment variables without any name restriction, so a field named
   `LD_PRELOAD`, `PATH`, `BASH_ENV`, or `NODE_OPTIONS` let whoever can write the
   secret choose what the child loads or executes. Such names now fail with
   `vault.env_key_forbidden` before the child is spawned, and the error lists
   every rejected field in sorted order with the behavior it would configure.

   Matching runs on the normalized key, so `path` and `PaTh` hit `PATH`; it is
   exact-name, so plausible secret names such as `SSH_PRIVATE_KEY`, `GIT_TOKEN`,
   or `LD_PRELOAD_BACKUP` stay injectable; it strips trailing all-digit version
   segments, so `LUA_INIT_5_4`, `LUA_PATH_5_4`, `LUA_CPATH_5_4`, and
   `LD_PRELOAD_32` resolve to their base entries; and it matches the families
   whose suffix the field name chooses by prefix (`DYLD_*`, `LD_32_*`, `LD_64_*`,
   `GIT_CONFIG_KEY_<n>`, `GIT_CONFIG_VALUE_<n>`). `read-secret --format env` still
   converts those names because it only prints values and never spawns a child.
   The denylist and the child-env construction moved to
   `internal/fs/vault_secret_env.go`.

2. `internal/credentialenv` existed but was not applied to every subprocess that
   inherits it: git invocations handed the credentials to git and to the hooks,
   clean/smudge filters, pagers, and helpers git runs, and `ti update` handed the
   TiDB Cloud keys and the filesystem bearer token to the staged ti binary and the
   downloaded companion it validates. Every git spawn now goes through
   `newGitCommand` (including the dormant native-FUSE reader) and `ti update`
   uses `credentialenv.ScrubbedEnviron()`; the unreferenced
   `startGitHydrateBackground` self-spawn is deleted rather than scrubbed, since
   it spawns ti itself and would lose env-only credentials if it ever ran.

Verification: gofmt, `go vet ./...` on linux/darwin/windows, `go test -count=1
./...`, `make e2e`. Each new test was mutation-checked: it fails on the pre-fix
code and passes with the fix.
@srstack
srstack force-pushed the fix/vault-env-and-subprocess-credentials branch from 0c4a3cf to a413bcf Compare November 17, 2026 04:05
@srstack

srstack commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both qiffang and mornyx on head a413bcf.

Blocking item — startup/helper bypasses (mornyx item 1, qiffang's Lua thread). The filter is no longer a bare map lookup. vaultEnvKeyDenied now checks the normalized key and, if that misses, the key with trailing all-digit version segments removed, and each candidate against the exact-name table plus a small prefix-family table:

  • version segments: LUA_INIT_5_4 → LUA_INIT, LUA_PATH_5_4 → LUA_PATH, LUA_CPATH_5_4 → LUA_CPATH, and LD_PRELOAD_32/LD_LIBRARY_PATH_64 → their base entries. This is generic, so future versioned spellings are covered without enumeration, and it only applies to a denied base (DB_URL_2 stays injectable).
  • prefix families whose suffix the field name chooses: DYLD_* (the whole namespace), LD_32_*, LD_64_*, GIT_CONFIG_KEY_<n>, GIT_CONFIG_VALUE_<n>.
  • new exact names: JDK_JAVA_OPTIONS, IBM_JAVA_OPTIONS, OPENJ9_JAVA_OPTIONS, GIT_CONFIG_PARAMETERS, GIT_EXTERNAL_DIFF, GIT_DIR, GIT_COMMON_DIR, GIT_WORK_TREE, PYTHONUSERBASE, PYTHONBREAKPOINT, OPENSSL_CONF, OPENSSL_ENGINES, OPENSSL_MODULES, DOTNET_STARTUP_HOOKS, CORECLR_PROFILER, CORECLR_PROFILER_PATH, COR_PROFILER, COR_PROFILER_PATH, GLIBC_TUNABLES, LD_ORIGIN_PATH, PERL5SHELL, FPATH, SUDO_ASKPASS (plus PHPRC, PHP_INI_SCAN_DIR, RUBYGEMS_GEMDEPS from the previous round).

Tests: TestVaultSecretChildEnvRejectsProcessConfigurationKeys now covers the versioned/prefixed/runtime-hook spellings (LUA_INIT_5_4, lua_init_5_4, LUA_PATH_5_4, LUA_CPATH_5_1, LD_PRELOAD_32, LD_LIBRARY_PATH_64, DYLD_PRINT_LIBRARIES, LD_32_PRELOAD, LD_64_LIBRARY_PATH, GIT_CONFIG_KEY_0, GIT_CONFIG_VALUE_0, and the new exact names); TestVaultSecretChildEnvAllowsSecretLikeKeys pins that LUA_VERSION, DB_URL_2, PGPASSWORD_5, GIT_DIR_BACKUP, and OPENSSL_CERT remain injectable; TestTrimVaultEnvVersionSuffix pins the stripping edges. Disabling the version-suffix rule makes the reject test fail (mutation-checked). README/AGENTS no longer say "exact name match" without the family and version rules.

Should-fix 2. gitSubprocessEnv() is gone; newGitCommand(ctx, args...) *exec.Cmd sets the scrubbed environment in one place and every git spawn uses it, including internal/fs/fuse_git.go. The unreferenced startGitHydrateBackground is deleted rather than scrubbed — you were right that it spawns ti, not git, so scrubbing would have removed env-only credentials if it ever ran (dead code was the actual defect).

Should-fix 3. All the loader/OpenSSL/CLR/shell entries you listed are in the table.

Nit. The env cluster (normalizeVaultEnvKey, normalizedVaultFieldMap, renderVaultEnv, the denylist and family tables, vaultEnvKeyDenied/trimVaultEnvVersionSuffix, validateVaultEnvFields, mergeEnv, vaultSecretChildEnv, the platform fold seam, and runVaultSecretCommand) moved to internal/fs/vault_secret_env.go; vault.go drops from 848 to 519 lines.

Verification at a413bcf: gofmt clean, go vet ./... on linux, GOOS=windows and GOOS=darwin clean, go test -count=1 ./... passes, make e2e passes. CI is running on the new head.

@mornyx mornyx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

All blocking, structural, and maintainability findings from the previous review round are cleanly resolved on a413bcf. vaultEnvKeyDenied in internal/fs/vault_secret_env.go now pairs the expanded normalized denylist with trailing all-digit version-segment stripping (trimVaultEnvVersionSuffix) and targeted prefix families (DYLD_, LD_32_, LD_64_, GIT_CONFIG_KEY_, GIT_CONFIG_VALUE_), closing the versioned/indexed startup and helper bypasses while keeping legitimate secret names injectable. Every git subprocess now goes through newGitCommand (including internal/fs/fuse_git.go), the unreferenced startGitHydrateBackground helper is gone, and extracting internal/fs/vault_secret_env.go leaves internal/fs/vault.go compact at 519 lines under a strict maintainability bar.

What looks good

  • vaultEnvKeyDenied + trimVaultEnvVersionSuffix + vaultEnvKeyFamilies handles versioned (LUA_INIT_5_4, LD_PRELOAD_32) and indexed/namespace (DYLD_*, LD_32_*, GIT_CONFIG_KEY_*) process-configuration keys cleanly without rejecting numbered secret names such as DB_URL_2 or PGPASSWORD_5, while still reporting the caller's normalized keys in deterministic sorted order.
  • Centralizing git subprocess construction in newGitCommand across internal/fs/git.go and internal/fs/fuse_git.go eliminates per-callsite cmd.Env drift by construction, and credentialenv.ScrubbedEnviron() remains the single case-insensitive credential denylist shared with ti update and run-with-secret.
  • Splitting the self-contained child-environment normalization, denylist/family matching, and execution logic into internal/fs/vault_secret_env.go pairs directly with internal/fs/vault_secret_env_test.go and keeps internal/fs/vault.go focused on vault control and mount operations.

Nits

  • internal/fs/vault_secret_env.go:152-157: vaultEnvKeyDenylist still enumerates six individual DYLD_* keys (DYLD_INSERT_LIBRARIES through DYLD_IMAGE_SUFFIX) with "the dynamic loader", which are completely shadowed by {"DYLD_", "the dynamic loader"} in vaultEnvKeyFamilies (internal/fs/vault_secret_env.go:304). Dropping those six entries would keep vaultEnvKeyFamilies as the single source of truth for the DYLD_ namespace.

Recommendation

Approve. All blocking and should-fix items are verified resolved with comprehensive regression tests and updated documentation; only an optional deduplication nit remains.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants