Open codehawks-bot opened 1 year ago
Escalate! +Insufficient validation leads to locking up prize tokens forever my finding is exaclty this finding and i explain how the funds will be stuck yet its finalized as low .Please reconsider this is perfect implementation of the bug and much more logical then the addres(0) finding https://github.com/Cyfrin/2023-08-sparkn/issues/897
Low level delegate call doesnt check if the contract code exist
Severity
High Risk
Relevant GitHub Links
https://github.com/Cyfrin/2023-08-sparkn/blob/0f139b2dc53905700dd29a01451b330f829653e9/src/Proxy.sol#L51C1-L64C6
Summary
Low level delegte call doesnt check if the contract code exist on address
Vulnerability Details
Delegate low level call has no ability to check if there's deployed contract code exist which delegating to ,So If proxy sending delegate call to empty address , call will success as everything went according to plan and this might lead to loss of funds cause in proxy factory there's no check if the implemantation contract is deployed.
Impact
The entire contest funds might stuck in proxy address cause of no implemantation existence check. Here's the POC for the scenario
This test will pass means delegatecall returns true from empty address...
Tools Used
Foundry test suite-Manuel Review
Recommendations
During an upgrade, check that the new logic contract has code. One solution is to use the extcodesize opcode. Alternatively, you can check for the existence of the target each time delegatecall is used. Here's usage for extcodesize