Missing contract existence checks for low-level calls #116
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Lines of code
https://github.com/code-423n4/2022-10-thegraph/blob/48e7c7cf641847e07ba07e01176cb17ba8ad6432/contracts/statechannels/GRTWithdrawHelper.sol#L56-L78
Vulnerability details
Impact
When doing low-level calls, it's necessary to not only check that the address is non-null, but that it has actual code. When a low-level call is made on a valid address that has no deployed code, the low level call always returns true. This may be the case of a
create2()
address hasn't yet had its contract deployed, or the contract has been destructed.In this case, the code uses the low level call as a sort of check for approval, assuming that failure to approve will block the transfer of the tokens that comes after it. If
tokenAddress
does not have any code deployed, the call toAPPROVE_SELECTOR
will pass, and theCOLLECT_SELECTOR
transfer that comes afterwards will be doneProof of Concept
https://github.com/code-423n4/2022-10-thegraph/blob/48e7c7cf641847e07ba07e01176cb17ba8ad6432/contracts/statechannels/GRTWithdrawHelper.sol#L56-L78
Tools Used
Code inspection
Recommended Mitigation Steps
require()
that the<address>.code.length
is non-zero before each low-level callThe text was updated successfully, but these errors were encountered: