Lack of chainID validation allows reuse of signatures across forks
Summary
The chainID is set at initializing and can't be changed. In the event of a post-deployment chain hard fork, the chainID cannot be updated, and signatures may be replayed across both versions of the chain.
pontifex
medium
Lack of chainID validation allows reuse of signatures across forks
Summary
The chainID is set at initializing and can't be changed. In the event of a post-deployment chain hard fork, the chainID cannot be updated, and signatures may be replayed across both versions of the chain.
Vulnerability Detail
A domain separator and the chainID are included in the signature schema at the
GSPVault.permit
function. https://github.com/sherlock-audit/2023-12-dodo-gsp/blob/af43d39f6a89e5084843e196fc0185abffe6304d/dodo-gassaving-pool/contracts/GasSavingPool/impl/GSPVault.sol#L325 However, this chainID is fixed at the time of initializing. https://github.com/sherlock-audit/2023-12-dodo-gsp/blob/af43d39f6a89e5084843e196fc0185abffe6304d/dodo-gassaving-pool/contracts/GasSavingPool/impl/GSP.sol#L80-L94 In the event of a post-deployment chain hard fork, the chainID cannot be updated, and signatures may be replayed across both versions of the chain. As a result, an attacker could reuse signatures to receive user funds on both chains.Impact
An attacker can reuse signatures to receive user funds in case of a post-deployment chain hard fork.
Code Snippet
https://github.com/sherlock-audit/2023-12-dodo-gsp/blob/af43d39f6a89e5084843e196fc0185abffe6304d/dodo-gassaving-pool/contracts/GasSavingPool/impl/GSPVault.sol#L325 https://github.com/sherlock-audit/2023-12-dodo-gsp/blob/af43d39f6a89e5084843e196fc0185abffe6304d/dodo-gassaving-pool/contracts/GasSavingPool/impl/GSP.sol#L80-L94
Tool used
Manual Review
Recommendation
To prevent post-deployment forks from affecting calls to permit, detect chainID changes and regenerate the domain separator when necessary.
Duplicate of #113