The _repay() in Singularity will deduct user's borrowed amount userBorrowPart[to] by the repayment amount part as shown in the code below.
However, an attacker could cause this to revert and grief a full repayment by frontrunning it with a 1 wei repayment on the victim's behalf.
This attack is possible as Singularity allows repayment on behalf.
One might argue that frontrunning is not possible on the host chain (Arbitrum), but that is not true for an omnichain protocol as it extends beyond the host chain. That means the attacker could monitor for the cross chain repayments initiated from another chain that has a mempool (e.g. USDO.sendAndLendOrRepay() tx on Ethereum), and then frontrun it with the grief attack before it is sent over to the Singularity market on Arbitrum.
The attack can be used to DoS any users' full repayment. A malicious liquidator could perform this attack to prevent any full repayment of undercollateralized positions, subjecting the users to liquidation.
Recommended Mitigation Steps
Support the ability to overpay for the repayment and refund any excess payment.
Lines of code
https://github.com/Tapioca-DAO/tapioca-bar-audit/blob/master/contracts/markets/singularity/SGLLendingCommon.sol#L91 https://github.com/Tapioca-DAO/tapioca-bar-audit/blob/master/contracts/markets/bigBang/BigBang.sol#L728 https://github.com/Tapioca-DAO/tapioca-bar-audit/blob/master/contracts/usd0/BaseUSDO.sol#L313
Vulnerability details
The
_repay()
in Singularity will deduct user's borrowed amountuserBorrowPart[to]
by the repayment amountpart
as shown in the code below.However, an attacker could cause this to revert and grief a full repayment by frontrunning it with a 1 wei repayment on the victim's behalf. This attack is possible as Singularity allows repayment on behalf.
One might argue that frontrunning is not possible on the host chain (Arbitrum), but that is not true for an omnichain protocol as it extends beyond the host chain. That means the attacker could monitor for the cross chain repayments initiated from another chain that has a mempool (e.g.
USDO.sendAndLendOrRepay()
tx on Ethereum), and then frontrun it with the grief attack before it is sent over to the Singularity market on Arbitrum.https://github.com/Tapioca-DAO/tapioca-bar-audit/blob/master/contracts/markets/singularity/SGLLendingCommon.sol#L91
Impact
The attack can be used to DoS any users' full repayment. A malicious liquidator could perform this attack to prevent any full repayment of undercollateralized positions, subjecting the users to liquidation.
Recommended Mitigation Steps
Support the ability to overpay for the repayment and refund any excess payment.
Assessed type
DoS