Skip to content
DoS Audit finding Intermediate

denial of service

The withdraw function allowed zero-amount withdrawals, so an attacker could flood the withdrawal queue with many empty entries. This made processWithdrawals very expensive to run, potentially locking funds because governance or users could not afford the gas to clear the queue.

danb Follow

Originally disclosed on Code4rena

Submitted by danb, also found by cmichel, csanuragjain, hyh, kirk-baird, leastwood, Meta0xNull, minhquanym, Omik, robee, Ruhum, and throttle

https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/VUSD.sol#L53

processWithdrawals can process limited amount in each call. An attacker can push to withdrawals enormous amount of withdrawals with amount = 0. In order to stop the dos attack and process the withdrawal, the governance needs to spend as much gas as the attacker. If the governance doesn’t have enough money to pay for the gas, the withdrawals can’t be processed.

Proof of Concept

Alice wants to attack vusd, she spends 1 millions dollars for gas to push as many withdrawals of amount = 0 as she can. If the governance wants to process the deposits after Alices empty deposits, they also need to spend at least 1 million dollars for gas in order to process Alice’s withdrawals first. But the governance doesn’t have 1 million dollars so the funds will be locked.

Recommended Mitigation Steps

Set a minimum amount of withdrawal. e.g. 1 dollar

    function withdraw(uint amount) external {
        require(amount >= 10 ** 6);
        burn(amount);
        withdrawals.push(Withdrawal(msg.sender, amount));
    }

atvanguard (Hubble) confirmed, but disagreed with High severity and commented:

Confirming this is an issue. Would classify it as 2 (Med Risk) because this attack is expensive to carry out.

atvanguard (Hubble) resolved

moose-code (judge) commented:

Would be interested to see the exact gas cost of executing withdraw. The thing is the grievance costs only gas to execute and the withdraw function is relatively cheap from first glance. The main issue here is that it can become SUPER expensive to clear the que in gas. I.e. if the attacker builds up a que of 200 withdrawals, some unknowning sucker is going to pay for more than 200 erc20 transfers in order to get their money out. Thats more than anyone would want to pay, and further since so much gas limit would be needed for this to be executed, to fit into a block you are going to have to pay a huge price.

So basically it costs attacker x to execute, which means it is also going to cost next user likely even more than x to fix the problem.

Also the que is not cleared so processWithdrawals becomes a really expensive function. If the items were cleared and set back to zero it would make it less expensive to de-que the que.

This being said we definitely have this at at least medium severity. $10k in gas to constantly brick users withdrawls from protocol for a week is a serious issue and not the biggest cost for an attack.

@JasoonS, going to put this as medium. Let’s discuss whether we want to have it as high.

moose-code (judge) commented:

Okay, going to keep this as high severity. The cost to fix the attack can be more than what the attack costs in total. It also burdens a random unsuspecting user with a really high gas cost to try and get their withdrawal. There are many good suggestions on how to fix this.


The original report as published on Code4rena, by danb. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 withdraw function did not enforce a minimum withdrawal amount, allowing zero-value entries to be added to the queue.

Impact

An attacker could make withdrawals very expensive to process, potentially locking funds if the cost to clear the queue is too high; the report notes the attack itself is expensive to carry out.

What the attacker needed

Ability to call withdraw repeatedly; enough funds to pay gas for many transactions

How it was found

  1. Attacker calls withdraw repeatedly with amount = 0, adding many empty withdrawals to the queue.
  2. Governance or a user later calls processWithdrawals, which must process the empty entries first.
  3. Processing the large queue costs a lot of gas, potentially more than can be paid, so withdrawals are not processed.

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 lets users request withdrawals, and later someone processes them in batches. Because the contract did not check that the withdrawal amount was above zero, an attacker could add lots of empty withdrawal requests cheaply. Processing all those empty requests costs a lot of gas (the fee paid to run code on the blockchain), so real withdrawals could get stuck.

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.

More by danb

View all

12 more disclosed reports, best first.

More from Hubble contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.