Repository navigation
Remove early redaction of secrets; use Reveal for sensitive headers (#3077) - #3078
Conversation
…#3077) The fetch tracker redacted headers and bodies before an entry was recorded (#1561, #1593), so the Network tab's Reveal toggle (#1386) revealed `[REDACTED]` (#3023), and credential headers outside core's six-name list were shown in plain text with no masking at all (#3076). - One list: core/mcp/sensitiveNames.ts replaces the five lists the tracker, --oauth-debug, `servers/show` and the web mask kept. Field names match exactly; header names by fragment (plus DPoP and Ocp-Apim-Subscription-Key, minus WWW-Authenticate). - The live fetch log keeps real header and body values. The URL query, `whsec_` webhook secrets and truncated JSON are still removed at capture, where no reveal could bring them back. - Sinks redact with `redactFetchRequestEntry`: the InspectorClient log line, Network export and the TUI's request view. - NetworkEntry masks credential headers behind their own Reveal, and a value already `[REDACTED]` is never offered for reveal. - The pre-redirect OAuth Network log rides in the tab's sessionStorage and is deleted once restored, instead of a never-deleted file under ~/.mcp-inspector/storage. RemoteInspectorClientStorage is removed. Closes #3077, closes #3023, closes #3076 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
There was a problem hiding this comment.
🟡 Changes recommended
A blocked sessionStorage getter can crash OAuth recovery during render, and repeated redaction of the full retained request history can stall the TUI on routine updates.
2 open issues
What changed in this PR
This PR restores meaningful Reveal controls in the Network tab while keeping exported logs, backend logs, and TUI output redacted, addressing #3077, #3023, and #3076.
Changes:
- Centralizes sensitive-name matching and moves header/body redaction from capture to output boundaries.
- Adds header mask/reveal controls alongside body masking.
- Replaces disk-backed OAuth Network-log persistence with read-once, tab-scoped
sessionStorage.
| File | Description |
|---|---|
core/mcp/state/fetchRequestLogState.ts |
Deletes saved logs after restoration. |
core/mcp/sensitiveNames.ts |
Defines shared sensitive field and header rules. |
core/mcp/remote/sessionStorage.ts |
Removes disk-backed session adapter. |
core/mcp/remote/index.ts |
Removes obsolete adapter exports. |
core/mcp/inspectorClient.ts |
Redacts fetch entries before logging. |
core/mcp/fetchTracking.ts |
Preserves live values and adds output redaction. |
core/cli/handlers/servers-list.ts |
Uses shared header sensitivity rules. |
core/auth/oauthDebug.ts |
Uses shared sensitive field names. |
core/auth/oauth-persist.ts |
Updates a storage-related comment. |
clients/web/src/utils/maskSecrets.ts |
Aligns body masking and adds header masking. |
clients/web/src/utils/maskSecrets.test.ts |
Tests shared masking and redacted-value handling. |
clients/web/src/test/integration/mcp/remote/transport.test.ts |
Checks credential exclusion from backend logs. |
clients/web/src/test/core/mcp/state/fetchRequestLogState.test.ts |
Tests read-once restoration and destroy handling. |
clients/web/src/test/core/mcp/sensitiveNames.test.ts |
Tests shared name predicates. |
clients/web/src/test/core/mcp/remote/sessionStorage.test.ts |
Removes obsolete adapter tests. |
clients/web/src/test/core/mcp/fetchTracking.test.ts |
Tests live capture and redacted output copies. |
clients/web/src/test/core/auth/oauthDebug.test.ts |
Updates shared-list commentary. |
clients/web/src/lib/fetchLogSessionStorage.ts |
Adds browser session-storage adapter. |
clients/web/src/lib/fetchLogSessionStorage.test.ts |
Tests storage round trips and failures. |
clients/web/src/hooks/useOAuthRecovery.ts |
Uses tab-scoped storage across redirects. |
clients/web/src/hooks/useOAuthRecovery.test.tsx |
Updates storage mocks. |
clients/web/src/hooks/useExportActions.ts |
Redacts Network exports. |
clients/web/src/hooks/useExportActions.test.tsx |
Tests export credential redaction. |
clients/web/src/hooks/useConnectionLifecycle.ts |
Uses the storage interface type. |
clients/web/src/hooks/useConnectionLifecycle.test.tsx |
Updates storage fixture typing. |
clients/web/src/components/groups/NetworkEntry/NetworkEntry.tsx |
Adds header Reveal controls and guards masked tooltips. |
clients/web/src/components/groups/NetworkEntry/NetworkEntry.test.tsx |
Tests header masking and Reveal behavior. |
clients/web/src/components/groups/NetworkEntry/NetworkEntry.stories.tsx |
Adds interactive credential-header story. |
clients/web/src/App.test.tsx |
Removes obsolete remote-storage mock. |
clients/web/README.md |
Documents masking and redirect storage. |
clients/tui/src/App.tsx |
Redacts request entries for display and copying. |
clients/cli/__tests__/servers-list.test.ts |
Tests broadened credential-header redaction. |
Review effort: Balanced
| const inspectorFetchRequests = useMemo( | ||
| () => recordedFetchRequests.map(redactFetchRequestEntry), | ||
| [recordedFetchRequests], | ||
| ); |
There was a problem hiding this comment.
Fixed in 5e0f418. Redaction moved to clients/tui/src/utils/redactedFetchRequests.ts, which caches each redacted copy in a WeakMap keyed by entry identity. That's exact because FetchRequestLogState replaces an entry object when it updates one, so only new or updated entries pay for the body parse, and dropped ones are collected. Tested in __tests__/redactedFetchRequests.test.ts.
) Reading window.sessionStorage can throw a SecurityError where storage is blocked; the adapter is built during render, so it now takes a getter resolved inside each settled call. The TUI redacted its whole retained history on every log update; it now caches redacted copies by entry identity, which is exact because the log replaces entries it updates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
Copilot round 1 (both fixed in 5e0f418):
|
There was a problem hiding this comment.
🟡 Changes recommended
Webhook secret matching against raw JSON misses escaped whsec_ values in request and response bodies, allowing the Network preview to expose secrets without a Reveal control.
2 open issues
1 resolved since last review
Review effort: Balanced
Capture now matches whsec_ secrets against a JSON body's decoded string values, so a \/ or \u escape no longer cuts the match short. The body is re-serialized only when a secret was found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
Copilot round 2 (fixed in c0e474f):
|
There was a problem hiding this comment.
🟡 Changes recommended
Request-body logging can overflow on deeply nested valid JSON before the request is sent, so recursive traversal and serialization need guards that omit the recorded body on failure to avoid exposing secrets.
2 open issues
1 resolved since last review
Review effort: Balanced
The webhook-secret walk and re-serialization run before the request is sent; nesting that JSON.parse accepts can overflow them. Guard both and record a withheld marker rather than throwing or keeping the raw body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
Copilot round 3 (fixed in b354971):
|
… masked (#3077) JSON.parse keeps the last of duplicate keys, so a body whose sensitive key resolved to an empty value showed its raw text, earlier duplicate included. Such a body is now displayed in its parsed form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
Copilot round 4 (no inline comments; headline finding fixed in 375a88b):
|
|
Copilot review loop closed. Round 5 posted no inline comments and an empty open-issue list. Its headline names areas but no concrete defect: duplicate-key JSON was fixed in round 4; the copy button copies the displayed (masked unless revealed) text; and the Protocol tab is outside this PR. So the loop stops on a round with no in-scope findings. Rounds 1–4 were fixed in 5e0f418, c0e474f, b354971 and 375a88b. |
…-instead-of-early-redaction


Closes #3077, closes #3023, closes #3076
Thanks to @mikecat (#3023) and @CloneOfAlex (#3076) for the reports, and @aniket-r2Dev2 for tracing the capture-time redaction on #3023.
Why
The Network tab is meant to mask secrets for display (
••••••••) and show them on Reveal (#1386). Since #1561/#1593 the fetch tracker redacted headers and bodies before recording the entry, so Reveal showed[REDACTED](#3023). Headers never got the mask/reveal treatment at all: the six names core knew were redacted and couldn't be revealed, and every other credential header (X-Auth-Token,Api-Key,Ocp-Apim-Subscription-Key, …) was shown in plain text (#3076). Five separate lists decided what a secret is, and they had drifted.What changed
core/mcp/sensitiveNames.ts. It replaces the fetch tracker's header and body sets,--oauth-debug'sSENSITIVE_FIELDS, the CLI'sisSensitiveHeaderand the web mask's JSON/form keys. Field names match exactly, so OAuth metadata liketoken_endpointstays readable. Header names match by fragment (the CLI's rule), plusDPoPandOcp-Apim-Subscription-Key, minusWWW-Authenticate, which is a challenge rather than a credential.createFetchTrackerno longer redacts headers or bodies. Three things are still removed at capture, because nothing could reveal them: the URL's credential query parameters (the URL shows in every collapsed row),whsec_webhook secrets (Events (#3026) phase 4: webhook subscription management #3031, found by value rather than name), and truncated JSON (it can't be masked).redactFetchRequestEntry: theInspectorClientfetch log line (which reaches the backend's log file), Network Export, and the TUI's request list and details, which have no reveal control.NetworkEntry, with one toggle per headers table, sharing the body'sSecretsToggle. A masked MCP header is neither decoded nor mismatch-flagged, since that tooltip would quote the secret. A value that is already[REDACTED]is never offered for reveal.code, is left alone. A JSON body labeled with another content type is still masked if it parses as JSON.The pre-redirect OAuth log now uses
sessionStorage, not diskBefore the OAuth redirect, the Network log was POSTed to
/api/storage, which wrote it to~/.mcp-inspector/storage/inspector-session-<authId>.jsonand never deleted it. Now that entries keep real values, it rides in the tab'ssessionStorageinstead (src/lib/fetchLogSessionStorage.ts):sessionStorageis scoped to that tab and origin.sessionStoragealready holds the backend API token. That token is strictly stronger (it drives the backend, including launching stdio servers), so storing the log there adds no new reader.FetchRequestLogStatedeletes it as soon as it has restored it. A StrictMode-destroyed instance leaves it for the live one.RemoteInspectorClientStoragehad no other caller, so it and its test are removed./api/storageitself stays (it also servesoauth/client). Files written by earlier builds are not cleaned up.Screenshots
New
Groups/NetworkEntry/CredentialHeadersstory (1280×900).Masked by default: the
authorizationandx-auth-tokenheaders, the formcode, and the JSON tokens.www-authenticatestays readable.After Reveal on all three sections, the real values are shown:
Testing
npm run local:gatepasses. New or changed tests cover:redactFetchRequestEntryredacts them;X-Auth-Tokenvalue (an integration test);[REDACTED]values;sessionStorageadapter;🤖 Generated with Claude Code