Repository navigation
π fix(logread): redact an own secret value in its JSON-escaped form - #16914
hivecommons-hive[bot] merged 2 commits into
Conversation
The read-time secret scrubber replaces each of the hive's own secret values in its plain, URL-encoded and base64 forms. The hive log, the request log and the output sources are JSON, so a value that holds a quote, a backslash or a control character is on disk only JSON-escaped, and none of those forms matched it: the value was returned readable. secretForms now also yields the value as written inside a JSON string, with and without HTML escaping. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Looks correct to me; one small doc suggestion.
Read src/crux/logread/secrets.go at 4a21f49. jsonEscapedForms (line 98) feeds secretForms, and NewSecretScrubber (lines 31-62) already dedups forms through a set and orders the replacer longest-first, so a value with nothing to escape gains no duplicate entry and the escaped form of a value that does cannot be shadowed by a shorter one. log/slog's JSON handler escapes strings the way encoding/json does with HTML escaping off, so the escapeHTML=false form matches the hive log exactly and the true form covers the encoding/json-written output sources; the test matrix (quote/backslash, control chars, <>&, non-ASCII) exercises both.
Suggestion, not a defect: the SecretScrubber type comment at secrets.go:20-22 still says the replacer covers "plain, URL-encoded and base64 forms". Worth adding "JSON-escaped" there to match the admin-mcp.md paragraph this PR updates, since that comment is the first thing the next reader sees.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
4a21f49
βΉοΈ Sentinel notice β informational; author is trusted (owner), merge is not blockedHive flagged this PR (author @Danathar, head
Hive did not add the |
Review suggestion on this PR: the SecretScrubber comment still listed the plain, URL-encoded and base64 forms only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
Done in the latest commit: the |
There was a problem hiding this comment.
Read the change against crux/logread/secrets.go on v6; it slots cleanly into the existing form-set mechanism and I found no defect.
Verified
NewSecretScrubber(secrets.go:30-61) dedupes forms through amap[string]booland sorts longest-first before building thestrings.Replacer, so for a value with nothing to escape the two new forms collapse into the existing plain one (asTestJSONEscapedFormsAddNothingForPlainValuesasserts) and no duplicate pair reaches the replacer. TheMinSecretValueLenfilter is applied per form, same as the URL/base64 forms.Replace(:66-75) counts markers in output minus input, so the JSON forms don't change the counting contract.- The JSON form produced by
encoding/jsonmatches whatlog/slog's JSON handler writes:appendEscapedJSONString($GOROOT/src/log/slog/json_handler.go:185) uses the non-HTMLsafeSet, short escapes for\n \r \t, and\u00XXfor other control bytes β the same asSetEscapeHTML(false); theSetEscapeHTML(true)form covers records written by plainjson.Marshal. The test suite writes through the real slog handler, so this is exercised rather than assumed. go build ./crux/logread/onef9e202is clean; CI is green apart from pending tide. Design doc paragraph and changelog fragment updated with the diff.
Looks correct to me.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Reviewed by Reviewer notesRead
No findings from any perspective. |
Summary
log_readredacts the hive's own secret values (the dashboard token, secret files, secret-named environment values) before it returns log lines. It missed a value that contains a quote, a backslash or a control character, so that value came back readable. This PR redacts it. Values made only of letters, digits and ordinary punctuation were always redacted.What went wrong
The logs are stored as JSON. A value such as
pa"ss\word-0123456789is therefore on disk aspa\"ss\\word-0123456789. The redaction looked for each secret in its plain, URL-encoded and base64 forms. None of them matches the JSON-escaped text:This matters for passwords more than for tokens, which rarely contain such characters. Reading logs needs the read-write role.
What changes
The redaction also looks for each value as it is written inside a JSON string, with and without HTML escaping. Nothing else about the scrubbing changes, and ordinary text is not affected.
Files
src/crux/logread/secrets.go:secretFormsaddsjsonEscapedForms.src/crux/logread/secret_json_form_test.go: new.src/docs/design/admin-mcp.md: the "Scrubbing" paragraph lists the form.changelog.d/security-logread-secret-json-escaped.mdTests
TestOwnSecretIsRedactedInItsJSONEscapedForm: six values written through the real slog JSON handler and read back withRead.TestOwnSecretIsRedactedInHTMLEscapedJSONTestJSONEscapedFormsAddNothingForPlainValues./crux/logread/package passes.π€ Generated with Claude Code