Skip to content

Enable log scrubbing by default#2724

Closed
ryankeithster wants to merge 1 commit intomicrosoft:mainfrom
ryankeithster:msrc107671-scrublogs-default
Closed

Enable log scrubbing by default#2724
ryankeithster wants to merge 1 commit intomicrosoft:mainfrom
ryankeithster:msrc107671-scrublogs-default

Conversation

@ryankeithster
Copy link
Copy Markdown

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 20:24
@ryankeithster ryankeithster deleted the msrc107671-scrublogs-default branch May 6, 2026 21:12
@ryankeithster ryankeithster restored the msrc107671-scrublogs-default branch May 6, 2026 22:47
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.

1 participant