Handsome Lemon Tapir
Medium
Using an immutable DOMAIN_SEPARATOR
will invalidate signatures upon hardfork or possible replay attack.
Using block.chainid
to calculate the immutable DOMAIN_SEPARATOR
in the constructors of both VVVVCInvestmentLedger.sol
and VVVVCTokenDistributor.sol
will cause signatures to become invalid after a hardfork, as the chain ID value changes but the DOMAIN_SEPARATOR
remains immutable.
In the constructors of VVVVCInvestmentLedger.sol
and VVVVCTokenDistributor.sol
, the DOMAIN_SEPARATOR
is calculated using block.chainid
and marked as immutable. This becomes problematic if a blockchain undergoes a hardfork, changing the chainid. Since the DOMAIN_SEPARATOR
is immutable, it retains the old chainid, leading to invalid signatures and could cause possible replay attacks.
- https://github.com/sherlock-audit/2024-11-vvv-exchange-update/blob/main/vvv-platform-smart-contracts/contracts/vc/VVVVCInvestmentLedger.sol?plain=1#L25
- https://github.com/sherlock-audit/2024-11-vvv-exchange-update/blob/main/vvv-platform-smart-contracts/contracts/vc/VVVVCInvestmentLedger.sol?plain=1#L127-L134
- https://github.com/sherlock-audit/2024-11-vvv-exchange-update/blob/main/vvv-platform-smart-contracts/contracts/vc/VVVVCTokenDistributor.sol?plain=1#L25
- https://github.com/sherlock-audit/2024-11-vvv-exchange-update/blob/main/vvv-platform-smart-contracts/contracts/vc/VVVVCTokenDistributor.sol?plain=1#L92-L99
No response
A blockchain hardfork that changes the chainid
occurs.
No response
The users cannot successfully verify signatures as the DOMAIN_SEPARATOR
is incorrect due to the use of an outdated chainid. This results in the inability to execute functions relying on valid signatures, such as claim or invest, rendering portions of the contracts non-functional.
Observe the constructors:
- https://github.com/sherlock-audit/2024-11-vvv-exchange-update/blob/main/vvv-platform-smart-contracts/contracts/vc/VVVVCInvestmentLedger.sol?plain=1#L127-L134
- https://github.com/sherlock-audit/2024-11-vvv-exchange-update/blob/main/vvv-platform-smart-contracts/contracts/vc/VVVVCTokenDistributor.sol?plain=1#L92-L99
As we can see the chainId is derived and then hardcoded in DOMAIN_SEPARATOR
. so after hard fork, DOMAIN_SEPARATOR
value will remain same and point to incorrect chainId
Instead of using an immutable DOMAIN_SEPARATOR
initialized with block.chainid in the constructor, introduce a function to allow updating the DOMAIN_SEPARATOR
in case of a hardfork or use a mechanism that dynamically generates the DOMAIN_SEPARATOR
during signature verification.