There is a critical mismatch between the comment and the actual implementation of the withdraw()
function in the TokenManager contract. The comment states that the caller must be the owner, but the function can be called by any user when the contract is not paused.
The withdraw()
function is currently commented like this:
However, the actual implementation allows any user to call the function when the contract is not paused:
The function only has the whenNotPaused
modifier and lacks any onlyOwner
or similar access control.
This discrepancy could lead to several issues:
Misuse of the contract: Developers or users relying on the comment might assume that only the owner can withdraw, leading to incorrect assumptions about the contract's security model.
Unintended fund withdrawal: If the contract was designed with the intention that only the owner should be able to withdraw, the current implementation allows any user to withdraw their balance, which could lead to unexpected behavior or loss of funds.
Auditing difficulties: The mismatch between comments and implementation can make the code harder to audit and understand, potentially hiding other vulnerabilities.
Manual code review
Align the implementation with the comment:
If the intention is that only the owner should be able to withdraw, modify the function to include the onlyOwner
modifier:
Alternatively, update the comment to reflect the actual implementation:
If the current implementation is correct and any user should be able to withdraw their own balance, update the comment to accurately describe the function's behavior:
By addressing this discrepancy, you will significantly improve the contract's clarity, reduce the risk of misuse, and make it easier for developers and auditors to understand the intended behavior of the contract.
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.