Skip to content

vminitd: Scrub envvars printed in debug log#521

Draft
dcantah wants to merge 1 commit intoapple:mainfrom
dcantah:vminitd-log-scrub
Draft

vminitd: Scrub envvars printed in debug log#521
dcantah wants to merge 1 commit intoapple:mainfrom
dcantah:vminitd-log-scrub

Conversation

@dcantah
Copy link
Member

@dcantah dcantah commented Feb 7, 2026

Closes #518

We print the OCI spec at debug level, and this can contain sensitive info in envvars specifically. Lets redact the values in the envvars before we print. I went the route of just redacting everything as trying to check against some "possibly sensitive looking vars" seems rife for never getting it fully right.

This is what the envvars look like after the change: env: ["PATH=<redacted>", "HOME=<redacted>"]

This does make debugging worse, but that's the tradeoff.

We print the OCI spec at debug level, and this can contain sensitive
info in envvars specifically. Lets redact the values in the envvars
before we print. I went the route of just redacting everything as
trying to check against some "possibly sensitive looking vars" seems
rife for never getting it fully right.

This is what the envvars look like after the change:
env: ["PATH=<redacted>", "HOME=<redacted>"]

This does make debugging worse, but that's the tradeoff.
@dcantah dcantah marked this pull request as draft February 8, 2026 03:35

/// Redacts environment variable values from a list of env vars in "KEY=VALUE" format.
/// Returns the env vars with values replaced by "<redacted>".
func redactEnvValues(_ env: [String]) -> [String] {
Copy link
Contributor

@manojmahapatra manojmahapatra Feb 8, 2026

Choose a reason for hiding this comment

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

Question: I was reading the Docker Compose secrets docs and wondered, should we adopt a policy of never logging any env/argv values (even at debug), that is always redact env + args/commandLine? Or is the intent to only redact env and leave argv visible for debugging?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question. We should clearly understand where app secret values could be stored at rest:

  • .env files or anything similar - these are owned by the user so container has no responsibility for them.
  • Container configuration files in the application data store. In Docker, it appears that these are stored as plaintext under /var/lib/docker.
  • boot logs - perhaps redact entirely, or log them at trace level (which means we shouldn't see them until we add log level control, at which time we could emit a warning if trace is selected)
  • application logs - the user's responsibility

Copy link
Contributor

@manojmahapatra manojmahapatra Feb 8, 2026

Choose a reason for hiding this comment

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

yeah, I agree w/ the boot logs part which are written today by default. As you said gate boot logs and if I'm thinking it right;
(1) dont set config.bootLog = BootLog.file(...) by default
(2) only write boot logs if the user explicitly asks?
(3) move sensitive guest logs to trace by making the spec/argv logs trace-level.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should emit boot logs always, it's too useful for diagnostics. I think John meant redact the container configs in them entirely possibly

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, I see what you mean. yeah, config only redaction will be a balanced approach.

Copy link
Contributor

@jglogan jglogan left a comment

Choose a reason for hiding this comment

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

Perhaps we do a log level check and log only env variable names at all levels but trace, and log everything at trace.

Right now I don't think it's possible to set anything but info or debug in container. Should we allow trace logging there we can emit a warning on system start.

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

3 participants