Skip to content

Redact environment variable values in vminitd debug logs#813

Open
vyncint wants to merge 1 commit into
apple:mainfrom
vyncint:fix/redact-env-in-vminitd-logs
Open

Redact environment variable values in vminitd debug logs#813
vyncint wants to merge 1 commit into
apple:mainfrom
vyncint:fix/redact-env-in-vminitd-logs

Conversation

@vyncint

@vyncint vyncint commented Jul 24, 2026

Copy link
Copy Markdown

Fixes #518.

What

vminitd logs the full OCI spec / exec process at debug level in ManagedContainer ("created bundle with spec …", "creating exec process with …"), which dumps every NAME=value environment entry into the boot log. Environment variables routinely carry secrets, so container logs --boot web | grep PASSWORD reproduces the leak exactly as described in #518.

This PR adds redactingEnvironmentValues() to ContainerizationOCI's Spec, Process, Hook, and Hooks — it returns a copy with every env value replaced by <redacted> while keeping the variable names (still useful for debugging which variables were set), leaving NAME-only inherit entries untouched — and uses it at both log sites. With this change the same repro shows MY_SUPER_SECRET_PASSWORD=<redacted>.

The helper lives in ContainerizationOCI (rather than privately in vminitd) so host-side users of the framework who log specs get the same tool; it's a small additive API with doc comments. These two vminitd sites are the only places in the repo that interpolate a whole Spec/Process into a log message (the gRPC handlers only log IDs and ports).

Verification

  • New SpecRedactionTests (4 tests) cover: values masked / names kept, NAME-only entries passed through, NAME= and values containing = fully masked, hooks' env masked, non-env fields untouched, originals unmutated, and — mirroring the issue directly — that the rendered string no longer contains the secret values.
  • Full ContainerizationOCITests suite passes (53 tests).
  • make vminitd cross-compiles cleanly against the pinned Swift 6.3 static Linux SDK with warnings-as-errors, so both edited log sites are type-checked for the Linux target.
  • swift format lint --strict clean on all touched files.

Per the AI contribution guidelines: this change was developed with AI assistance (Claude Code); every line has been reviewed, and the reasoning above is the complete justification for each change.

🤖 Generated with Claude Code

vminitd logged the full OCI spec/process at debug level, exposing secrets passed through environment variables (apple#518). Add redactingEnvironmentValues() to ContainerizationOCI's Spec, Process, Hook, and Hooks - masking values while keeping variable names - and use it at both log sites in ManagedContainer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

[Bug]: vminitd logs can expose environment variable secrets

1 participant