Function claimFighter() enables users to claim a pre-determined number of fighters. This function verifies if the message signature is from the delegated address. However, the calculation of the signature does not take into a consideration block.chainid. This implies, that when smart contract will be deployed on the different chain - it will be possible to re-use the signature.
As demonstrated above, msgHash does not use block.chaind to create a hash which is then verified.
This means that both signature and msgHash will be the same for different blockchains, thus it is possible to re-use signature on the different block.chainid.
Tools Used
Manual code review
Recommended Mitigation Steps
Make sure to include block.chainid into msgHash calculations. That way, msgHash will be different on different blockchains, thus the signature re-use won't be possible, becuase the msgHash on different blockchain wouldn't match the signature from another blockchain.
Lines of code
https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/FighterFarm.sol#L199-L206
Vulnerability details
Impact
Function
claimFighter()
enables users to claim a pre-determined number of fighters. This function verifies if the message signature is from the delegated address. However, the calculation of the signature does not take into a considerationblock.chainid
. This implies, that when smart contract will be deployed on the different chain - it will be possible to re-use the signature.Proof of Concept
File: FighterFarm.sol
As demonstrated above,
msgHash
does not useblock.chaind
to create a hash which is then verified.This means that both
signature
andmsgHash
will be the same for different blockchains, thus it is possible to re-use signature on the differentblock.chainid
.Tools Used
Manual code review
Recommended Mitigation Steps
Make sure to include
block.chainid
intomsgHash
calculations. That way,msgHash
will be different on different blockchains, thus the signature re-use won't be possible, becuase themsgHash
on different blockchain wouldn't match the signature from another blockchain.Assessed type
Other