Bad message digest can allow attacker to force prizes to be distributed based on the implementation of the old implementation contract.
The distributor contract is meant to be upgradable as understood from the natspec. A new implementation address can be used when a contest is created. The key issue to this vulnerability lies in how the message digest contains only contestId
and data
in deployProxyAndDistributeBySignature()
. We will illustrate how this may happen.
Owner sets contest inputting organizer
, contestId
, closeTime
, implementation
For a variety of reasons, for instance the implementation contract contains some bugs/issues, owner wants to upgrade to a new implementation
Owner sets a new contest inputting the same organizer
, contestId
, closeTime
, but with a different implementation
Now, during distribution, the organizer
wants to distributes using signature with deployProxyAndDistributeBySignature()
Attacker sees this, uses the same signature with the same message digest and calls deployProxyAndDistributeBySignature()
but with the old implementation contract, instead of the new one which organizer wants to use
The prize is distributed based on the logic of the old implementation contract, which can be faulty/potential loss of funds.
The organizer who intends to distribute based on a new distributor contract can be frontrunned and forced to distribute based on a wrong and unintended implementation contract.
Manual Review
Consider adding the implementation address as part of the message digest. Instead of using _hashTypedDataV4(keccak256(abi.encode(contestId, data)))
, we use _hashTypedDataV4(keccak256(abi.encode(contestId, data, implementation)))
.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.