Skip to content

C4 S-538 Prevent excess msg.value#76

Merged
shunkakinoki merged 9 commits intomasterfrom
c4-s538
Nov 26, 2025
Merged

C4 S-538 Prevent excess msg.value#76
shunkakinoki merged 9 commits intomasterfrom
c4-s538

Conversation

@ScreamingHawk
Copy link
Contributor

S-538 Excess ETH Can Be Permanently Locked in Direct Calls to TrailsRouter

https://code4rena.com/audits/2025-11-sequence-transaction-rails/submissions/S-538

Issue: msg.value validation is inconsistent and doesn't require an exact value.

Analysis: When ERC-20 is used, the exact supplied amount is used. For native token interactions, we check msg.value < amount and do not do 0 checks when msg.value is unexpected. In practice, this is misconfiguration of the payload and shouldn't happen, but for safety it makes sense to check for this.

Fix: Changes msg.value < amount checks to msg.value != amount. Adds msg.value == 0 validation for ERC20 usages.

NOTE: I've also removed references to ETH in favour of Value to support chains that doesn't use ETH as the native token.

NOTE2: This assumes we have no flows that are expected to send ERC20 AND native tokens in the same transaction.

@ScreamingHawk ScreamingHawk requested a review from a team November 25, 2025 21:20
Agusx1211
Agusx1211 previously approved these changes Nov 26, 2025
…recent changes in test performance and gas usage. Adjustments made to various test cases for accuracy and consistency.
@shunkakinoki shunkakinoki enabled auto-merge (squash) November 26, 2025 07:48
@shunkakinoki shunkakinoki merged commit 0c40a8f into master Nov 26, 2025
1 check passed
@shunkakinoki shunkakinoki deleted the c4-s538 branch November 26, 2025 07:50
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