Malicious actors can front-run setYieldConvEnabled
The owner can enable reward processing via setYieldConvEnabled, which sharply increases totalAssets. An attacker can front-run this transaction by depositing before the owner's transaction, then withdraw after totalAssets increases to capture a share of the rewards.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/313
Found by
pashap9990
Root Cause
AutoCompoundingPodLp'owner can enable or disable processing reward tokens through AutoCompoundingPodLp::setYieldConvEnabled but when owner decides to enable with sets yieldConvEnabled to true this causes _totalAssets will be increase sharply
function _processRewardsToPodLp(uint256 _amountLpOutMin, uint256 _deadline) internal returns (uint256 _lpAmtOut) {
@>>>> if (!yieldConvEnabled) {
return _lpAmtOut;
}
address[] memory _tokens = ITokenRewards(IStakingPoolToken(_asset()).POOL_REWARDS()).getAllRewardsTokens();
uint256 _len = _tokens.length + 1;
for (uint256 _i; _i < _len; _i++) {
address _token = _i == _tokens.length ? pod.lpRewardsToken() : _tokens[_i];
uint256 _bal =
IERC20(_token).balanceOf(address(this)) - (_token == pod.PAIRED_LP_TOKEN() ? _protocolFees : 0);
if (_bal == 0) {
continue;
}
uint256 _newLp = _tokenToPodLp(_token, _bal, 0, _deadline);
_lpAmtOut += _newLp;
}
@>>> _totalAssets += _lpAmtOut;
require(_lpAmtOut >= _amountLpOutMin, "M");
}
Internal Conditions
yieldConvEnabled = false
PoC
Let's assume there is reward tokens in AutoCompoundingPodLp contract and AutoCompoundingPodLp::setYieldConvEnabled will be called by contract's owner and then malicious actor see transaction in mempool and calls AutoCompoundingPodLp:deposit. hence, totalAssets wouldn't update because yieldConvEnabled is false and when owner's transaction will be executed
totalAssets will be updated and malicious actor can withdraw his/her assets plus profit
Code Snippet
Impact
Malicious actor can steal other users profit
Mitigation
Owner should pause deposit function when he/she wants to call AutoCompoundingPodLp::setYieldConvEnabled
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 deposit function does not account for pending rewards when yieldConvEnabled is false, so a depositor can enter at a lower share price and benefit from the subsequent increase in totalAssets.
Impact
A malicious actor could steal other users' profit by front-running the owner's transaction.
What the attacker needed
YieldConvEnabled is false; reward tokens are present in the contract; attacker can see pending transactions
The fix
The owner should pause the deposit function when calling setYieldConvEnabled.
How it was found
- Owner calls setYieldConvEnabled to enable reward processing.
- Attacker sees this transaction in the mempool and calls deposit before it is mined.
- Owner's transaction executes, increasing totalAssets.
- Attacker withdraws and receives a profit from the rewards.
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.
When the owner turns on reward processing, the contract's total assets jump because rewards are converted. An attacker can watch for this transaction and quickly deposit just before it, then withdraw just after, taking a cut of the rewards they did not earn.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.