Skip to content

fix(ICRC_Rosetta): DEFI-2944: prevent overflow before ingress-window validation in ICRC1 construction payloads#10807

Open
mbjorkqvist wants to merge 2 commits into
masterfrom
mathias/DEFI-2944-overflow-ingress-window-validation
Open

fix(ICRC_Rosetta): DEFI-2944: prevent overflow before ingress-window validation in ICRC1 construction payloads#10807
mbjorkqvist wants to merge 2 commits into
masterfrom
mathias/DEFI-2944-overflow-ingress-window-validation

Conversation

@mbjorkqvist

@mbjorkqvist mbjorkqvist commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The ICRC1 Rosetta construction_payloads endpoint computed the default ingress_end before the ingress-window validation ran. Because ingress_start comes from optional, caller-controlled metadata, a near-u64::MAX ingress_start with ingress_end omitted overflowed that computation and panicked the request thread — a request-triggered DoS despite the existing ingress-window guard.

The default is now computed with a saturating add, so an out-of-range window is rejected with a clean error by the existing validation instead of panicking.

The change is split into two commits: the first adds a test that exposes the panic, the second applies the fix and updates the test to assert the request is rejected with the expected error.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 hardens the ICRC1 Rosetta construction_payloads endpoint against a caller-triggered integer overflow when defaulting ingress_end from caller-controlled ingress_start, ensuring malformed metadata is rejected via existing ingress-window validation instead of panicking.

Changes:

  • Compute default ingress_end using saturating_add to avoid overflow before validate_ingress_window runs.
  • Add a regression test asserting a near-u64::MAX ingress_start is rejected without panic and returns the expected error.

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

mbjorkqvist and others added 2 commits July 17, 2026 11:09
…loads

The default `ingress_end` is computed as `ingress_start + ingress_interval`
before `validate_ingress_window` runs. Since `ingress_start` comes from
optional, caller-controlled metadata, a near-`u64::MAX` `ingress_start` with
`ingress_end` omitted overflows this addition and panics the request thread,
leaving the ICRC1 Rosetta construction endpoint with a request-triggered DoS
despite the ingress-window guard.

This test documents the current (panicking) behaviour via `#[should_panic]`;
the follow-up commit fixes it and updates the test to assert the request is
rejected with an error instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ICRC1 construction payloads

Compute the default `ingress_end` with `saturating_add` instead of `+`. A
near-`u64::MAX` `ingress_start` from caller metadata now saturates to
`u64::MAX` rather than overflowing and panicking, and the resulting
out-of-range window is rejected by the existing `validate_ingress_window`
check, returning a clean error to the client.

The regression test added in the previous commit is updated to assert the
request is rejected with an error rather than panicking.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mbjorkqvist
mbjorkqvist force-pushed the mathias/DEFI-2944-overflow-ingress-window-validation branch from d0c6b5f to a6d8ed3 Compare July 17, 2026 11:12
@mbjorkqvist mbjorkqvist changed the title fix: DEFI-2944: prevent overflow before ingress-window validation in ICRC1 construction payloads fix(ICRC_Rosetta): DEFI-2944: prevent overflow before ingress-window validation in ICRC1 construction payloads Jul 17, 2026
@mbjorkqvist
mbjorkqvist requested a review from Copilot July 17, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 1 out of 1 changed files in this pull request and generated no new comments.

@mbjorkqvist
mbjorkqvist marked this pull request as ready for review July 17, 2026 11:32
@mbjorkqvist
mbjorkqvist requested a review from a team as a code owner July 17, 2026 11:32
@github-actions github-actions Bot added the @defi label Jul 17, 2026
@zeropath-ai

zeropath-ai Bot commented Jul 17, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to a6d8ed3.

Security Overview
Detected Code Changes
Change Type Relevant files
Bug Fix ► rs/rosetta-api/icrc1/src/construction_api/services.rs
    Fix potential panic by saturating ingress_end calculation when metadata.ingress_start is near u64::MAX
Bug Fix ► rs/rosetta-api/icrc1/src/construction_api/services.rs
    Add test near_u64_max_ingress_start_is_rejected_without_panic to ensure rejection without panic when ingress_start is near max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants