The contract's use of the delegatecall
operation in the fallback function can lead to unintended behavior and unauthorized access due to a lack of proper context separation between the proxy and implementation contracts.
The delegatecall
operation within the fallback function can allow the implementation contract to manipulate and access the proxy contract's storage variables and state. While the intention is to delegate calls to the implementation contract, the nature of delegatecall
makes it execute the code of the implementation contract as if it were running within the proxy contract's context. This can result in unintended interactions, unauthorized access, and potential security vulnerabilities.
Consider a scenario where an attacker crafts a malicious implementation contract with the intent of exploiting this behavior:
In this example, the malicious implementation contract sets up an owner during its construction. The takeOwnership
function is designed to allow ownership transfer, but the authorization check is flawed, relying on msg.sender
, which is not isolated between the proxy and implementation contracts due to the use of delegatecall
.
An attacker could craft a transaction to call the takeOwnership
function through the proxy. The attacker would set the _newOwner
parameter to their own address, and because the msg.sender
context is from the proxy, the attacker would gain unauthorized ownership of the malicious implementation contract.
An attacker could gain unauthorized control over crucial contract functionality, manipulate state variables, and potentially drain funds or disrupt contract behavior.
Manual
Use a more secure proxy pattern that provides proper context isolation between the proxy and implementation contracts. Also,
implement a contract existence check before each delegatecall
.
Carefully review the Solidity documentation, especially the “Warnings” section,
and the pitfalls of using the delegatecall proxy pattern.
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.