Collected fees are never transferred out of Pool contract
The Gondi Pool contract credits fees to an internal counter but never transfers them out, so the funds remain locked in the contract indefinitely. An attacker could not directly steal these fees, but the value is permanently stuck, representing a leak of value.
minhquanym Follow with oakcobalt and bin2chen
Originally disclosed on Code4rena
Submitted by minhquanym, also found by oakcobalt and bin2chen
Lenders in the Gondi protocol could be EOA or Gondi Pool. The Gondi Pool, an ERC4626, allows anyone to deposit funds and earn yield from lending on Gondi. When a loan is repaid or liquidated, the pool deducts a fee from the received amount before adding the rest to the pool balance. As shown in the loanRepayment() function, the fees are calculated by calling processFees() and then added to getCollectedFees. After that, the accounting function _loanTermination() is called with the amount being received - fees.
However, this fee is credited to getCollectedFees but never transferred out of the pool. As a result, these funds remain locked in the contract indefinitely.
function loanRepayment(
uint256 _loanId,
uint256 _principalAmount,
uint256 _apr,
uint256,
uint256 _protocolFee,
uint256 _startTime
) external override onlyAcceptedCallers {
uint256 netApr = _netApr(_apr, _protocolFee);
uint256 interestEarned = _principalAmount.getInterest(netApr, block.timestamp - _startTime);
uint256 received = _principalAmount + interestEarned;
uint256 fees = IFeeManager(getFeeManager).processFees(_principalAmount, interestEarned);
getCollectedFees += fees; // @audit getCollectedFees is never transfer out
_loanTermination(msg.sender, _loanId, _principalAmount, netApr, interestEarned, received - fees);
}
Proof of Concept
The processFees() function only calculates the fee but doesn’t transfer anything.
function processFees(uint256 _principal, uint256 _interest) external view returns (uint256) {
/// @dev cached
Fees memory __fees = _fees;
return _principal.mulDivDown(__fees.managementFee, PRECISION)
+ _interest.mulDivDown(__fees.performanceFee, PRECISION);
}
Then after getCollectedFees is credited for fees, we can see this getCollectedFees is never transferred out of the pool.
Recommended Mitigation Steps
Add a function to collect the credited fees getCollectedFees from the pool in the FeeManager contract.
0xend (Gondi) confirmed and commented:
Not sure if it’s High; tend to think as high as those that would compromise user’s assets. Definitely an issue though.
0xA5DF (judge) decreased severity to Medium and commented:
Marking as med as fees falls under the definition ‘leak of value’.
Added
collectFeesmethod.
Status: Mitigation confirmed. Full details in reports from oakcobalt, minhquanym and bin2chen.
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
Likely the FeeManager contract lacks a function to withdraw the accumulated fees from the Pool, so the credited amount is never transferred out.
Impact
The fees remain locked in the pool contract indefinitely, resulting in a leak of value for the protocol.
What the attacker needed
None
The fix
The issue was mitigated by adding a `collectFees` method to the FeeManager contract.
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.
In a lending pool, when borrowers repay with interest, a small fee is taken for the protocol. Here, the pool correctly calculates that fee and adds it to a running total, but there is no function to actually move that money out of the pool contract. So the fees pile up inside the contract and nobody can retrieve them, meaning the protocol loses that revenue.
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.