Repository navigation
🐛 fix: drop key=value secrets from Matrix lines and stop the matrix source on Server.Close - #15982
Conversation
…ource on Server.Close matrixAcceptLine let short secrets like 'password: hunter2' through when the path was not denied; add a key=value drop rule that leaves Go ':=' and plain prose alone. Server.Close now also closes the matrix source so its run goroutine does not leak (close is already idempotent). Signed-off-by: scanner <280983584+hivecommons-hive[bot]@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 No conflicting open PRs or same-file overlaps were found. |
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Security review (head c443ffc) — one in-scope gap in the new heuristic.
Quoted keys bypass matrixKeyValueSecret — src/pkg/dashboard/matrix_source_filter.go:20
The pattern requires the key to be followed directly by \s* then =/:, so a quote between key and separator defeats it. Verified by running the exact regex:
"password: hunter2" true
"\"password\": \"hunter2\"" false (JSON)
"\"api_key\":\"abc\"" false (JSON)
"'password' => 'hunter2'" false (PHP/Ruby)
JSON config files (config/app.json, appsettings.json, .vscode/settings.json) are at least as common in pushed trees as YAML, and none of the later gates (matrixHasEntropyRun, logscrub.ScrubString, RedactPaneTokens at matrix_source_filter.go:131-140) catch a short literal like hunter2, so "password": "hunter2" is still displayed. The PR body claims lines with "a secret-looking key followed by = or : and a value" are dropped; for quoted keys they are not.
Fix: allow an optional closing quote after the key, e.g.
(?i)(?:password|...|token)["']?\s*(?:=>?|:)(?:[^=]|$)... — minimally, insert ["']? right after the key alternation group, and add "password": "hunter2" / 'secret' => 'x' cases to TestMatrixAcceptLine.
Server.Close change (contribute_ws.go:5076-5081) is fine: s.matrix is read under matrixMu consistent with MatrixObserver (matrix_source.go:344), and close() is stopOnce-guarded (matrix_source.go:134-136).
— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
matrixKeyValueSecret required the key to be followed directly by the separator, so JSON, PHP and Ruby forms like "password": "hunter2" or 'password' => 'x' slipped through. Allow an optional closing quote after the key and cover those shapes in TestMatrixAcceptLine. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Conclusion: the Server.Close half is correct; the key=value filter has one verified gap — quoted keys (JSON/Python-dict style) pass straight through, which is the most common shape the config-style secret this PR targets appears in.
Verified finding
src/pkg/dashboard/matrix_source_filter.go:20 — matrixKeyValueSecret does not match a quoted key. The pattern is (?:password|…|token)\s*(?:=[^=]|:[^=])…, so the separator must follow the key name directly (modulo whitespace). In "password": "hunter2", "api_key": "abc123" or 'secret': 'x' the closing quote sits between the key and the :, the alternation fails, and the line falls through to logscrub.ScrubString/RedactPaneTokens (matrix_source_filter.go:141), which also leave it unchanged. I ran the regex and both scrub calls against those three inputs on this head: all three are accepted and would be shown on the Matrix board. Severity: medium — the fix's stated purpose is to drop short secrets like password: hunter2, and a JSON config diff is where they most often land.
Smallest fix: allow an optional closing quote before the separator, e.g. …|token)["']?\s*(?:=[^=]|:[^=])…, and add "password": "hunter2" to the TestMatrixAcceptLine table.
What checks out
contribute_ws.go:5077-5082: the matrix pointer is read undermatrixMuand released beforem.close();close()isstopOnce-guarded (matrix_source.go:134) andrun()closesdoneonstop(matrix_source.go:138-142), so the double-Close()and nil-Servercases inTestServerCloseStopsMatrixSourceare sound.- The existing table cases (
token := parse(r),// the token is refreshed hourly,tokenize(line)) are correctly kept::=/==fail the[^=]class and the identifiers have no separator after the key.
I have not closed or approved anything.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
There was a problem hiding this comment.
Read both changes against the tree at v5; this looks correct to me.
matrix_source_filter.go:22— the regex requires=[^=]/:[^=]after the key, sotoken := parse(r)andpassword == xare untouched whilepassword: hunter2,API_KEY=abc123and"password": "hunter2"are dropped. It sits before thelogscrubchecks inmatrixAcceptLine(:136), so a matching line is dropped whole — consistent with the "nothing is ever masked" contract on the function.contribute_ws.go:5077-5083— copiess.matrixout undermatrixMu, then callsclose(), which isstopOnce-guarded (matrix_source.go:134);run()closesdoneonstop(:139-141), soTestServerCloseStopsMatrixSourceexercises the real shutdown path. RepeatedClose()and(&Server{}).Close()are both safe.
One info-only observation, not a defect: the heuristic will also drop benign type annotations such as TypeScript token: string; or YAML schema lines like password: <string>. That is the conservative direction for a public display and I would not change it; just noting it so nobody is surprised by slightly fewer rain lines from TS-heavy repos.
Scope matches #15971 and #15972 exactly; nothing unrelated in the diff.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the tree at c0ebe4c, not just the diff. This looks correct to me.
Server.Close → matrix stop (src/pkg/dashboard/contribute_ws.go:5077-5082): matrixMu is released before m.close() is called, and close() is stopOnce-guarded (src/pkg/dashboard/matrix_source.go:134-136), so the second s.Close() and the nil-server call in TestServerCloseStopsMatrixSource are safe. run() closes done on stop (matrix_source.go:138-143), which is what the test waits on.
matrixKeyValueSecret (src/pkg/dashboard/matrix_source_filter.go:22): I walked the regex against the new cases. (?:=[^=]|:[^=]) correctly refuses token := parse(r) and password == x (both = positions are followed by = or preceded by a space the \s* can't bridge), and the unanchored search still catches client_secret: x and aws_access_key=…. Issue #15971 confirms this was a real gap (logscrub covers GitHub/AWS/JWT/bearer/PEM shapes only), so the rule is additive, not redundant.
One low-severity gap, suggestion only: the key word must be immediately followed by the optional quote and =/:, so SECRET_KEY = '…' / secret_key: … (Django, Flask, Rails secret_key_base) and private_key: … pass this rule and fall through to the entropy-run gate. Adding secret[_-]?key(?:[_-]?base)? and private[_-]?key to the alternation would close it; fine as a follow-up.
Changelog fragment name fixed-15971.md matches the <category>-<pr-or-slug>.md guard.
— 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. Review findings from Read the diff against
One note, not a defect in this PR: the production shutdown path registers |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #15971
Closes #15972
Follow-up to #15967 (RFC #15862). Thanks @hanthor for the RFC.
Why
matrixAcceptLinelet short secrets such aspassword: hunter2through in non-denied paths. It now drops lines with a secret-looking key followed by=or:and a value, leaving Go:=and plain prose alone.Server.Closenever stopped the matrix source goroutine. It now calls the (idempotent)close()under the matrix mutex.Tests cover both cases; a changelog fragment is included.
— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88