Repository navigation
[worker] Mask secrets in every field of uploaded log records - #4698
Merged
Merged
Conversation
The upload transform masked only each record's msg, so a serialized err
(message, stack and other fields) was uploaded with secrets intact. That
includes unknown build phase failures, which log { err } with an empty msg.
Mask the strings inside err on a copy, since bunyan shares the record with
other streams.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4698 +/- ##
==========================================
+ Coverage 75.25% 75.30% +0.05%
==========================================
Files 1053 1053
Lines 52045 52174 +129
Branches 11357 11395 +38
==========================================
+ Hits 39162 39283 +121
- Misses 11895 11903 +8
Partials 988 988 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Mask all fields except bunyan's metadata, not only err: other fields such as error, data and the job dump also carried secrets. Round-trip each value through JSON first so a toJSON method can't bring back the original, mask keys and numbers, and replace values nested too deeply instead of uploading them unmasked.
|
✅ Thank you for adding a changeset! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The worker masks job secrets in uploaded logs, but only in each record's
msg(createTransformStreaminpackages/worker/src/logger.ts). Every other field was uploaded as is, for example:err(message,stack, …). Unknown failures inside a build phase are logged asthis.logger.error({ err }, '')(packages/build-tools/src/context.ts:310), so their cause, secrets included, is only inerr. A comment there says the website displayserr.stackfor these records.{ error }inreportMaestroTestResults.ts,{ code, data }inrestoreCache.ts, and the job dump atbuild.ts:48, which can contain a copy of a secret's value.Found while making
eas simulator:start/simulator:getshow why a session failed (#4693, #4694). The CLI prints only the maskedmsgfor this reason.How
name,pid,level,time,v,phase,source,marker,result,buildStepId,buildStepInternalId).toJSONmethod can't bring back the original value, and aDatebecomes its string form;[Truncated]instead of being uploaded unmasked;[Unserializable].WorkerLogBufferand the caller's objects are left alone.context.ts:310. Fillingmsgfor phase failures would change what the website shows, which is a separate decision.Test Plan
src/__unit__/logger.test.ts. For every record they assert thatJSON.stringify(record)contains no secret. Cases:error({ err }, '')anderror({ err })haveerr.messageanderr.stackmasked;toJSONmethod that returns a secret is masked;[Truncated].err) fails one of these tests.packages/workerunit tests: 85 pass.yarn typecheck(worker),oxlintandoxfmt --checkpass.🤖 Generated with Claude Code