_deleteLienPosition can be called by anyone to delete any lien they wish
The function _deleteLienPosition is public and lacks caller validation, allowing anyone to delete any lien from any collateral. This could let a borrower bypass the release check and withdraw collateral without repaying the loan, effectively stealing lender funds.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/233
Found by
TurnipBoy, 0x0, obront, tives, yixxas, ctf_sec, zzykxx
Summary
_deleteLienPosition is a public function that doesn't check the caller. This allows anyone to call it an remove whatever lien they wish from whatever collateral they wish
Vulnerability Detail
function _deleteLienPosition(uint256 collateralId, uint256 position) public {
uint256[] storage stack = liens[collateralId];
require(position < stack.length, "index out of bounds");
emit RemoveLien(
stack[position],
lienData[stack[position]].collateralId,
lienData[stack[position]].position
);
for (uint256 i = position; i < stack.length - 1; i++) {
stack[i] = stack[i + 1];
}
stack.pop();
}
_deleteLienPosition is a public function and doesn't validate that it's being called by any permissioned account. The result is that anyone can call it to delete any lien that they want. It wouldn't remove the lien data but it would remove it from the array associated with collateralId, which would allow it to pass the CollateralToken.sol#releaseCheck and the underlying to be withdrawn by the user.
Impact
All liens can be deleted completely rugging lenders
Code Snippet
https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L651-L664
Tool used
Manual Review
Recommendation
Change _deleteLienPosition to internal rather than public.
Discussion
IAmTurnipBoy
Escalate for 1 USDC
Deleting leans allows borrower to steal funds because they never have to repay the funds the borrowed. Should be high risk
sherlock-admin
Escalate for 1 USDC
Deleting leans allows borrower to steal funds because they never have to repay the funds the borrowed. Should be high risk
You've created a valid escalation for 1 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
The function _deleteLienPosition was declared public without any access control, allowing any caller to remove liens.
Impact
All liens can be deleted, allowing borrowers to steal lender funds by withdrawing collateral without repaying.
What the attacker needed
None
The fix
The function should be changed from public to internal to restrict access.
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.
In a smart contract, a lien is a claim on collateral for a loan. The function that removes a lien was public, meaning anyone could call it, not just authorised users. So an attacker could delete a lien, making it look like the loan was repaid, and then withdraw the collateral, stealing from the lender.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.