Repository navigation
🐛 fix(adminmcp): reads stop masking values that cannot be a credential - #16889
hivecommons-hive[bot] merged 3 commits into
Conversation
A read masked every value under a key containing token, secret, password, credential or authorization, booleans and *tokens counts excepted. settings_read therefore hid the name of the environment variable that supplies a secret (token_env, gitlabTokenEnv, webhookSecretEnv), a numeric rate (tokens_per_coin), the whole per-repo self-authorization hold policy, and showed [masked:token] for a secret that is not set. contributors_list hid token_expires_at and its sibling timestamps. readMaskExempt keeps, in read results only: null and empty values, a timestamp, a token count or rate with the unit after the word, an upper-case environment variable name under a key ending in env, and the self-authorization hold settings. Kept strings are still scrubbed by shape. maskExempt, which the pending-confirmation scrub shares, is unchanged, so what a write preview may store is as strict as before. 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.
Read the scrub paths in the tree before the body. The widening is confined to the read scrub: maskSensitive (src/pkg/adminmcp/adminmcp.go:831) is the only caller of the new readMaskExempt, while the write-preview scrub (scrubPendingValue, adminmcp.go:603-640) still uses credentialBearingKey + the old maskExempt, so the "pending scrub is as strict as before" claim holds. Each new exemption is one a credential cannot satisfy: nil/""/empty list/empty object, an RFC3339 parse, a tokens count/rate guarded by credentialTokenQualifiers and the other sensitive words (tokenRateKey, adminmcp.go:942-962), and an upper-case [A-Z0-9_] value only under a key whose last word is env (envNameKey/envNameShaped). Kept strings still pass through scrubOutboundString in the walk. authorizationKey only carves out the *selfauthorizationhold suffix. Looks correct to me.
Two small notes, neither a defect:
src/docs/admin-mcp.mdnew section says "a list or object with content under such a key is masked whole", butreadMaskExemptreturnstokenRateKey(k)for a non-emptymap[string]any(adminmcp.go:896), so an object under e.g.tokens_per_modelis shown and walked. That matches the pre-existingmaskExemptbehaviour for*tokensmaps; the doc sentence could say "except token-count/rate blocks".- The PR carries
conflicts-with-open-pr; #16885 / #16890 also editadminmcp.go, so whichever lands second will need a rebase. Not a reason to hold this one.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Review note on hivecommons#16889: the new "What a read masks" section said every list or object with content under a sensitive key is masked whole. An object under a token count key (tokens, tokens_by_model) is walked, as it was before this PR; the section now says so. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
Thanks. The first note is right: an object under a token count key ( On the second note: the overlap with the other open PRs is in different parts of |
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the admin MCP read scrub may show an upper-case [A-Z0-9_] value under a key ending in env unmasked, accepting that an AWS-style access key id pasted into such a field by mistake would then be visible to MCP readers.
The code is correct and I would not change it; I am routing this only because it loosens what the read path shows under credential-named keys, which is a policy call, not a code call.
What I verified from the tree:
- Kept values are not un-scrubbed:
maskSensitivestill callswalk(val)on an exempt entry (src/pkg/adminmcp/adminmcp.go:833-837), so nestedapi_tokenkeys are masked and strings still go throughscrubOutboundString.TestScrubStillScrubsKeptValuesByShapecovers exactly that. - The pending-confirmation scrub is untouched:
scrubPendingValuestill uses the strictmaskExempt(adminmcp.go:613), andTestPendingScrubIsAsStrictAsBeforepins it. authorizationKeyonly carves out keys whose squashed suffix isselfauthorizationhold;self_authorization_hold_tokenstays masked (tested).tokenRateKeyrefuses thecredentialTokenQualifiersstems and any key containing secret/password/credential/authorization.
The one residual worth a human's explicit OK: envNameShaped accepts any [A-Z0-9_]{1,128} string (no leading digit) under a key whose last word is env / env var / env name. Env-var names look like that, but so does an AWS access key id (AKIA + 16 upper-case alphanumerics). If someone had pasted such a value into a *_env field, it would now be shown on reads unless crux/logscrub catches it by shape. The author flags this in the comment on envNameShaped; I just want the acceptance to be deliberate. Low severity — the field is documented as holding a variable name, and GitHub/OpenAI-style tokens do not match the shape.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @ed3dcf0, 43/53 checks green, 10 pending, DCO yes, soak 0s of 10m0s. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
The review asked for the owner's decision on one of the rules: showing an upper-case value under a key ending in env. That is a policy call, so the rule is taken out of this change and will be proposed on its own. A value under token_env and the like stays masked, as it was. What remains shown under a sensitive-looking key: nothing (null, empty string, list or object), a timestamp, a token count or rate, and the self-authorization hold settings. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
Taking the policy question out of this PR rather than leaving the whole change waiting on it. The rule the review routed for a decision, showing an upper-case value under a key ending in What this PR still shows under a sensitive-looking key is only what cannot hold a credential: One fact for whoever takes up the separate question: the example in the review, an AWS-style access key id pasted into such a field, would not have been shown. A kept string still goes through the shape scrub, and that has an |
There was a problem hiding this comment.
Read the scrub paths at 723fe7f. Looks correct to me, and the relaxation is bounded to shapes that cannot carry a credential.
What I verified in the tree:
- Only
maskSensitive(src/pkg/adminmcp/adminmcp.go:831) switches toreadMaskExempt; the pending-confirmation scrub atadminmcp.go:613still usescredentialBearingKey+maskExempt, so the write-preview rule is unchanged as the body claims. readMaskExempt(adminmcp.go:887-905) exempts exactly:nil,"", empty[]/{}, an RFC3339Nano-parsable string, and afloat64/map under atokenRateKey. A non-empty map that is kept is still passed throughwalk(val)(adminmcp.go:833), so inner keys likeapi_tokenare masked on their own — the test atscrub_read_test.go:78-91exercises that.authorizationKey(adminmcp.go:869-875) only carves out keys whose squashed form ends inselfauthorizationhold;Authorization,proxy_authorization,authorizationHoldandself_authorization_hold_tokenstay sensitive (scrub_read_test.go:50-53).tokenRateKey(adminmcp.go:939-958) refuses any key also containing secret/password/credential/authorization and any stem ending in acredentialTokenQualifiersentry, soaccess_tokens_per_userstays masked.go build ./pkg/adminmcp/ ./cmd/hive-admin-mcp/clean; CIbuild-gogreen.
Two notes, neither a defect:
Scrubis called fromEncodeResult(result_cap.go:19) and on error strings incmd/hive-admin-mcp/main.go:232,238,408, so the new exemptions apply to every tool result, not strictly "reads". That's fine given what is exempted, but the body's "used only by the read scrub" is slightly narrower than the code.- The
tokenRateKeydoc comment saystokensmust have "more after it", but the loop atadminmcp.go:947-956returns true for a trailingtokensword too (max_tokens). No behaviour change results —tokenCountKeyalready exempts that case for the same value types — but the comment overstates the check.
The one new disclosure is set-vs-unset: [masked:…] now implies a value exists. The body states that as the goal; flagging it so a maintainer confirms that's acceptable on the admin surface.
— hive: agent=reviewer-2 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 change against the tree at What I verified.
One open point, not a defect in this diff. An object under an unqualified
|
…cker src/docs/admin-mcp.md: kept the reorganized guide and carried over v6's changes to it: ping and notification answers (hivecommons#16893), version_read hash/short (hivecommons#16890), settings_read takes no limit and the triggers section (hivecommons#16892), What a read masks (hivecommons#16889), and write tools always listed with metadata.preview.enabled (hivecommons#16890); the troubleshooting row follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com>
Summary
Admin MCP reads mask any value whose key contains
token,secret,password,credentialorauthorization. That rule is too wide: it hides settings an operator needs and that cannot hold a credential, and it makes a secret that is not set look the same as one that is. This PR keeps the rule and adds a short list of values it must not mask. Real secrets are masked exactly as before, and the stricter rule for what a write preview may store is not touched.What an operator saw
Read through
settings_readandcontributors_liston a live v6 hive:work_source.gitlab.token_env[masked:token]work_source.external.auth_token[masked:token]budget.coins.bob.tokens_per_coin[masked:token]repoSelfAuthorizationHold[masked:authorization]security.credentialWarnings[masked:secret]token_expires_at,token_issued_at(contributor)[masked:token]What changes
A value under one of those keys is now shown when it is one of these:
null, an empty string, an empty list or object. So[masked:token]now means a value is there and was withheld.tokens_per_coin. (totalTokensandinput_tokenswere already shown.)selfAuthorizationHold,repoSelfAuthorizationHold,self_authorization_hold). They are a merge policy, not anAuthorizationheader.Anything kept this way still goes through the shape scrub (GitHub tokens, JWTs, bearer tokens, private keys), and keys inside a shown block are judged by the same rules.
What stays masked
token_env. Showing those names was part of this PR at first; the review asked for the owner's decision on it, so it is taken out here and will be proposed on its own.password,secret, or a key such asaccess_tokens_per_user.credentialWarningswith warnings in it, orcredentialInjection. Opening those safely needs a per-field decision, so this PR leaves them.token_typeandcredential_type, and thesourcesentry for a*_tokenssetting (a word such as "default"). They are short strings that no general rule can tell from a password.Files
src/pkg/adminmcp/adminmcp.go:readMaskExemptand helpers, used only by the read scrub;sensitiveKeyusesauthorizationKey.src/pkg/adminmcp/scrub_read_test.go: new.src/docs/admin-mcp.md: new section "What a read masks".changelog.d/fixed-admin-mcp-read-scrub-false-positives.mdTests
TestScrubShowsValuesThatCannotBeASecret: 13 cases.TestScrubStillMasksWhatCouldBeASecret: 23 cases that must stay masked, environment variable names among them.TestScrubStillScrubsKeptValuesByShapeTestPendingScrubIsAsStrictAsBefore: the write-preview scrub still masks all of these.TestKeyWordstokensis ignored", "a list with content is shown", "authorizationis never sensitive") each fail a test.go test ./pkg/adminmcp/ ./cmd/hive-admin-mcp/passes, and so do theAdminMCP,SettingsReadandDiagtests in./pkg/dashboard/, which include the settings secret-leak test.🤖 Generated with Claude Code