Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: medium

Contest second distribution attempt would consume all gas

Summary

Attempting (either intentionally or accidentally) to distribute prizes collected in contest at the second time would cause a revert (as it should), but not in a normal way, consuming all gas sent - which is a really unnecessary loss of funds.

Vulnerability Details

A second attempt to distribute prizes collected in a certain contest also means a second attempt to deploy a proxy for that contest - because all the functions that invoke prizes distribution (deployProxyAndDistribute and deployProxyAndDistributeBySignature) also deploy a proxy with a specific salt. Thus, any second attempt of distribution would result in a second attempt to deploy a proxy with the same salt, which will revert with the INVALID opcode, an opcode that will cause the consumption of all remaining gas.

Impact

Unnecessary consumption of all gas on revert - which can be easily considered as loss of funds.

Recommendations

Revert normally using the revert keyword if the proxy contract has already been deployed with that specific salt. You should probably keep some sort of mapping of already used salts to implement that.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!