Skip to content
Access control Disclosed report Advanced

Steal all MKR from `flap` during liquidation by exploiting lack of validation in `flap.kick`

The public `flap.kick` function did not validate its `bid` parameter, so anyone could open a fake DAI-for-MKR auction with an arbitrarily large bid at almost no cost. After governance shut the system down, the attacker could call `yank` on those fake auctions and receive MKR from the `flap` contract up to the bid amount.

lucash-dev Follow

Originally disclosed on HackerOne

  • Triaged in 7 days
  • Fixed in 27 days
  • Paid in 27 days
  • Disclosed after 28 days

Summary:

The flap contract provides the ability to auction DAI for MKR. That's a fundamental functionality of the MCD system, invoked usually from the vow contract. A flaw in the validation of calls to flap.kick, however, allows a malicious user to create "fake' auctions that can be later used to steal MKR from flap during the liquidation (end) phase.

Detailed description

The method flap.kick, used to start an auction of DAI (for MKR) in the flap contract, lacks any validation of the bid parameter. Since the method is public, a malicious user can directly invoke it, passing an arbitrary bid parameter -- affecting other contracts that assume this value represents the highest bid in the auction.

While it's possible that this issue will cause other problems, in this report I'll focus on what seems to be the highest severity attack enabled by it.

The attack consists of two parts:

1 - During the normal operation of the MCD system (contracts not "caged"), the attacker will create one or more "fake" auctions by calling flap.kick. The bid parameter can be arbitrarily large, and won't be validated in any way. On the other hand, the lot parameter can be arbitrarily small, as long as it's not zero, which means the auction can be placed with almost zero cost.

2 - After governance calls end.cage, the auctions are stopped -- but any MKR deposited in the flap contract for any outstanding auction will still be there until someone calls yank for each one. At this point, the attacker can call flap.yank for his own "fake" auctions, and that will result in him getting MKR transferred from the flap contract to himself -- in whatever amount was specified as bid in step 1.

Since the attacker might no know beforehand, it would be wise for them to create multiple "fake" auctions. In particular, an exponential series of auctions, with bid values 1, 2, 4, 8, 16... will allow the attacker to extract any exact amount of MKR from the flap contract.

Steps To Reproduce:

I've attached to this report a modified version of end.t.sol which contains a test (the last one, test_steal_mkr_from_flapper) that reproduces this attack.

Please don't hesitate to contact me if you have any trouble understanding or reproducing this issue.

Impact

This issue allows an attacker to steal arbitrary amounts of MKR deposited for auction. That impact is particularly troubling, as MKR tokens are used to govern the platform, and anyone maliciously obtaining large quantities of these tokens might use them to further affect other core functionalities, potentially leading to stealing collateral, DAI etc. Also, because the same MKR token might be used for governance of future versions of the contracts, the damage might be much more enduring and harder to mitigate.

Given the above, and the minimal cost for perpetrating the attack, this issue would normally be classified as Critical. The specific policies for this program, though, won't allow for that, since this attack doesn't steal collateral directly. So, I classified the severity as High.

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

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 public `flap.kick` entry point trusted caller-supplied auction parameters, especially `bid`, without checking that the call came from the intended internal contract or that the bid was legitimate.

Impact

An attacker could steal arbitrary amounts of MKR deposited for auction, which could then be used to influence governance and other core functions; the report notes the program's own rules capped the severity at High because collateral is not stolen directly.

What the attacker needed

Attacker can call flap.kick directly; governance later calls end.cage; MKR is deposited in flap for auctions

How it was found

  1. Call `flap.kick` directly with an arbitrarily large bid and a tiny non-zero lot to create fake auctions at almost no cost.
  2. Wait for governance to call `end.cage` so auctions stop while MKR stays in the `flap` contract.
  3. Call `flap.yank` on the fake auctions to receive MKR from the contract equal to the bid amounts.

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.

This is a smart contract that runs auctions where people bid DAI to buy MKR. A function that starts an auction was open to anyone and never checked the bid amount, so a person could pretend to have bid a huge amount for almost nothing. Later, when the system was being shut down, that fake bid was paid out in real MKR taken from the contract.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by lucash-dev

View all

4 more disclosed reports, best first.

More from BlockDev Sp. Z o.o

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.