Repository navigation
fix(ICP_Rosetta): DEFI-3058: bound Candid decoding of envelope args in the construction API - #12108
Draft
mbjorkqvist wants to merge 2 commits into
Draft
mbjorkqvist wants to merge 2 commits into
mbjorkqvist wants to merge 2 commits into
Conversation
…n the construction API Decode the canister method arguments of client-supplied envelopes in construction/parse and construction/submit with a Candid skipping quota, the same one the ic-cdk endpoint macros apply to the canister methods being called, so that the decoding work is bounded regardless of the lengths declared in the type table. Also run the construction endpoints that parse or build transactions on the blocking thread pool, so a slow request cannot occupy the actix workers serving the other endpoints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical denial-of-service path remains because the skipping quota does not bound known-field decoding, allowing small inputs to trigger excessive CPU and memory use before rejection.
1 open issue
What changed in this PR
This PR hardens ICP Rosetta’s construction API against excessive Candid decoding work, following the approach used for ICRC Rosetta in #12106.
Changes:
- Apply a shared 10,000-unit skipping quota when decoding client-supplied Candid envelope arguments.
- Move
parse,hash,combine, andpayloadsprocessing to the blocking thread pool. - Add regression tests for oversized skipped values and acceptance of small unexpected values.
| File | Description |
|---|---|
rs/rosetta-api/icp/src/rosetta_server.rs |
Offloads four construction handlers to the blocking pool. |
rs/rosetta-api/icp/src/request.rs |
Applies quota-controlled decoding during submit request conversion. |
rs/rosetta-api/icp/src/request_handler/construction_parse.rs |
Updates argument decoding and adds quota regression tests. |
rs/rosetta-api/icp/src/convert.rs |
Introduces the shared decoder and skipping quota. |
rs/rosetta-api/icp/CHANGELOG.md |
Documents the construction API hardening. |
Review effort: Balanced
…elope args The skipping quota only bounds values that are skipped. A long vector of records whose fields are all optional, e.g. in `SetFollowing`, takes no bytes on the wire and is decoded rather than skipped. Also set a decoding quota of 100,000, as the NNS canisters do for `http_request`, and check that the largest legitimate argument stays well within it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
ICP Rosetta decodes the Candid arguments of client-supplied call envelopes in
construction/parseandconstruction/submitwithout a skipping quota, so the decoding work depends on the lengths declared in the Candid type table rather than on the size of the arguments. The construction handlers also run synchronously on the actix workers, so slow requests can hold up the other endpoints. This is the ICP Rosetta counterpart of #12106.What
parse,hash,combine,payloads) on the blocking thread pool.optfield.🤖 Generated with Claude Code