Skip to content
DoS Audit finding Intermediate

Transfer position ownership to addr(0) to DoS end() challenge

A position owner can transfer ownership to the zero address, causing the challenge end function to revert when it tries to refund the owner. This locks the bidder's funds and the challenger's collateral, preventing the challenge from completing.

__141345__ Follow

Originally disclosed on Code4rena

Submitted by 141345

If some challenge is about to succeed, the position owner will lose the collateral. Seeing the unavoidable loss, the owner can transfer the position ownership to addr(0), fail the end() call of the challenge. At the end, the DoS in end() will have these impacts:

  • the successful bidder will lose bid fund.
  • the challenger’s collateral will be locked, and lose the challenge reward.

Proof of Concept

Assuming, the position has minimumCollateral of 600 zchf, the position owner minted 1,000 zchf against some collateral worth of 1,100 zchf, the highest bid for the collateral was 1,060 zchf, the challenge reward being 50. Then in Position.sol#notifyChallengeSucceeded(), the repayment will be 1,000, but effectiveBid worth of 1,060. The fundNeeded will be 1,000 + 50 = 1,050, and results in excess of 1,060 - 1,050 = 10 to refund the position owner in line 268 MintingHub.sol. In addition, due to the minimumCollateral limit, this challenge cannot be split into smaller ones.

File: contracts/MintingHub.sol
252:     function end(uint256 _challengeNumber, bool postponeCollateralReturn) public {

260:         (address owner, uint256 effectiveBid, uint256 volume, uint256 repayment, uint32 reservePPM) = challenge.position.notifyChallengeSucceeded(recipient, challenge.bid, challenge.size);
261:         if (effectiveBid < challenge.bid) {
262:             // overbid, return excess amount
263:             IERC20(zchf).transfer(challenge.bidder, challenge.bid - effectiveBid);
264:         }
265:         uint256 reward = (volume * CHALLENGER_REWARD) / 1000_000;
266:         uint256 fundsNeeded = reward + repayment;
267:         if (effectiveBid > fundsNeeded){
268:             zchf.transfer(owner, effectiveBid - fundsNeeded);

File: contracts/Position.sol
329:     function notifyChallengeSucceeded(address _bidder, uint256 _bid, uint256 _size) external onlyHub returns (address, uint256, uint256, uint256, uint32) {

349:         uint256 repayment = minted < volumeZCHF ? minted : volumeZCHF; // how much must be burned to make things even
350:
351:         notifyRepaidInternal(repayment); // we assume the caller takes care of the actual repayment
352:         internalWithdrawCollateral(_bidder, _size); // transfer collateral to the bidder and emit update
353:         return (owner, _bid, volumeZCHF, repayment, reserveContribution);
354:     }

From the position owner’s point of view, the position is on auction and has incurred loss already, only 10 zchf refund left. The owner can give up the tiny amount, and transfer the ownership to addr(0) to DoS the end() call.

When the position owner is addr(0), the transfer in line 268 MintingHub.sol will revert, due to the requirement in zchf (inherited from ERC20.sol):

File: contracts/ERC20.sol
151:     function _transfer(address sender, address recipient, uint256 amount) internal virtual {
152:         require(recipient != address(0));

Now the successful bidder can no longer call end(). The bid fund will be lost. Also the challenger will lose the collateral because the return call encounter DoS too.

Recommended Mitigation Steps

Disallow transferring position ownership to addr(0)

0xA5DF (lookout) commented:

The need to prevent transferring to the zero address is already mentioned in the automated findings and was reported by #935, however the impact demonstrated in this report is much more severe than the low severity impact identified by other reports and therefore I believe it should be a separate finding.

luziusmeisser (Frankencoin) confirmed


The original report as published on Code4rena, by __141345__. 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

The position ownership transfer allows setting the owner to the zero address, and the challenge end function later attempts a token transfer to that zero address, which reverts.

Impact

The successful bidder loses their bid funds and the challenger's collateral is locked, so the challenger loses the challenge reward.

What the attacker needed

A position is under challenge; owner can transfer position ownership; challenge is about to succeed

How it was found

  1. The position owner sees the challenge is about to succeed and they will lose collateral.
  2. The owner transfers the position ownership to the zero address.
  3. The successful bidder calls end() on the challenge.
  4. The end() call reverts because the refund transfer to the zero address fails.

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 owner can give away their position to nobody (the zero address). When the challenge finishes, the system tries to send a small refund to the owner, but sending to nobody fails, so the whole finish step stops. This traps the bidder's money and the challenger's collateral.

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 __141345__

View all

18 more disclosed reports, best first.

More from Frankencoin

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.