`LIEN_TOKEN.ownerOf(i)` should be `LIEN_TOKEN.ownerOf(liensRemaining[i])`
In the endAuction function, the code checks the owner of the wrong lien token ID, using the loop index instead of the actual lien token ID from the liensRemaining array. This causes incorrect recording of YIntercept and LienToken amounts, leading to wrong totalAssets accounting and potential loss of funds.
0xRajeev Follow with __141345__
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/259
Found by
0xRajeev, __141345__
Summary
In endAuction(), the check for public vault owner is referred to the wrong lien token id. And the actual vault lien amount is not properly recorded.
Vulnerability Detail
The lien token id should be queried is liensRemaining[i] instead of i.
Impact
YIntercept will not be correctly recorded. The accounting for LienToken amounts will be wrong. Hence the totalAssets on book will be wrong, eventually the contract and users could lose fund due to the wrong accounting.
Code Snippet
Tool used
Manual Review
Recommendation
Change LIEN_TOKEN.ownerOf(i) to LIEN_TOKEN.ownerOf(liensRemaining[i]).
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 mistakenly uses the loop index i instead of the value liensRemaining[i] when calling LIEN_TOKEN.ownerOf, causing the wrong lien token owner to be checked and incorrect accounting.
Impact
The YIntercept and LienToken amounts are recorded incorrectly, making totalAssets wrong and potentially causing the contract and users to lose funds due to the accounting error.
What the attacker needed
None
The fix
The code should be fixed by changing LIEN_TOKEN.ownerOf(i) to LIEN_TOKEN.ownerOf(liensRemaining[i]).
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 uses the wrong identifier when looking up who owns a token. Instead of using the actual token ID from a list, it uses the position in the list, so it checks the wrong owner and records incorrect amounts. This can make the contract's accounting wrong and potentially cause users to lose funds.
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.