Skip to content

Enable log scrubbing by default - #2725

Merged
ryankeithster merged 5 commits into
microsoft:mainfrom
ryankeithster:msrc107671-scrublogs-default
May 12, 2026
Merged

Enable log scrubbing by default#2725
ryankeithster merged 5 commits into
microsoft:mainfrom
ryankeithster:msrc107671-scrublogs-default

Conversation

@ryankeithster

Copy link
Copy Markdown
Contributor

Summary

Addresses security concerns related to the logging of environment variables, which could potentially contain sensitive information, in cleartext to ETW traces and log files by enabling scrubbing of this information from the logs by default.

Changes

Default scrubbing ON (internal/log/scrub.go)

  • Added init() that sets scrubbing enabled by default, eliminating the need for explicit opt-in via config
  • Added ScrubCreateOptions() to scrub the OCI spec (env vars + annotations) within CreateOptions logged during container creation

Proto: three-state ScrubLogs field (cmd/containerd-shim-runhcs-v1/options/runhcs.proto)

  • Changed bool scrub_logs = 20optional bool scrub_logs = 20
  • Enables distinguishing "not set" (nil → default scrub ON) from "explicitly false" (opt-out)
  • Backward compatible: old containerd omits zero-value bools on the wire → new shim sees nil → scrubbing stays ON

Shim consumers updated for *bool semantics

  • cmd/containerd-shim-runhcs-v1/serve.go: Only disables scrubbing if ScrubLogs is explicitly *false
  • cmd/containerd-shim-lcow-v2/main.go: Same pattern
  • internal/builder/vm/lcow/kernel_args.go: Passes -scrub-logs=false to GCS only if explicitly disabled; otherwise always passes -scrub-logs
  • cmd/gcs/main.go: Changed --scrub-logs flag default from false to true

New scrub coverage (internal/hcsoci/create.go, internal/log/format.go)

  • initializeCreateOptions now scrubs env vars and annotations before logging via new FormatScrub helper
  • Previously logged the full OCI spec in cleartext at debug level

@ryankeithster
ryankeithster requested a review from a team as a code owner May 6, 2026 22:50
@ryankeithster

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

Ryan Keith (from Dev Box) added 2 commits May 6, 2026 17:17
Signed-off-by: Ryan Keith (from Dev Box) <ryankeith@microsoft.com>
Signed-off-by: Ryan Keith (from Dev Box) <ryankeith@microsoft.com>
@ryankeithster
ryankeithster force-pushed the msrc107671-scrublogs-default branch from c60931d to 7cd244c Compare May 7, 2026 00:18

@helsaawy helsaawy 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.

nits with log package change, but lgtm overall

Comment thread internal/hcsoci/create.go Outdated
Comment thread internal/log/format.go Outdated
Signed-off-by: Ryan Keith (from Dev Box) <ryankeith@microsoft.com>
Comment thread internal/builder/vm/lcow/kernel_args.go Outdated
Ryan Keith (from Dev Box) added 2 commits May 8, 2026 13:25
Signed-off-by: Ryan Keith (from Dev Box) <ryankeith@microsoft.com>
Signed-off-by: Ryan Keith (from Dev Box) <ryankeith@microsoft.com>
@ryankeithster
ryankeithster merged commit 1e20768 into microsoft:main May 12, 2026
57 of 61 checks passed
samuelkarp added a commit to samuelkarp/containerd that referenced this pull request Jul 24, 2026
The io.containerd.runhcs.v1 shim can scrub sensitive information from
logs it emits. Since v0.15.0-rc.2 this is done by default, but older
branches still require the option to be explicitly enabled. Explicitly
enable the scrubbing by default for the CRI configuration.

See also: microsoft/hcsshim#2725

Google-Bug-Id: 481375460
Signed-off-by: Samuel Karp <samuelkarp@google.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.

3 participants