Repository navigation
fix(ICRC_Rosetta): DEFI-3056: bound amount length and ledger method args size - #12095
Merged
mbjorkqvist merged 2 commits intoNov 13, 2026
Merged
Conversation
…rgs size - Reject `Amount` values longer than 78 characters (enough for any u256) before parsing them into a `Nat` in `rosetta_core`. - Reject ledger method arguments larger than 4 KiB in `/construction/payloads` before they are copied into the envelopes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the change adding Construction API input-size limits.
No open issues 🎉
What changed in this PR
Adds size limits to reduce memory amplification in the ICRC Rosetta Construction API, extending the memo protection introduced in #11886.
Changes:
- Rejects amount strings longer than 78 characters, excluding a leading
-, before conversion toNat. - Rejects encoded ledger method arguments larger than 4 KiB before copying them into transaction envelopes.
- Adds boundary and oversized-input tests and documents the limits in the changelog.
| File | Description |
|---|---|
rs/rosetta-api/icrc1/src/construction_api/utils.rs |
Validates argument size before envelope creation and tests accepted and oversized arguments. |
rs/rosetta-api/icrc1/src/common/constants.rs |
Defines the 4 KiB encoded-argument limit. |
rs/rosetta-api/icrc1/CHANGELOG.md |
Records the new amount and argument-size limits. |
rs/rosetta-api/common/rosetta_core/src/objects.rs |
Bounds shared Amount-to-Nat conversion and adds length-validation tests. |
Review effort: Balanced
|
✅ No security or compliance issues detected. Reviewed everything up to 089a960. Security OverviewDetected Code Changes
|
eichhorl
approved these changes
Nov 13, 2026
- Also bound the size of client-supplied ledger method args in /construction/parse, /construction/hash and /construction/submit. - Avoid an underflow when deriving ingress_start in /construction/parse. - Test the size check through handle_construction_payloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mbjorkqvist
deleted the
mathias/DEFI-3056-rosetta-bound-amount-length
branch
November 13, 2026 16:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The ICRC Rosetta Construction API builds the ledger method arguments from caller-provided operations and copies them into every envelope of the unsigned transaction. The amounts in those operations (
amount,fee,allowance,expected_allowance) are parsed without any length limit. This is a follow-up to #11886, which limits the memo.What
Amountvalues longer than 78 characters (enough for any u256), not counting a leading-, are rejected before parsing. The check is inrosetta_core. ICRC-1 and ICP amounts are well within this limit./construction/payloadsrejects ledger method arguments larger than 4 KiB before building the envelopes. This bounds all fields, including any added in the future. The largest supported arguments, with a 1 KiB memo, fit well within it.🤖 Generated with Claude Code