DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Fee can be bypaassed on certain tokens

Vulnerability Details

_transferToken charges a governance fee from the amount to withdraw. This fee can easily be bypassed with a low decimal, high cost token like wbtc.

By splitting deposits into small chunks, and subsequently withdrawing the small chunks, even when a user is in profit, the calculation (amount - depositInfo[depositId].amount) * governanceFee will in more cases be less than BASIS_POINTS_DIVISOR and due to solidity's innate rounding down of division will always evaluate 0.

function _transferToken(uint256 depositId, uint256 amount) internal {
uint256 fee;
if (amount > depositInfo[depositId].amount) {
> fee = (amount - depositInfo[depositId].amount) * governanceFee / BASIS_POINTS_DIVISOR;
if (fee > 0) {
collateralToken.safeTransfer(treasury, fee);
}
}
try collateralToken.transfer(depositInfo[depositId].recipient, amount - fee) {}
catch {
collateralToken.transfer(treasury, amount - fee);
emit TokenTranferFailed(depositInfo[depositId].recipient, amount - fee);
}
totalDepositAmount -= depositInfo[depositId].amount;
emit GovernanceFeeCollected(address(collateralToken), fee);
}

This will occur much easily with a token like WBTC which on average is very expensive and also has relatively low decimal count compared to other tokens. It's also possible with a token like USDC due to it's also low decimal count. Also, low gas costs on arbitrum and avalanche will make multiple small deposits relatively cheaper, compared to a chain like ethereum mainnet.

Recommendations

Round up fee calculations in favour of protocol.

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!