Skip to content
Race condition Audit finding Intermediate

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.

pashap9990 Follow

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

Solidity
    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

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/AutoCompoundingPodLp.sol#L463

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/AutoCompoundingPodLp.sol#L214

Impact

Malicious actor can steal other users profit

Mitigation

Owner should pause deposit function when he/she wants to call AutoCompoundingPodLp::setYieldConvEnabled

The original report as published on Sherlock, by pashap9990. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

  1. Owner calls setYieldConvEnabled to enable reward processing.
  2. Attacker sees this transaction in the mempool and calls deposit before it is mined.
  3. Owner's transaction executes, increasing totalAssets.
  4. 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.

More by pashap9990

View all

12 more disclosed reports, best first.

More from Peapods

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.