You can grief migrations by sending SCX to the UniswapHelper
The UniswapHelper contract checks that its SCX balance equals a parameter passed by the caller, but an attacker can send SCX directly to the contract to make the balance exceed the parameter, causing any migration to revert. This allows an attacker to prevent migrations until the extra SCX is used to buy and burn Flan.
Submitted by camden, also found by robee
The attack here allows the attacker to prevent migrations.
The attack here is recoverable because we can just call buyFlanAndBurn (f it worked as expected) with SCX as the input token to buy Flan with the extra SCX, then run the migration again.
Proof of Concept
The attack here is simple:
- Get some SCX
- Send it to the UniswapHelper contract
- Any migration called will revert
My proof of concept test. You should be able to use this directly in the thig https://gist.github.com/CamdenClark/b6841ac7a63e868d90eff7d9a40e3e0a
localSCXBalance is the SCX balance of the uniswap helper. https://github.com/code-423n4/2022-01-behodler/blob/cedb81273f6daf2ee39ec765eef5ba74f21b2c6e/contracts/UniswapHelper.sol#L163
But, the caller of stablizeFlan assumes that the rectangleOfFairness parameter is going to be equal to the amount of SCX that was sent https://github.com/code-423n4/2022-01-behodler/blob/cedb81273f6daf2ee39ec765eef5ba74f21b2c6e/contracts/Limbo.sol#L234
Recommended Mitigation Steps
The mitigation could be to do >= instead of == so sending tokens can’t grief this.
Beyond this though, why do you need to pass in rectangleOfFairness if we’re requiring it to be a function of the localSCXBalance anyways? https://github.com/code-423n4/2022-01-behodler/blob/cedb81273f6daf2ee39ec765eef5ba74f21b2c6e/contracts/UniswapHelper.sol#L167
gititGoro (Behodler) acknowledged and commented:
It’s interesting to think about this issue because it’s the type of tight rope walk between incentives and code enforcement. In this scenario, the net results of the griefing will be both a higher flan and scx price. So in exchange for a timely migration, we get a boost to flan and scx (which is precisely the goal of a migration from Limbo’s perspective). Eventually we get the migration we wanted but only after some price assist from a griefer. For this cryptoeconomic reason, I’ve marked it as acknowledged rather than confirmed.
Still I appreciate the depth with which you’ve thought about this and I hope the Behodler community sees more of you after this audit.
Jack the Pug (judge) commented:
Good catch! Thank you for creating the proof of concept test script. The Code4rena community needs more wardens like you!
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 contract uses a strict equality check between its SCX balance and a caller-supplied parameter, which can be broken by sending extra tokens directly to the contract.
Impact
An attacker can prevent migrations, though the attack is recoverable by calling buyFlanAndBurn with SCX to buy Flan and then retrying the migration.
What the attacker needed
Some SCX tokens
The fix
The mitigation could be to change the equality check to a greater-than-or-equal comparison, and to remove the redundant parameter.
How it was found
- Get some SCX
- Send it to the UniswapHelper contract
- Any migration called will revert
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 smart contract called UniswapHelper helps with migrations. It expects its balance of a token called SCX to match a number given by the caller. Anyone can send SCX to the contract, so an attacker can make the balance too high, and then the check fails, stopping migrations.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.