Bonding mechanism allows malicious user to DOS auctions
The bonding mechanism allows a malicious user to bond an auction immediately after it starts, preventing anyone else from settling it for 24 hours. This freezes user funds and auction settlement, and the attacker can repeat the attack on each new auction.
Submitted by kenzo.
A malicious user can listen to the mempool and immediately bond when an auction starts, without aim of settling the auction. As no one can cancel his bond in less than 24h, this will freeze user funds and auction settlement for 24h until his bond is burned and the new index is deleted. The malicious user can then repeat this when a new auction starts.
While the malicious user will have to pay by having his bond burned, it might not be enough of a detriment for the DOS of the basket.
Impact
Denial of service of the auction mechanism. The malicious user can hold the basket “hostage” and postpone or prevent implementing new index. The only way to mitigate it would be to try to front-run the malicious user, obviously not ideal.
Proof of Concept
publishAllIndex: https://github.com/code-423n4/2021-09-defiProtocol/blob/52b74824c42acbcd64248f68c40128fe3a82caf6/contracts/contracts/Basket.sol#L170
- The attacker would listen to this function / PublishedNewIndex event and upon catching it, immediately bond the auction.
- The publisher has no way to burn a bond before 24h has passed. But even if he could, it would not really help as the attacker could just bond again (though losing funds in the process).
settleAuction: https://github.com/code-423n4/2021-09-defiProtocol/blob/52b74824c42acbcd64248f68c40128fe3a82caf6/contracts/contracts/Auction.sol#L79
- Only the bonder can settle.
- Can only burn 24h after bond.
Tools Used
Manual analysis, hardhat.
Recommended Mitigation Steps
If we only allow one user to bond, I see no real way to mitigate this attack, because the malicious user could always listen to the mempool and immediately bond when an auction starts and thus lock it.
So we can change to a mechanism that allows many people to bond and only one to settle; but at that point, I see no point to the bond mechanism any more. So we might as well remove it and let anybody settle the auction.
With the bond mechanism, a potential settler would have 2 options:
- Bond early: no one else will be able to bond and settle, but the user would need to leave more tokens in the basket (as newRatio starts large and decreases in time)
- Bond late: the settler might make more money as he will need to leave less tokens in the basket, but he risks that somebody else will bond and settle before him.
Without a bond mechanism, the potential settler would still have these equivalent 2 options:
- Settle early: take from basket less tokens, but make sure you win the auction
- Settle late: take from basket more tokens, but risk that somebody settles before you
So that’s really equivalent to the bonding scenario.
I might be missing something but at the moment I see no detriment to removing the bonding mechanism.
frank-beard (Kuiper) acknowledged
itsmetechjay (organizer) commented:
Warden apologizes for linking the code of the previous defiProtocol contest, however, these lines are not changed in the new contest.
Alex the Entreprenerd (judge) commented:
I fully agree with this, anyone can grief the rest of the funds by bonding.
Personally, this is so easy to execute that I have to raise the severity to High, as it means that every single time there’s a benefit to performing a DOS, any malicious actor just has to bond to do it
Alex the Entreprenerd (judge) commented:
The sponsor may want to consider de-prioritizing bonding to rebalance, by allowing multiple users to bond and rebalance at the same time (or by having bond and rebalance happen at the same time)
Alex the Entreprenerd (judge) commented:
After thinking about it, I had put into question the high severity because of the “extractability of value”. However because this finding allows to effectively DOS the auction, at any time, I still believe High Risk to be the correct severity
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 design allows only one user to bond per auction, and that bonder has exclusive rights to settle, so a malicious early bonder can block all other settlements.
Impact
Denial of service of the auction mechanism, allowing the attacker to hold the basket hostage and postpone or prevent implementing a new index; the only mitigation is to try to front-run the attacker.
What the attacker needed
Ability to monitor the mempool; sufficient funds to bond; no special permissions
The fix
The bonding mechanism should be removed or changed to allow multiple users to bond and settle, as the report suggests.
How it was found
- Attacker listens for the PublishedNewIndex event or the publishAllIndex function call.
- Upon detecting a new auction, attacker immediately calls bond.
- Attacker does not settle the auction, so no one else can settle for 24 hours.
- After 24 hours, the bond is burned and the new index is deleted, but the attacker can repeat the attack on the next auction.
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 system, an auction lets someone rebalance a basket of tokens. To take part, a user must 'bond' (lock up some funds) and only that bonder can settle the auction. The problem is that a bad actor can bond first and then simply refuse to settle, blocking everyone else for 24 hours until their bond is burned.
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.