code-423n4 / 2023-01-rabbithole-findings

1 stars 2 forks source link

`mintReceipt` might mint NFT's even if the signature is not valid. #629

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/QuestFactory.sol#L223

Vulnerability details

Impact

If the contract accepts invalid signatures for minting, this will lead to a potential drainage of rewards

Proof of Concept

Consider the following scenario:

1) An admin changes the claimSignerAddress to 0x0 in order to prevent any further mintings or for any other reasons.

2) While the claimSignerAddress now is 0x0, all signatures will pass due to the following line:

if (recoverSigner(hash_, signature_) != claimSignerAddress) revert AddressNotSigned();

The problem here lies in the recover function, which returns 0x0 if the signature is not signed.

3) Any address can mint any desired NFT with any signature.

IIRC this was even an issue why a famous bridge-hack happened, but im unsure which one it was right now.

Tools Used

VSCode

Recommended Mitigation Steps

Consider implementing the following additional check within the mintReceipt function:

if (recoverSigner(hash_, signature_) == address(0) revert AddressNotSigned();

Moreover, the claimSignerAddress should obviously have a non-zero check in the setter but this is a known-issue.

c4-judge commented 1 year ago

kirk-baird marked the issue as unsatisfactory: Invalid

kirk-baird commented 1 year ago

This is not true, ECDSA.recover() will check to ensure the zero address is not returned by ecrecover()