Position owners can deny liquidations
A position owner can set the position price to the maximum unsigned integer value, which causes an overflow in the challenge logic so that bids and challenge endings revert. This lets the owner avoid liquidation and leave the challenger's funds stuck.
Submitted by JGcarv
Lines of code
https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Position.sol#L159 https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Position.sol#L307
Impact
The owner of a vulnerable position can deny being liquidated by setting the price to be type(uint256).max, making every call to tryAvertChallenge fail due to an overflow.
This means that if it’s advantageous enough the owner can choose to keep zchf and leave the collateral stuck. This could happen in any scenario where a collateral is likely to loose it’s value, for example, de-pegs, runs on the bank, etc.
Test Proof
Here’s a snippet that can be pasted on GeneralTest.t.sol:
function test_liquidationDenial() public {
test01Equity(); // ensure there is some equity to burn
address posAddress = initPosition();
Position pos = Position(posAddress);
skip(15 * 86_400 + 60);
alice.mint(address(pos), 1001);
vm.prank(address(alice));
pos.adjustPrice(type(uint256).max);
col.mint(address(bob), 1001);
uint256 first = bob.challenge(hub, posAddress, 1001);
bob.obtainFrankencoins(swap, 55_000 ether);
vm.expectRevert();
bob.bid(hub, first, 10_000 ether);
skip(7 * 86_400 + 60);
vm.expectRevert();
hub.end(first, false);
}
I think the real issue here is that you can’t end the challenge (as shown in the last line of the PoC), that will cause a loss of funds for challenger and disincentivize users from challenging the position.
luziusmeisser (Frankencoin) confirmed and commented:
Ouch, this is a good one.
Great finding with coded POC. As the presort mentioned, the impact is the same as
#670, but this has a different exploit path. Satisfactory.
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
Likely the price is used in arithmetic without bounds checking, so an extreme value overflows and makes the challenge and bid functions revert.
Impact
The owner can avoid liquidation and keep the borrowed funds while collateral stays stuck, and the challenger loses funds, which could discourage others from challenging positions.
What the attacker needed
A position owned by the attacker; attacker can set the price; a challenger willing to bid
How it was found
- Set up a position and let time pass so a challenge is possible.
- Mint tokens into the position and adjust the price to the maximum value.
- Have another account challenge the position.
- Attempt to bid on the challenge and observe it reverts.
- Wait and attempt to end the challenge and observe it also reverts.
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.
A position is a loan backed by collateral, and if the collateral loses value anyone can challenge it to force a liquidation. Here the borrower can set a price value so large that the maths overflows, which makes the challenge steps fail, so the loan is never liquidated and the person who tried to challenge loses their money.
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.