Treasury.sol:: deposit Treasury.sol::withdraw
The transferFrom function is called to transfer tokens from the caller (msg.sender) to the Treasury contract:
The transfer function is called to transfer tokens from the Treasury contract to the recipient:
Both the deposit and withdraw functions contain unchecked return values for ERC20 transferFrom and transfer calls
Silent Failures: If the transferFrom or transfer call fails, the contract will not revert, and the failure will go unnoticed.
State Inconsistency: The contract updates its state (e.g., _balances and _totalValue) assuming the transfer was successful, but if the transfer fails, the state will be incorrect.
Funds Loss: In the withdraw function, if the transfer fails, the tokens will not be sent to the recipient, but the contract will reduce the balance, effectively losing the tokens.
Manual Review
To fix this issue, you should always check the return value of transfer and transferFrom. Here are the recommended fixes:
Use SafeERC20 Library
The contract already imports the SafeERC20 library, which provides safeTransfer and safeTransferFrom functions that revert if the transfer fails. Replace the transfer and transferFrom calls with safeTransfer and safeTransferFrom:
Manually Check the Return Value
If you prefer not to use SafeERC20, you can manually check the return value of transfer and transferFrom:
Add a Custom Error
Define a custom error for failed transfers:
LightChaser Low-60
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.