An attacker could manipulate debt exceptional redistribution because it is allowed to deposit into any trove
The Opus protocol allows anyone to deposit collateral into any trove, not just the owner. An attacker could exploit this by depositing a small amount of a volatile asset into a victim's trove, causing the victim to absorb all bad debt from the attacker's trove during redistribution instead of the loss being shared across all assets.
Originally disclosed on Code4rena
Submitted by minhquanym
In a redistribution, the unhealthy trove’s collateral and debt is distributed among troves proportionally to its collateral composition. If no other troves have deposited a yang that is to be redistributed, then the debt and value attributed to that yang will be redistributed among all other yangs in the system, according to their value proportionally to the total value of all remaining yangs in the system.
However, the Opus protocol allows anyone to deposit into any trove, even if they are not the trove’s owner, as seen in the function abbot.deposit(). This feature could potentially be exploited by an attacker. For instance, if a yang is only deposited in one trove that’s being redistributed, the attacker could deposit a small amount into a victim’s trove. This could result in all bad debt being redistributed to the victim’s trove instead of exceptional redistribution, even if the victim didn’t want this (i.e., they didn’t deposit this yang into their trove).
fn deposit(ref self: ContractState, trove_id: u64, yang_asset: AssetBalance) {
// There is no need to check the yang address is non-zero because the
// Sentinel does not allow a zero address yang to be added.
assert(trove_id != 0, 'ABB: Trove ID cannot be 0');
assert(trove_id <= self.troves_count.read(), 'ABB: Non-existent trove');
// note that caller does not need to be the trove's owner to deposit
// @audit Attacker could deposit for any trove to make it the only trove deposited this yang and being redistributed when bad debt happen
self.deposit_helper(trove_id, get_caller_address(), yang_asset);
}
Proof of Concept
Consider the following scenario:
- Assume there is a highly volatile yang
Xadded to Opus. Alice, aware of the risk ofX, does not deposit any amount ofXinto her trove. - Bob, the attacker, has deposited some
Xinto his trove. - When Bob’s trove is about to be redistributed due to bad debt, since no other trove has deposited
X, the debt should be redistributed among all other yangs (exceptional redistribution). This means everyone would share the loss of the bad debt. However, Bob could bypass this by depositing someXinto Alice’s trove. Since the deposit function doesn’t require the caller to be the trove’s owner, Alice’s trove now holds someX. As a result, a regular redistribution will occur, and all of Bob’s bad debt will be redistributed to Alice’s trove.
Recommended Mitigation Steps
Limit deposits to only the trove’s owner.
tserg (Opus) acknowledged, but disagreed with severity and commented:
The likelihood of this happening is low.
0xsomeone (judge) decreased severity to Medium and commented:
The warden has demonstrated how bad debt re-allocation can be “gamed” due to the permissionless deposit system of troves.
This particular attack vector is quite interesting and I commend the warden for their out-of-the-box thinking. However, I believe a medium-risk grade is better suited, given that the likelihood of a liquidation of a trove with an asset that is not held by any other trove in the system is low.
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 deposit function does not check that the caller is the trove owner, allowing anyone to add collateral to any trove and manipulate redistribution outcomes.
Impact
An attacker could shift all bad debt from their own trove onto a victim's trove, but the likelihood is low because it requires a liquidation of a trove holding an asset that no other trove in the system holds.
What the attacker needed
A trove with bad debt; a yang held only by the attacker's trove; victim has a trove without that yang; attacker can deposit into victim's trove
The fix
Deposits should be restricted to the trove's owner only.
How it was found
- Assume a highly volatile yang X is added to Opus and Alice does not deposit any X into her trove.
- Bob the attacker deposits some X into his own trove.
- When Bob's trove is about to be redistributed due to bad debt, no other trove holds X, so exceptional redistribution would normally spread the loss across all other yangs.
- Bob deposits a small amount of X into Alice's trove, which is allowed because the deposit function does not require the caller to be the trove owner.
- Alice's trove now holds some X, so a regular redistribution occurs and all of Bob's bad debt is redistributed to Alice's trove.
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 this lending system, when a risky loan fails, its debt is normally spread across everyone who holds the same collateral. But if only one person holds that collateral, the system spreads the loss across all other collateral types instead. The bug is that anyone can add collateral to someone else's loan, so an attacker can make a victim appear to hold the risky collateral and force them to take on the bad debt.
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.