Skip to content
Business logic Audit finding Intermediate

Missing checks if pairs equal tokens

Several library and contract functions do not verify that the length of a token path matches the number of tokens, nor that the tokens actually correspond to the pair. An attacker or careless caller could set a faulty liquidation path that causes liquidation transactions to revert.

Marginswap

Originally disclosed on Code4rena

The UniswapStyleLib.getAmountsOut, PriceAware.setLiquidationPath (and others) don’t check that path.length + 1 == tokens.length which should always hold true. Also, it does not check that the tokens actually match the pair. It’s easy to set faulty liquidation paths which then end up reverting the liquidation transactions.

The original report as published on Code4rena. 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 missing input validation: the functions assume the path and token arrays are consistent with the pair without checking lengths or contents.

Impact

Faulty liquidation paths could be set, causing liquidation transactions to revert; the text does not claim any theft or loss of funds.

What the attacker needed

Ability to set a liquidation path

The fix

The functions should validate that the path length matches the token count and that the tokens match the pair before use.

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.

Smart contracts often take a list of tokens describing a swap route. If the code never checks that this list lines up with the actual trading pair, someone can supply a mismatched list. The result is that the transaction fails instead of doing what was intended.

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 from Marginswap

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.