Fee is charged current reserveToken pool balance to time which is not updated
The fee calculation uses the current reserve token balance multiplied by the entire time since the last fee claim, rather than the balance that was actually held over that period. An attacker could cause fees to be overcharged or undercharged by depositing or redeeming tokens just before a fee claim.
Source: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/842
Found by
0x52, 0xDemon, 0xadrii, 0xlucky, 0xmystery, Abhan1041, Beejay, BugAttacker, ChainProof, Darinrikusham, DeLaSoul, Etherking, Goran, Harry_cryptodev, JohnTPark24, Kirkeelee, KupiaSec, Kyosi, MysteryAuditor, Pablo, Saurabh_Singh, Strapontin, ZeroTrust, ZoA, appet, bigbear1229, bladeee, bretzel, bube, davidjohn241018, dobrevaleri, farismaulana, future, moray5554, novaman33, pessimist, prosper, sl1, t0x1c, tvdung94, ydlee
Summary
Here fee is charged from lastFeeClaimTime to current time but with current reserveToken token pool balance. But fee should be charged on every reserveToken balance is changed. That can be accomplished via claimFees function is invoked every user create and redeem activities.
Root Cause
Fee is charged based on current reserveToken balance where feeBeneficiary is invoked claimFees function. But time to time reserveToken can be changed. So fee should be calculated each and every time when reserveToken balance is changed.
function claimFees() public nonReentrant {
require(msg.sender == feeBeneficiary || poolFactory.hasRole(poolFactory.GOV_ROLE(), msg.sender), NotBeneficiary());
uint256 feeAmount = getFeeAmount();
if (feeAmount == 0) {
revert NoFeesToClaim();
}
lastFeeClaimTime = block.timestamp;
IERC20(reserveToken).safeTransfer(feeBeneficiary, feeAmount);
emit FeeClaimed(feeBeneficiary, feeAmount);
}
/**
* @dev Returns the amount of fees to be claimed.
* @return The amount of fees to be claimed.
*/
function getFeeAmount() internal view returns (uint256) {
return (IERC20(reserveToken).balanceOf(address(this)) * fee * (block.timestamp - lastFeeClaimTime)) / (PRECISION * SECONDS_PER_YEAR);
}
Internal Pre-conditions
Can happen in normal operation.
External Pre-conditions
None
Attack Path
- Consider this scenario , pool is consist of 10e18 reserveToken throughout the year at the year end , some one is deposited 1000e18 reserveToken , now
feeBeneficiaryis calledclaimFees, here fee is overcharged. meaning fee is calculated as 1000e18 token is in pool throughout the year. - pool is consist of 1000e18 reserveToken through out the year at the year end , most of users are redeem , due to that reserveToken balance is 10e18 , now
feeBeneficiaryis calledclaimFees, here fee is undercharged. meaning fee is calculated as 10e18 token is in pool throughout the year.
Impact
- Fee is not collected correctly so that it could be overcharged or undercharged .
PoC
No response
Mitigation
claimFees can be invoked inside of _create and _redeem functions.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/Convexity-Research/plaza-evm/pull/164
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The fee calculation multiplies the current reserve token balance by the entire elapsed time since the last claim, without accounting for changes in balance during that period.
Impact
Fees could be overcharged or undercharged, leading to incorrect fee collection.
What the attacker needed
None
The fix
The protocol team fixed this issue by invoking claimFees inside the _create and _redeem functions.
How it was found
- Pool holds 10e18 reserveToken for the whole year.
- At year end, someone deposits 1000e18 reserveToken.
- feeBeneficiary calls claimFees, and the fee is overcharged because it is calculated as if 1000e18 tokens were present all year.
- Alternatively, pool holds 1000e18 reserveToken for the whole year.
- At year end, most users redeem, leaving 10e18 reserveToken.
- feeBeneficiary calls claimFees, and the fee is undercharged because it is calculated as if only 10e18 tokens were present all year.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A fee is taken from a pool of tokens, and the amount is based on how many tokens are in the pool and how long it has been since the last fee was taken. The mistake is that it uses the current number of tokens for the whole time period, even if that number changed recently. So someone can add or remove tokens just before the fee is taken to make the fee too high or too low.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.