Skip to content
Business logic Audit finding Intermediate

wrong YAXIS estimates

The Harvester.getEstimates function used a WETH input amount to compute a YAXIS to WETH trade, producing incorrect estimates. These wrong estimates could cause harvest transactions to revert or allow large slippage, enabling sandwich attacks.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

The Harvester.getEstimates contract tries to estimate a YAXIS amount but uses the wrong path and/or amount.

It currently uses a WETH input amount to compute a YAXIS -> WETH trade.

address[] memory _path;
_path[0] = IStrategy(_strategy).want();
_path[1] = IStrategy(_strategy).weth();
// ...

_path[0] = manager.yaxis();
// path is YAXIS -> WETH now
// fee is a WETH precision value
uint256 _fee = _estimatedWETH.mul(manager.treasuryFee()).div(ONE_HUNDRED_PERCENT);
// this will return wrong trade amounts
_amounts = _router.getAmountsOut(_fee, _path);
_estimatedYAXIS = _amounts[1];

Impact

The estimations from getEstimates are wrong. They seem to be used to provide min. amount slippage values (_estimatedWETH, _estimatedYAXIS) for the harvester when calling Controller._estimatedYAXIS. These are then used in BaseStrategy._payHarvestFees and can revert the harvest transactions if the wrongly computed _estimatedYAXIS value is above the actual trade value. Or they can allow a large slippage if the _estimatedYAXIS value is below the actual trade value, which can then be used for a sandwich attack.

Recommended Mitigation Steps

Fix the estimations computations.

As the estimations are used in BaseStrategy._payHarvestFees, the expected behavior seems to be trading WETH to YAXIS. The path should therefore be changed to path[0] = WETH; path[1] = YAXIS in Harvester.getEstimates.

Haz077 (yAxis) acknowledged

GalloDaSballo (judge) commented:

Price estimates on Uniswap are dependent on which side of the swap you’re making

Sponsor has mitigated in later PR

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

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 code used a WETH input amount to compute a YAXIS to WETH trade, instead of the correct WETH to YAXIS direction.

Impact

The wrong estimates could revert harvest transactions or allow a large slippage, which can then be used for a sandwich attack.

What the attacker needed

None

The fix

The path should be changed to WETH -> YAXIS in Harvester.getEstimates.

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 smart contract tried to guess how many tokens it would get when swapping, but it used the wrong token as the starting point. This made the guess wrong, which could either stop the swap from working or let an attacker take advantage of the price difference.

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.

More by cmichel

View all

196 more disclosed reports, best first.

More from yAxis contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.