The commitToLiens function of AstariaRouter (AstariaRouter.sol#L249) always tries to send a CollateralToken to the caller while not being the owner of the token–this will always cause a revert.
Even though AstariaRouter is an approved spender/operator, the CollateralToken will be minted to the actual owner of the collateral (the from_ argument). Thus, when commitToLiens tries to send a CollateralToken to the caller, it will always revert (AstariaRouter.sol#L589):
function commitToLiens(IAstariaRouter.Commitment[] calldata commitments)
external
whenNotPaused
returns (uint256 totalBorrowed)
{
totalBorrowed = 0;
for (uint256 i = 0; i < commitments.length; ++i) {
// @audit CollateralToken is minted to the collateral owner
_transferAndDepositAsset(
commitments[i].tokenContract,
commitments[i].tokenId
);
totalBorrowed += _executeCommitment(commitments[i]);
uint256 collateralId = commitments[i].tokenContract.computeId(
commitments[i].tokenId
);
// @audit this contract is not the owner of the minted CollateralToken
_returnCollateral(collateralId, address(msg.sender));
}
WETH.safeApprove(address(TRANSFER_PROXY), totalBorrowed);
TRANSFER_PROXY.tokenTransferFrom(
address(WETH),
address(this),
address(msg.sender),
totalBorrowed
);
}
Tool used
Manual Review
Recommendation
Consider removing the call to _returnCollateral from the commitToLiens function since the caller is already the owner of the CollateralToken. Also, consider improving the test coverage of the AstariaRouter contract.
Jeiwan
medium
Denial of service in
AstariaRouter.commitToLiens
Summary
Denial of service in
AstariaRouter.commitToLiens
Vulnerability Detail
The
commitToLiens
function ofAstariaRouter
(AstariaRouter.sol#L249) always tries to send a CollateralToken to the caller while not being the owner of the token–this will always cause a revert.First, the function deposits a caller's NFT collateral token (AstariaRouter.sol#L578):
The depositing is handled here (CollateralToken.sol#L266):
Even though
AstariaRouter
is an approved spender/operator, the CollateralToken will be minted to the actual owner of the collateral (thefrom_
argument). Thus, whencommitToLiens
tries to send a CollateralToken to the caller, it will always revert (AstariaRouter.sol#L589):Impact
The
commitToLiens
function ofAstariaRouter
will always revert.Code Snippet
AstariaRouter.sol#L249:
Tool used
Manual Review
Recommendation
Consider removing the call to
_returnCollateral
from thecommitToLiens
function since the caller is already the owner of the CollateralToken. Also, consider improving the test coverage of theAstariaRouter
contract.Duplicate of #204