Skip to content

Verify SEP-10 challenge body integrity after domain signing#237

Merged
CassioMG merged 2 commits into
mainfrom
sep10-domain-signing-integrity-check
May 22, 2026
Merged

Verify SEP-10 challenge body integrity after domain signing#237
CassioMG merged 2 commits into
mainfrom
sep10-domain-signing-integrity-check

Conversation

@CassioMG
Copy link
Copy Markdown
Contributor

@CassioMG CassioMG commented May 21, 2026

Summary

  • Sep10.sign() now verifies that the transaction returned by the configured DomainSigner has the same body hash as the original challenge before signing it with the user's account key. If the body differs, a DomainSigningModifiedError is thrown and the user-account signature is not applied.

Test plan

  • Added unit test: should accept when domain signer returns the same transaction with an appended signature — confirms the legitimate flow still works.
  • Added unit test: should reject when domain signer returns a transaction with a different body — confirms a modified envelope causes DomainSigningModifiedError before any user-account signing.
  • yarn lint passes
  • yarn test:ci passes (249 tests, 0 failures)

Compares the hash of the transaction returned by the configured DomainSigner
against the original challenge before signing it with the user's account key.
If the body differs, a new DomainSigningModifiedError is thrown and the
user-account signature is never applied.
Copilot AI review requested due to automatic review settings May 21, 2026 00:26
Copy link
Copy Markdown

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 strengthens SEP-10 authentication by ensuring that a configured domain signer cannot modify the SEP-10 challenge transaction body before the wallet applies the user-account signature. It does so by comparing the transaction body hash (excluding signatures) before and after domain signing, and rejecting any body changes with a dedicated error.

Changes:

  • Added an integrity check in Sep10.sign() to verify the domain signer returns a transaction with the same envelope body hash as the original challenge.
  • Introduced DomainSigningModifiedError to clearly signal domain-signer body modification.
  • Added unit tests covering both the accepted case (signature appended only) and the rejected case (body changed), including assertions that user signing and token POST are not performed on rejection.

Reviewed changes

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

File Description
@stellar/typescript-wallet-sdk/src/walletSdk/Auth/index.ts Adds post-domain-signing body-hash verification and throws DomainSigningModifiedError on mismatch.
@stellar/typescript-wallet-sdk/src/walletSdk/Exceptions/index.ts Defines the new DomainSigningModifiedError used by SEP-10 signing flow.
@stellar/typescript-wallet-sdk/test/auth.test.ts Adds unit tests for domain signer integrity behavior (accept same body + extra signature; reject modified body).

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

Copy link
Copy Markdown

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 3 changed files in this pull request and generated 1 comment.

Comment thread @stellar/typescript-wallet-sdk/test/auth.test.ts Outdated
@CassioMG CassioMG requested a review from piyalbasu May 21, 2026 00:37
Copy link
Copy Markdown
Contributor

@piyalbasu piyalbasu left a comment

Choose a reason for hiding this comment

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

This is looking good to me!

@CassioMG CassioMG merged commit 6e624e9 into main May 22, 2026
8 checks passed
@CassioMG CassioMG deleted the sep10-domain-signing-integrity-check branch May 22, 2026 00:36
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.

3 participants