`commitToLiens` always reverts
The commitToLiens function in the AstariaRouter contract always reverts because it tries to return collateral that was already minted to the borrower rather than the router. This prevents borrowers from depositing collateral and requesting loans, blocking the protocol's core lending flow.
bin2chen Follow with HonorLt, rvierdiiev and 2 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/204
Found by
bin2chen, HonorLt, rvierdiiev, Jeiwan, 0xRajeev
Summary
The function commitToLiens() always reverts at the call to _returnCollateral() which prevents borrowers from depositing collateral and requesting loans in the protocol.
Vulnerability Detail
The collateral token with collateralId is already minted directly to the caller (i.e. borrower) in commitToLiens() at the call to _transferAndDepositAsset() function. That's because while executing _transferAndDepositAsset the NFT is transferred to COLLATERAL_TOKEN whose onERC721Received mints the token with collateralId to borrower (from address) and not the operator_ (i.e. AstariaRouter) because operator_ != from_.
However, the call to _returnCollateral() in commitToLiens() incorrectly assumes that this has been minted to the operator and attempts to transfer it to the borrower which will revert because the collateralId is not owned by AstariaRouter as it has already been transferred/minted to the borrower.
Impact
The function commitToLiens() always reverts, preventing borrowers from depositing collateral and requesting loans in the protocol, thereby failing to bootstrap its core NFT lending functionality.
Code Snippet
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/AstariaRouter.sol#L244-L274
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/AstariaRouter.sol#L578-L587
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/CollateralToken.sol#L282-L284
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/AstariaRouter.sol#L589-L591
Tool used
Manual Review
Recommendation
Remove the call to _returnCollateral() in commitToLiens().
Discussion
secureum
Escalate for 2 USDC.
Given the impact of failing to bootstrap core protocol functionality as described above, we still think this is of high-severity (not Medium as judged) unlike a DoS that affects only a minority of protocol flows. Also, this is not a dup of #195.
cc @berndartmueller @lucyoa
sherlock-admin
Escalate for 2 USDC.
Given the impact of failing to bootstrap core protocol functionality as described above, we still think this is of high-severity (not Medium as judged) unlike a DoS that affects only a minority of protocol flows. Also, this is not a dup of #195.
cc @berndartmueller @lucyoa
You've created a valid escalation for 2 USDC!
To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Evert0x
Escalation accepted
sherlock-admin
Escalation accepted
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
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 assumes the collateral NFT is minted to the router (operator) when it is actually minted to the borrower, so the subsequent transfer from the router reverts.
Impact
The function always reverts, so borrowers cannot deposit collateral or request loans, breaking the protocol's core NFT lending functionality.
What the attacker needed
None
The fix
The call to _returnCollateral() in commitToLiens() should be removed.
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 is a program that runs on a blockchain and can hold digital assets. Here, a function meant to let people deposit an NFT as collateral and ask for a loan always fails, because it tries to move an NFT that the contract does not actually own. As a result, nobody can use the main lending feature.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.