Skip to content

fix(express): handle circular request bodies in error redaction - #10032

Open
MohammedRyaan786 wants to merge 1 commit into
masterfrom
COINS-1940-fix-express-redaction-recursion
Open

MohammedRyaan786 wants to merge 1 commit into
masterfrom
COINS-1940-fix-express-redaction-recursion

Conversation

@MohammedRyaan786

@MohammedRyaan786 MohammedRyaan786 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Ticket: COINS-1940

This pull request improves the handling of sensitive values in request bodies, specifically addressing issues with circular references that could cause infinite recursion. It also adds a test to ensure that circular request bodies are handled correctly during error redaction.

Improvements to sensitive value collection:

  • Refactored the collectSensitiveRequestValues function in clientRoutes.ts to detect and safely handle circular references by tracking visited objects with a WeakSet, preventing infinite recursion when traversing request bodies.

Testing enhancements:

  • Added a unit test in clientRoutes/index.ts to verify that the error redaction logic works correctly with circular request bodies, ensuring sensitive values are properly redacted without causing runtime errors.

@linear-code

linear-code Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

COINS-1940

@MohammedRyaan786
MohammedRyaan786 force-pushed the COINS-1940-fix-express-redaction-recursion branch from 445f797 to 4817b69 Compare October 22, 2026 17:18
@MohammedRyaan786

Copy link
Copy Markdown
Contributor Author

@claude please review the PR for correctness and provide a verdict

@MohammedRyaan786
MohammedRyaan786 marked this pull request as ready for review October 22, 2026 17:32
@MohammedRyaan786
MohammedRyaan786 requested review from a team as code owners October 22, 2026 17:32

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

@kisslove-dewangan

Copy link
Copy Markdown
Contributor

@claude review thoroughly and give approval rating

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.


function redactSensitiveValues(value: unknown, sensitiveValues: Set<string>): unknown {
function redactSensitiveValues(
value: unknown,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a test for a mutated body, to show that secrets are still redacted after the SDK changes the cloned params.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in ddb9fad22: modules/express/test/unit/typedRoutes/sendmany.ts → "should redact secrets when sendMany mutates the cloned params and then fails". The test goes through the real /sendmany route, so it uses the actual createSendParams clone. The mocked wallet.sendMany behaves like the SDK: it attaches a self-referencing wallet to the params (as Object.assign(params, { wallet: this }) does), deletes walletPassphrase from them, then throws an error that contains the passphrase.

The test checks that:

  • the response comes back as a 400;
  • the error message is failed to sign with [REDACTED];
  • the passphrase appears in neither the response body nor the logs;
  • the SDK received a copy (with wallet attached and the passphrase removed), not the request body itself.

I confirmed it fails when createSendParams returns req.body directly: the passphrase leaks unredacted.


Generated by Claude Code

@MohammedRyaan786
MohammedRyaan786 force-pushed the COINS-1940-fix-express-redaction-recursion branch from 4817b69 to ddb9fad Compare October 23, 2026 10:39
Ticket: COINS-1940

Co-authored-by: Ralph CLI <ralph-cli@bitgo.com>
Ralph: 18.12.3-bitgo.3 openrouter/z-ai/glm-5.3-flash@smol openrouter/google/gemini-3.8-flash@commit openrouter/z-ai/glm-5.3@task+plan openrouter/openai/gpt-5.6-luna@advisor+slow openrouter/openai/gpt-5.6-luna-pro@default
@MohammedRyaan786
MohammedRyaan786 force-pushed the COINS-1940-fix-express-redaction-recursion branch from ddb9fad to 9621bbd Compare October 23, 2026 10:42

This branch has not been deployed

No deployments
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.

2 participants