Grifeing Attack #14
kalpshah284
started this conversation in
Bug reports
Replies: 1 comment 4 replies
-
Hi @kalpshah284 thank you for reporting the issue. I've passed the issue on to our security team. I will let you know the resolution. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Description
Where:
provideWithPermit
andprovideForWithPermit
Expected behavior:
The
provideWithPermit
andprovideForWithPermit
functions utilize the permit function so that approve and pull operations can happen in a single transaction instead of two consecutive transactions.Attack:
ERC20Permit uses the nonces mapping for replay protection. Once a signature is verified and approved, the nonce increases, invalidating the same signature being replayed.
provideWithPermit and provideForWithPermit expect the holder to sign their tokens and provide the signature to the contract as part of
permitData
When a provideWithPermit and provideForWithPermit transaction is in the mempool, an attacker can take this signature, and call the
permit
function on the token themselves.Since this is a valid signature, the token accepts it and increases the nonce.
This makes the spender's transaction fail whenever it gets mined.
-Impact
An attacker can ensure all calls to provideWithPermit and provideForWithPermit fail for the first time.
-Risk Breakdown
Difficulty to Exploit: Easy
Weakness:
CVSS2 Score:
-Recommendation
In the provideWithPermit and provideForWithPermit function, check if it has the approval it needs. If not, then only submit the permit signature.
if (IERC20(_token).allowance(owner, spender) < amount) { IERC20PermitUpgradeable(_token).permit(msg.sender, address(this), amount, deadline, v, r, s); }
Beta Was this translation helpful? Give feedback.
All reactions