Skip to content

fix(agent-core): redact the value of a name/value pair whose name is a credential - #833

Merged
nik13 merged 4 commits into
devfrom
fix/agent-core-name-value-credentials
Dec 3, 2026
Merged

nik13 merged 4 commits into
devfrom
fix/agent-core-name-value-credentials

Conversation

@nik13

@nik13 nik13 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Credentials often travel as name/value pairs. In these pairs the credential name is a value, not a key:

  • Kubernetes env entries: {"name":"DB_PASSWORD","value":"…"}
  • ECS / AWS Name/Value
  • CloudFormation stack parameters ParameterKey/ParameterValue/ResolvedValue
  • CloudFormation stack outputs OutputKey/OutputValue
  • tag and parameter-store Key/Value lists

agent-core's structured redaction only checked member keys, so the value of such a pair was exported.

Now, when an object's pair-name field (name, Name, key, Key, ParameterKey, OutputKey) holds a credential name, every pair-value field (value, Value, ParameterValue, ResolvedValue, OutputValue) in that object is written as fi-core's placeholder <redacted>. The name and other members are kept.

  • Fail-closed: any credential-named pair field redacts every pair-value field of the object.
  • Value types: the value is redacted whatever its type (string, number, object, array).
  • Applies everywhere: parsed objects, arrays, and JSON embedded in strings.
  • Token-count names are not credentials: max_tokens, gen_ai.usage.input_tokens, llm.token_count.prompt, completion_tokens and tokenizer names keep their values.

This is part of TH-11639, the structured name/value rule only. Free-text pair shapes (YAML - name: / value: lists, Python-repr dicts, escaped JSON inside log lines, other pair spellings) are follow-ups on that card.

Tests

traceai_agent_core/test/privacy.test.cjs:

  • Each pair shape:
    • the exact structured output (only the value changes);
    • the shape nested in arrays, objects and JSON strings, including Response: <json> text;
    • idempotence;
    • fi-core discoverSecrets learns neither the value nor the placeholder.
  • Value types: a credential-named pair redacts object, array, number and boolean values.
  • Mixed fields: any credential-named pair field redacts both value and Value.
  • Guards: non-credential pairs, pairs missing a name or value, non-string names and token-count names are unchanged.
  • Stack parameters: ResolvedValue is redacted with ParameterValue, while a non-credential parameter keeps it.

An internal pre-review (three lenses, two skeptics per finding) found three issues, all fixed in fa1e0ef:

  • a test-file brace that the rebase onto dev dropped;
  • the missing OutputKey/OutputValue shape;
  • token-count names that were treated as credentials.

Nothing was run locally (repo rule); CI runs these tests.

🤖 Generated with Claude Code

nik13 and others added 4 commits December 2, 2026 19:59
…a credential

Credentials are often carried as name/value pairs, where the credential
name is a value rather than a key: Kubernetes env entries
({"name":"DB_PASSWORD","value":"…"}), ECS/AWS Name/Value, CloudFormation
ParameterKey/ParameterValue/ResolvedValue, and key/value tag lists. The
structured path only checked keys, so the value was exported. When an
object's name field holds a credential name, its value fields are now
written as <redacted>; the name and other members are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…token-count names

- OutputKey/OutputValue (CloudFormation stack outputs) join the pair
  fields.
- A pair name for a token count, limit or tokenizer (max_tokens,
  gen_ai.usage.input_tokens, llm.token_count.prompt) is not a credential
  name, so its value is kept.
- Restore the closing of the previous-output test that the rebase onto
  dev dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s a token-usage phrase

The token-count exclusion matched anywhere in the normalized name, so
TOKENIZER_API_KEY or secret_max_tokens was treated as a token count and
its value kept. A pair name is now a credential name when it still is
one with its token-usage phrases taken out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Taking the phrases out of the separator-free name let a plural borrow the
next word's first letter (MAX_TOKEN_SECRET became "ecret"), so such a
credential name kept its value. The name is now split into words (at
separators and camelCase boundaries) and only whole token-usage words or
word pairs are taken out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nik13 nik13 closed this Dec 2, 2026
@nik13 nik13 reopened this Dec 2, 2026
@nik13
nik13 marked this pull request as ready for review December 2, 2026 19:31
@nik13
nik13 merged commit be37262 into dev Dec 3, 2026
15 checks passed
@nik13
nik13 deleted the fix/agent-core-name-value-credentials branch December 3, 2026 00:22
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.

1 participant