inspector icon indicating copy to clipboard operation
inspector copied to clipboard

The hosted doctor echoes the stored bearer token back in its own response

Open olartgabo opened this issue 2 months ago • 1 comments

Found during the review of #4884 (MJ-001 redaction). Out of scope for that PR, deliberately left for its own ticket. Not covered by anything merged.

What happens

sdk/src/server-probe.ts:501-513 builds the initialize attempt with the stored token on it:

if (accessToken) { headers.Authorization = `Bearer ${accessToken}`; }
return { name: "streamable_initialize", request: { method: "POST", url: config.url, headers, … } };

That headers object is stored on the attempt and ships to the caller inside transport.attempts[].request.headers. The token comes from server-side storage (routes/web/servers.ts:224, auth.ts:958-964), not from the caller's own request. The redactor added in #4884 rewrites error.message, connection.detail, checks[].detail and now error.code and durationMs — it does not touch request.headers.

Why it matters

The caller is authorized for that server, so this is not a cross-tenant leak. It is a needless echo that puts a live OAuth access token into a JSON response body, which then reaches:

  • browser memory and devtools
  • HAR exports
  • any support bundle or ticket a user pastes it into

A token that never had to leave the server is now in several places nobody is tracking.

Suggested direction

Redact Authorization (and any other credential-shaped header) out of attempts[].request.headers unconditionally, hosted or not. The attempt record is for diagnosing the request shape; the secret value carries no diagnostic weight.

Notes

Separate from #5000 (credential headers egressing to target-chosen metadata hosts), though both live on the same probe path.

Not a pentest finding. Reported here so it is tracked rather than sitting only in the review write-up.

olartgabo avatar Sep 13 '26 03:09 olartgabo

Opened #5058 for this. Following CONTRIBUTING — @chelojimenez, I can't self-assign without write access, so tagging here instead; happy to step aside if someone is already on it.

Short version of the approach: the redaction is in server-probe rather than hosted-doctor-redaction, because this is not a hosted-mode differential — the local inspector has no more use for the token in its own response than the hosted one does, which matches the "unconditionally, hosted or not" in the issue. The predicate is isSecretKeyName exported from conformance-redaction rather than a new list, so x-api-key and vendor-prefixed token headers are covered too.

Every test cell pairs the redaction with the control that the outgoing request still carries the real credential. Mutation results, including two that survive because the two defences deliberately overlap, are written out in the PR body.

#5000 is untouched — this changes only what is recorded, not what egresses.

L4XB avatar Sep 14 '26 07:09 L4XB