Validate contract ID on transaction deserialization#1349
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens AssembledTransaction deserialization by ensuring a deserialized transaction’s target contract matches the Client/options contractId, preventing cross-contract transaction signing.
Changes:
- Add contract ID validation during
AssembledTransaction.fromXDR()andAssembledTransaction.fromJSON(). - Add unit tests covering accept/reject behavior for matching vs. mismatching contract IDs.
- Update
.gitignoreto exclude local tooling directories.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/contract/assembled_transaction.ts |
Adds contract ID checks when reconstructing assembled transactions from XDR/JSON. |
test/unit/server/soroban/assembled_transaction.test.ts |
Adds tests validating the new deserialization checks. |
.gitignore |
Ignores .claude/ and .copilot/ directories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Size Change: +89.5 kB (+0.2%) Total Size: 45.2 MB
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 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.
There was a problem hiding this comment.
I think this fix should target the Client's txFromJson and txFromXdr methods. In that those are were we should be opinionated and enforce validation. I think we could create a static validate function on the AssembledTransaction class that verifies contractIds are the same and the method name is in the spec
Ignore this there is no reason to not have this validation on all AssembledTransaction parsing
fromXDR()andfromJSON()inAssembledTransactionnow verify that thedeserialized transaction's contract address matches the
Client's configuredcontractId, throwing a clear error on mismatch.foreign contract could be silently signed through a
Clientconfigured fora different contract.
.gitignore