Skip to content

feat: capture raw body bytes for v4 hmac calculation#8065

Draft
MohammedRyaan786 wants to merge 1 commit intomasterfrom
CAAS-659
Draft

feat: capture raw body bytes for v4 hmac calculation#8065
MohammedRyaan786 wants to merge 1 commit intomasterfrom
CAAS-659

Conversation

@MohammedRyaan786
Copy link
Contributor

@MohammedRyaan786 MohammedRyaan786 commented Feb 5, 2026

TICKET: CAAS-659

This pull request improves how HTTP request bodies are handled in the Express app, specifically to support v4 HMAC authentication that requires the exact raw request bytes. The main changes add logic to preserve the raw request body and ensure it is sent unchanged when proxying requests, which is important for signature verification.

Enhancements for request body handling and HMAC authentication:

  • The Express app now stores the raw request body buffer on each request before JSON parsing, enabling downstream code to access the exact bytes received from the client. This is necessary for v4 HMAC authentication, which relies on the unmodified request body.
  • A new sendRequestBody helper function is introduced in clientRoutes.ts to send the raw request body buffer when available, falling back to the parsed body for backward compatibility.
  • The redirectRequest function is updated to use sendRequestBody for all HTTP methods that send a body, ensuring the raw bytes are forwarded when possible.

Current PR is related to this BGMS PR

@MohammedRyaan786 MohammedRyaan786 requested review from a team as code owners February 5, 2026 12:40
@MohammedRyaan786 MohammedRyaan786 marked this pull request as draft February 5, 2026 12:40
@MohammedRyaan786
Copy link
Contributor Author

@claude please review this PR

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to preserve exact incoming HTTP request body bytes in the Express app so downstream v4 HMAC/signature verification can use the unmodified payload, and to forward that raw payload unchanged when proxying requests.

Changes:

  • Capture and store the raw JSON request body buffer during parsing (req.rawBodyBuffer).
  • Add a helper to prefer forwarding the raw body when proxying (sendRequestBody) and apply it across body-bearing HTTP methods.
  • Add unit tests validating raw-body capture behavior (whitespace/order preservation).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
modules/express/src/expressApp.ts Adds bodyParser.json verify hook to capture raw request bytes into req.rawBodyBuffer.
modules/express/src/clientRoutes.ts Introduces sendRequestBody and updates redirectRequest to forward raw bytes when present.
modules/express/types/express/index.d.ts Extends Express Request typing with optional rawBodyBuffer.
modules/express/test/unit/clientRoutes/rawBodyBuffer.ts Adds tests validating raw-body buffer capture and preservation characteristics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lokesh-bitgo
Copy link
Contributor

@claude review this PR with a primary focus on the bug, and confirm whether these changes impact any other flows.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MohammedRyaan786 MohammedRyaan786 marked this pull request as ready for review February 9, 2026 18:46
@MohammedRyaan786 MohammedRyaan786 requested a review from a team as a code owner February 9, 2026 18:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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