The use of low level delegatecall in the FarmFacet and LibFarm contracts poses a significant risk if the facetcontract is self-destructed or if there's no code at the target address. This issue is not sufficiently handled by the current implementation, which also doesn't consider the msg.value sent along with the call,
considering the functions are payable.
The delegatecall opcode in Solidity returns success even if there is no contract code at the target address.
This situation can generally occur if the contract being delegate-called has been self-destructed or if the address is
not a contract. The current implementation of LibFarm does not check for the existence of contract code at
the facet address before performing the delegatecall, which can lead to potential loss of funds.
Contracts using FarmFacet and LibFarm rely on delegatecall to execute functions defined in various facets.
If the facet address is self-destructed, The delegatecall will return success, potentially causing loss of funds for the user.
Function calls will silently fail because of the behaviour of the delegatecall opcode.
Manual Review
To mitigate this issue, the LibFarm library should be updated to include a check for the existence of
contract code at the facet address before performing the delegatecall. Here is an updated implementation
of the _farm function that includes this check:
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.