This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
Shawler - attacker can grief repayBorrowWithERC20Permit and stakeWithERC20Permit via permit front-running #67
Labels
Non-Reward
This issue will not receive a payout
Shawler
Medium
attacker can grief repayBorrowWithERC20Permit and stakeWithERC20Permit via permit front-running
Summary
Potential griefing vector of
stakeWithERC20Permit
andrepayBorrowWithERC20Permit
having a pre-signed approval ('permit') signature attached(e.g., no profit motive for an attacker but spoils UX for users of the protocol) by front-running the 'token.permit' calls with intercepted from mempool signatures.
repayBorrowWithERC20Permit
stakeWithERC20Permit
Root Cause
The
stakeWithERC20Permit
andrepayBorrowWithERC20Permit
functions integrate the permit feature to combine approval and transaction processes into a single step, streamlining operations by eliminating the need for two separate transactions.ERC20Permit employs a nonce mapping for safeguarding against replay attacks. When a signature is validated and processed, the corresponding nonce is incremented, rendering the same signature unusable for subsequent transactions. Both the
stakeWithERC20Permit
andrepayBorrowWithERC20Permit
functions require users to authorize their tokens for use by theUserManagerERC20
andUErc20
contract addresses, respectively, as spenders. Users must submit these transactions along with their digital signatures—specified byuint8 v, bytes32 r, bytes32 s
.reference lido permit issue
Attack Path
This valid signature is accepted by the token contract, which then updates the nonce accordingly. As a result, when the original user transaction attempts to process, it fails due to the already updated nonce.
Impact
When a user’s transaction resides in the mempool awaiting confirmation, an attacker could potentially exploit this by using the observed signature to preemptively execute the
token.permit
function with the publicly available parameters.Mitigation
reference
Duplicate of #65
The text was updated successfully, but these errors were encountered: