SyrupRouter::depositWithPermit() may be DoSed by frontrunning ERC20::permit()
Description
SyrupRouter::depositWithPermit() uses the permit functionality of the asset by calling IERC20Like(asset).permit(owner_, address(this), amount_, deadline_, v_, r_, s_);.
Some griefer may spot the SyrupRouter::depositWithPermit() transaction, frontrun it and call the IERC20Like::permit() function directly, spending the nonce of the signature and DoSing the router.
Recommendation
An attacker has no profit from executing so it is not expected to happen, but some measures could still be taken.
Some examples are:
- Get the allowance and only call IERC20Like::permit() if it is smaller than amount_.
- Use try/catch.
- Flashbots.
Status
Addressed in #cb70312