The supplyWithPermit() and repayWithPermit() functions utilises the permit function so that approve and pull operations can happen in a single transaction instead of two consecutive transactions.
Vulnerability Details
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.
supplyWithPermit() expects the holder to sign their tokens and provide the signature in function parameter.
When a supplyWithPermit() transaction is in the mempool, an attacker can take this signature, call the permit function on the token themselves.
Since this is a valid signature, the token accepts it and increases the nonce.
As a result victim transaction will revert, whenever it gets mined becuase the nonce has been already use.
Check POC for more detail.
Impact Details
Attacker can invalidate users supplyWithPermit() and repayWithPermit() transactions.
While Attacker does not profit from this, it harms users (gas fee and opportunity cost) and protocols reputation.
Recommendation
In repayWithPermit and supplyWithPermit function, check if it has the approval it needs. If not, then only submit the permit signature.
Given the fix is simple, I would suggest to implement it as there is also possibility that sophisticated attacker might uses this to delay users repay() transaction and gain advantage.
References
Add any relevant links to documentation or code
Proof of Concept
Following is POCs demonstrating the attack vector on Manta-Pacific fork in foundry..
To recreate please enter your RPC, and then run "forge test"