Repository navigation
Description
Re-verified on harper
maina7dae44 (2026-10-26). #3412 merged 2026-10-26 without changing this;utility/credentials.ts:9-10CREDENTIAL_KEYstill end-anchorskey|token|cookie|authorization, andagent/DESIGN.md~36 ("Not covered") does not list plural keys. Fix-shape note:maxTokens,promptTokensandoperationTokenTimeoutare deliberately left readable and are structurally the same asapiKeys/tokens, so the fix needs a rule that tells them apart, e.g. mask by value type (any non-numeric value or list element under a plural credential-named key) or an explicit exclusion list.accessTokens,refreshTokens,authorizations,keys, spaced keys and URL-encoded keys are the same gap.
What happens
The built-in agent's credential masking (#3412, closes #3097) replaces the value of every credential-named key with *s before a config- or logs-scope read or a read_log result reaches the model and the stored, replicated session transcript. A credential key in plural form is not treated as a credential, so its values go through raw.
Measured on main ccd6db847 (the #3412 merge commit) in one real agent_prompt session driven by a fake OpenAI-compatible model that issues five tool calls:
| Surface | apiKey / token (control) |
apiKeys / tokens |
|---|---|---|
read_file root config |
apiKey: ********************************* |
apiKeys:\n - sk-sqa98-config-plural-sentinel raw |
grep_files root config |
masked line | "line":97,"text":" - sk-sqa98-config-plural-sentinel" |
agent read_log |
{\"token\":\"******************************\"} |
{\"tokens\":[\"sk-sqa98-log-plural-sentinel\"]} raw |
tail_file / grep_files root logs |
masked | raw |
| model request bodies / stored session | absent | config sentinel present in a model request |
Library-level on the same build (node -e over dist/utility/credentials.js): apiKey true, apiKeys false, token true, tokens false, maxTokens false, cookies false, privateKeys false, secrets true, passwords true, credentials true. authorizations, accessTokens, refreshTokens, keys, a spaced key ("api key") and a URL-encoded key (api%5Fkey=) also come back raw; secret*, credential*, passw* plurals are masked because those alternations are unanchored.
Mechanism
utility/credentials.ts:9-10:
export const CREDENTIAL_KEY =
/^(?:.*(?:secret|passw(?:or)?d|passphrase|credential).*|.*(?:key|token|cookie|authorization)|.*access[-_]?key[-_]?id)$/i;key|token|cookie|authorization is end-anchored so that maxTokens, promptTokens, maxKeys stay readable (agent/DESIGN.md:36). The same regex gates the YAML parse path (:84), the text scan (maskLine, :195) and, through maskCredentialValues, every string field of a read_log entry (agent/registryTools.ts:72-92). agent/DESIGN.md:36 "Not covered" lists a password in a URL, quoted-value continuations, other operations tools, http_fetch and MCP read_log — not plural keys.
Repro
npm run test:integration -- "integrationTests/qa-scratch/security/sqa98-plural-key-e2e.test.ts"
# 1/6: the singular control passes, the five plural arms fail with the raw sentinel in the tool resultOne-liner: node -e "const {CREDENTIAL_KEY}=require('./dist/utility/credentials.js'); console.log(CREDENTIAL_KEY.test('apiKeys'), CREDENTIAL_KEY.test('tokens'))" → false false.
Fix shape
A bare s? after the anchored group would re-hide maxTokens/promptTokens. Either an explicit plural list (apiKeys|tokens|cookies|privateKeys|accessTokens|refreshTokens|authorizations|keys) or s? plus an exclusion of the counter prefixes (max|prompt|completion|embedding|num|count|candidate|allowed), and a "Not covered" line in agent/DESIGN.md for spaced and URL-encoded keys. If the end-anchor is kept on purpose, say so in DESIGN.md and in the docs (documentation#745 currently words the rule as "a key that ends in key, token, cookie, or authorization", which documents the gap only by implication). The promoted anchor unitTests/agent/credentialMasking.test.js (PR #3557) and SP-70 flip green on a fix.
Existing work checked
harper issues (1,500 titles) and PRs (300): #3097 CLOSED by #3412 (its acceptance named *token*, which would have covered plurals); #3462, #3380 OPEN (other redaction surfaces); PR #2939 MERGED (logger-side CREDENTIAL_KEY_PATTERN, substring — masks tokens at write time for STRUCTURED log arguments, so the two patterns disagree on plurals). harper-pro (500 issues, PRs): nothing. No comment or review thread on #3412 raises plurals. documentation#745 OPEN documents the end-anchored rule. Docs at db4de761: reference/configuration/options.md:473 still says the agent reads config secrets unmasked.
What this does not prove
- That a shipped Harper component logs a plural-named credential field as free text: a structured
logger.warn('x', { tokens })is masked at write time byharper_logger.ts:49-50; the logs leg needs a pre-serialized JSON string or a proxied/third-party message. - That any shipped config key is plural-credential-named (grep found only counters:
maxTokens,maxKeys,candidateKeys…); the config leg needs an operator-written key or a widenedagent.configScope. - Bun; MCP
read_log(documented as unmasked anyway); the families beyondapiKeys/tokenson the end-to-end route (library-level only).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity