Skip to content

fix(agentlogin): match secret words in settings keys as words, not substrings - #58

Closed
dhruv1220 wants to merge 1 commit into
devvmhq:mainfrom
dhruv1220:fix/redact-substring-key-match-55
Closed

dhruv1220 wants to merge 1 commit into
devvmhq:mainfrom
dhruv1220:fix/redact-substring-key-match-55

Conversation

@dhruv1220

Copy link
Copy Markdown
Contributor

Fixes #55.

Redact decided a settings key held a secret by substring-matching its name
against key, token, secret and passw, so a whole table under a key
like tokeneconomizer counted as secrets and every value under it became
devvm-redacted. With the TokenEconomizer plugin installed that blanked
extraKnownMarketplaces.tokeneconomizer.source.source ("github"),
marketplaces.tokeneconomizer.source_type and the hook-trust entries, and
Claude Code rejected the whole settings file — every plugin showed as
disabled in the VM.

A stem now only counts as a word of its own: at a camelCase or separator
boundary, at the key's end, or with a trailing s (tokens, apiKeys).
A stem starting a longer lowercase word doesn't count, so tokeneconomizer,
tokenizer, keystore and keyboard keep their values, while apiKey,
apikey, oauth_token, accessToken, client_secret, password,
passwd, tokens and Authorization still redact exactly as before.

  • internal/agentlogin/redact.go: redactName's substring regex is now
    secretKeyName / secretStemAt, with the same keep rules (paths,
    {env:X}, true/false, short numbers, Claude Code's own env) untouched.
  • internal/agentlogin/redact_test.go: TestRedactKeepsMarketplaceName
    reproduces the issue's JSON and TOML settings (fails on the old code, passes
    with the fix), plus a TestSecretKeyName table for the boundary cases.
  • docs/content/docs/internals/network.md: the "Keys in settings files"
    bullet now says what counts as a secret-named key.

Verified: go test ./internal/agentlogin/ and go test ./internal/structure/ green, gofmt / go vet clean. The wider
go test ./internal/... suite is green except TestScript/install, which
fails identically on unmodified code (its install.sh test extracts a
tarball as non-root and tar refuses the chown) — a pre-existing
environment failure, unrelated to this change. (mise isn't available in
this environment, so the full mise run gate couldn't run here.)

@dhruv1220
dhruv1220 requested a review from w3cj as a code owner November 18, 2026 11:19
@w3cj

w3cj commented Nov 18, 2026

Copy link
Copy Markdown
Member

Thanks @dhruv1220, this is a careful PR and the test reproduces #55 well. We’re going to fix it a different way, for two reasons. Kebab-case names, which most plugins and marketplaces use, still match (token-saver, secret-scanner), so the bug stays for most of them. And the word-boundary rule stops redacting some all-lowercase secret keys that main redacts today, such as accesstokenvalue or secretkeyid, which we’d rather not trade in this code. Instead we’ll treat the keys of known name tables (marketplaces, plugins, MCP servers, providers) as names rather than field names, and keep the field check as it is. I’ll close this, but once it lands we'll credit to you in the changelog. Thanks again!

Generated with Claude, edited and reviewed by @w3cj

@w3cj w3cj closed this Nov 18, 2026
w3cj added a commit that referenced this pull request Nov 18, 2026
…aken for secrets

Redact judged every key by redactName's substring rule, so a plugin, a
marketplace or an MCP server named tokeneconomizer, token-saver or
secret-scanner had all its settings replaced with devvm-redacted, and
Claude Code refused the VM's settings.json whole (#55).

Each agents.Def now lists the tables of its settings files whose keys are
names you choose (Names: a table under a name isn't judged by its name)
and the tables of settings keyed by names (NamedValues: neither a table
nor a setting's word, lower-case letters and dashes such as off, is),
read from each agent's docs; agents.NameTables is their one union, which
Redact applies to every agent's files. Fields under a name are judged as
before: the substring rule, wholeTable, secretShape and the URL and text
scrubbing. Any other value right under a names table is still judged by
its key, a name that's env or headers still makes a table of secrets, and
a * in a table's path never stands for a list's element.

The trade-off: a table with a secret-looking key right under a name, such
as {"mcp": {"tokens": {...}}}, is no longer replaced whole; no agent's
schema has one there, and the fields inside it are still judged.

Tests: TestRedactNames (Claude Code's, Codex's, opencode's and pi's
names, kebab and camel, secret fields under names, misplaced values in
names and settings tables, a list under a settings table's path, a
server named env), FuzzRedact's seeds under names and settings tables,
and TestRestoreOlderNamesCopy for a VM copy an older devvm blanked, which
devvm agent save leaves out with a warning (an After you upgrade line).
Thanks to dhruv1220 for the tests' idea in #58.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@w3cj

w3cj commented Nov 22, 2026

Copy link
Copy Markdown
Member

Your idea of matching secret words as whole words shaped the tests for the #55 fix, which is in 0.2.0-rc.1. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secret redaction naively matches on key names, so it blanks non-secret config under names like "tokeneconomizer"

2 participants