Skip to content

[M-03] DoS Attack on Swapping via Permit2 Possible #1016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: may-14-audit
Choose a base branch
from

Conversation

mrice32
Copy link
Contributor

@mrice32 mrice32 commented Jun 4, 2025

The SwapProxy contract contains the performSwap function, which enables the caller to execute a swap using several different ways: by approving or sending tokens to the specified exchange and by approving tokens through the Permit2 contract.

However, since it is possible to provide any address as the exchange parameter and any call data through the routerCalldata parameter of the performSwap function, the SwapProxy contract may be forced to perform an arbitrary call to arbitrary address.

This could be exploited by an attacker, who could force the SwapProxy contract to call the invalidateNonces function of the Permit2 contract, specifying any spender and a nonce higher than the current one. As a result, the nonce for a given (token, spender) pair will be updated. If the performSwap function is called again later, it will attempt to use a subsequent nonce, which has been invalidated by the attacker and the code inside Permit2 will revert due to nonces mismatch.

As the performSwap function is the only place where the nonce passed to the Permit2 contract is updated, the possibility of swapping a given token on a certain exchange will be blocked forever, which impacts all the functions of the SpokePoolPeriphery contract related to swapping tokens. The attack may be performed for many different (tokens, exchange) pairs.

Consider not allowing the exchange parameter to be equal to the Permit2 contract address.

@mrice32 mrice32 changed the title M-03 DoS Attack on Swapping via Permit2 Possible [M-03] DoS Attack on Swapping via Permit2 Possible Jun 4, 2025
@mrice32 mrice32 requested a review from grasphoper June 4, 2025 05:14
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.

1 participant