The TokenManager
contract contains functions tillIn
and withdraw
that handle native ETH transactions. These functions lack adequate access control, which could allow unauthorized users or contracts to deposit or withdraw ETH, potentially compromising the security of the contract.
The functions tillIn
and withdraw
handle ETH without strict checks on msg.sender
. The tillIn
function allows any caller to deposit ETH into the contract, and the withdraw
function allows any caller to withdraw ETH, assuming the contract's state allows it. This could be exploited by malicious actors to deposit and withdraw ETH without proper authorization.
Function tillIn
: Allows deposits of ETH without restricting who can call it. The check for sufficient ETH (msg.value < _amount
) cannot prevent unauthorized deposits.
Function withdraw
: Allows ETH withdrawals without restricting who can request a withdrawal. This function transfers ETH directly to the msg.sender
, potentially allowing unauthorized users to claim funds.
Unauthorized Deposits: Malicious users could deposit ETH into the contract, potentially crowding out legitimate operations or misappropriating funds.
Unauthorized Withdrawals: Attackers could withdraw ETH without proper authorization, leading to financial loss or unauthorized access to the contract’s funds.
The impact is high as it directly affects the contract's ability to manage ETH securely, risking potential financial losses and undermining the trust in the contract’s operations.
Forge
Foundry
To demonstrate the potential exploit, here is a simplified contract that interacts with the vulnerable TokenManager
contract:
Implement Access Control:
Add appropriate access control modifiers (e.g., onlyOwner
or custom role-based access control) to the tillIn
and withdraw
functions. Ensure that only authorized users or contracts can call these functions.
Verify ETH Handling:
Ensure that ETH deposits and withdrawals are handled securely. Consider adding checks to validate the caller's authorization and to prevent unauthorized access.
Invalid, withdrawals are gated to caller context `msg.sender`, not anybody. This acts as the access control and hence "owner", to withdraw collateral/points tokens after finalization of market actions.
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.