Redact environment variable values in vminitd debug logs - #813
Conversation
|
Can you rebase on |
cec005d to
50f7722
Compare
|
Rebased onto The rebase was content-free: Two things worth flagging, both my doing:
|
|
Hi @crosbymichael, Following up on the rebase. Both workflows are still at action_required on That approval is the only thing blocking. No rush, just flagging it. |
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.
5424632 to
c339953
Compare
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 everyNAME=valueenvironment entry into the boot log. Environment variables routinely carry secrets, socontainer logs --boot web | grep PASSWORDreproduces the leak exactly as described in #518.This PR adds
redactingEnvironmentValues()toContainerizationOCI'sSpec,Process,Hook, andHooks— it returns a copy with every env value replaced by<redacted>while keeping the variable names (still useful for debugging which variables were set), leavingNAME-only inherit entries untouched — and uses it at both log sites. With this change the same repro showsMY_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 wholeSpec/Processinto a log message (the gRPC handlers only log IDs and ports).Verification
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.ContainerizationOCITestssuite passes (53 tests).make vminitdcross-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 --strictclean 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.