Platform: Code4rena
Start Date: 16/09/2021
Pot Size: $200,000 SUSHI
Total HM: 26
Participants: 16
Period: 14 days
Judge: alcueca
Total Solo HM: 13
Id: 29
League: ETH
Rank: 16/16
Findings: 1
Award: $115.80
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: nikitastupin
9.2639 SUSHI - $115.80
t11s
If the chain was to fork (or someone was to sign messages to use permit on a local fork), permit signatures made on either fork could be replayed on the other. This could allow users who permit to each other (or contracts that can be upgraded) to steal funds from each other.
The DOMAIN_SEPARATOR is set in the constructor, which causes this issue. If block.chainid changes the DOMAIN_SEPARATOR separator will not be updated.
This is advised against in the security considerations section of EIP2612: https://eips.ethereum.org/EIPS/eip-2612
"If the DOMAIN_SEPARATOR contains the chainId and is defined at contract deployment instead of reconstructed for every signature, there is a risk of possible replay attacks between chains in the event of a fututre chain split."
None.
Either compute DOMAIN_SEPARATOR on the fly for each permit or cache a starting value in the constructor, and if chainid changes fall back to recomputing on the fly.
Here are some implementations of this:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/draft-EIP712.sol https://github.com/yieldprotocol/yield-utils-v2/blob/main/contracts/token/ERC20Permit.sol https://github.com/boringcrypto/BoringSolidity/blob/master/contracts/Domain.sol https://github.com/dapp-org/dappsys-v2/blob/a59e20576ef9febcd8ac350f8fad363e55c5277a/src/token.sol#L96-L98
#0 - maxsam4
2021-09-22T08:54:47Z
I knew this was coming xD
We fixed this in our codebase after your tweet. However, I agree with Dan on this. There are much bigger problems if the network forks than replaying. Therefore, this is an unrealistic scenario with limited impact.
I'd suggest changing the severity to 1.
#1 - alcueca
2021-10-25T05:59:14Z
We could have a long discussion here, and I would prefer to stop reporting this vulnerability as it really is unrealistic. However, the sponsor confirmed and fixed it, so I can't dismiss it.
As a low-effort find, I'm downgrading it to 1 out of respect to real severity 2's found.
#2 - alcueca
2021-10-30T04:40:06Z
Duplicate of #18