Skip to content
Business logic Audit finding Intermediate

UniswapConfig getters return wrong token config if token config does not exist

The UniswapConfig contract's getter functions for token configurations incorrectly return the configuration of the first token (index 0) when queried for a non-existent token, because the non-existence check uses -1 while the index lookup returns 0. This could lead to wrong oracle prices, potentially allowing undercollateralized loans that cannot be liquidated.

Based Loans

Originally disclosed on Code4rena

The UniswapConfig.getTokenConfigBySymbolHash function does not work as getSymbolHashIndex returns 0 if there is no config token for that symbol (uninitialized map value), but the outer function implements the non-existence check with -1.

The same issue occurs also for:

  • getTokenConfigByCToken
  • getTokenConfigByUnderlying

When encountering a non-existent token config, it will always return the token config of the first index (index 0) which is a valid token config for a completely different token.

This leads to wrong oracle prices for the actual token which could in the worst case be used to borrow more tokens at a lower price or borrow more tokens by having a higher collateral value, essentially allowing undercollateralized loans that cannot be liquidated.

Recommend fixing the non-existence check.

ghoul-sol (Based Loans) confirmed:

Addressed in this PR

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

The non-existence check compares the index to -1, but the index lookup returns 0 for missing entries, so the check never triggers and the function returns the config at index 0.

Impact

Wrong oracle prices could be used to borrow more tokens at a lower price or with a higher collateral value, potentially allowing undercollateralized loans that cannot be liquidated.

What the attacker needed

None

The fix

The non-existence check should be fixed to correctly detect when a token config does not exist.

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.

This is a smart contract bug where a function that looks up token settings returns the settings of a different token when the requested token has no settings. That wrong information could make the system think a token is worth more or less than it really is, which might let someone borrow too much money.

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 Based Loans

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.