Skip to content

fix(agent-sdk): mask every evt_/emk_ token shape the Go CLI masks - #28

Open
Lumea-art wants to merge 1 commit into
EverMind-AI:mainfrom
Lumea-art:fix/agent-sdk-token-redaction
Open

Lumea-art wants to merge 1 commit into
EverMind-AI:mainfrom
Lumea-art:fix/agent-sdk-token-redaction

Conversation

@Lumea-art

Copy link
Copy Markdown

Summary

redactError in @everme/agent-sdk only masked tokens of exactly 32 alphanumerics, while cli/internal/output/redact.go masks emk_ / evt_ with [A-Za-z0-9_-]{20,}. Any token that is shorter, longer, or contains - / _ therefore survived redaction — fully or partially — in plugin logs, host model context and user-visible errors. Nothing leaks today because the backend issues 32-char lowercase hex, but the Go side explicitly reserves headroom for a key-format change, and agent-sdk is the shared base of memory-mcp, claude-code, codex and openclaw.

Changes

  • plugins/agent-sdk/src/client.js — one tokenRe = /(?:evt_|emk_)[A-Za-z0-9_-]{20,}/g replaces the two {32} patterns, so the JS and Go sides agree on the token shape. The misleading "case-insensitive on both alphabet AND prefix" comment is replaced: prefixes stay case-sensitive, exactly like the Go side.
  • plugins/agent-sdk/tests/client.test.js — regression test over five shapes (24-char, 36-char, and payloads containing - / _, for both prefixes), asserting the full token never survives and that the stable 8-char prefix mask is kept.

Observed before the change (synthetic values, redactError called directly):

Input Before After
emk_ + 24 alnum leaked in full emk_aaaa_REDACTED
emk_ + 36 alnum emk_aaaa_REDACTEDaaaa (tail leaked) emk_aaaa_REDACTED
emk_ + 18 alnum + - + 17 alnum leaked in full emk_aaaa_REDACTED
evt_ + 24 alnum leaked in full evt_bbbb_REDACTED
evt_ + 18 alnum + _ + 17 alnum leaked in full evt_bbbb_REDACTED

Test Plan

Node v24.15.0, linux/amd64, commit a7384c8:

cd plugins && npm ci
cd plugins && npm test --workspaces --if-present   # 361 pass / 0 fail
cd plugins && npm audit --audit-level=moderate     # 0 vulnerabilities
  • CLI tests pass, if cli/ changed — not applicable, this PR does not touch cli/
  • Plugin workspace tests pass, if plugins/ changed
  • Manual verification completed, if behavior changed — the before/after table above was produced by calling redactError with synthetic values.

Note: plugins/everme/bin/*.mjs are generated bundles and were not regenerated here; they pick this up on their next build.

Security

  • No real emk_* / evt_* values — every token in the test is built from repeated synthetic characters. This change is itself a hardening of the credential scrubber.

Related Issues

redactError only matched exactly 32 alphanumerics, while cli/internal/output/redact.go
masks emk_/evt_ with [A-Za-z0-9_-]{20,}. Any shorter, longer or dash/underscore-bearing
token therefore survived — fully or partially — in plugin logs, host model context and
user-visible errors. Share one shape with the Go side and keep the prefix-stable mask.

Regression test covers 24-char, 36-char and dash/underscore payloads for both prefixes.
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.

fix: Node agent-sdk redaction regex drift — non-32-char / non-alphanumeric evt_/emk_ tokens are not masked (potential credential leak)

1 participant