Kuiper contest - TomFrenchBlockchain's results

Automated portfolio protocol.

General Information

Platform: Code4rena

Start Date: 08/12/2021

Pot Size: $30,000 ETH

Total HM: 12

Participants: 26

Period: 3 days

Judge: leastwood

Total Solo HM: 9

Id: 65

League: ETH

Kuiper

Findings Distribution

Researcher Performance

Rank: 6/26

Findings: 4

Award: $1,862.53

🌟 Selected for report: 9

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: gzeon

Also found by: 0x0x0x, TomFrenchBlockchain

Labels

bug
duplicate
2 (Med Risk)

Awards

414.5093 USDC - $414.51

External Links

Handle

TomFrenchBlockchain

Vulnerability details

Impact

Publisher can make licenseFee arbitrarily large and then steal any funds remaining in the basket after 1 day.

Proof of Concept

On minting or burning basket tokens the handleFees function is called. This mints a number of basket tokens to the publisher and factory owner.

https://github.com/code-423n4/2021-12-defiprotocol/blob/205d3766044171e325df6a8bf2e79b37856eece1/contracts/contracts/Basket.sol#L133-L153

A key parameter in this calculation is the licenseFee which can be thought of as the percentage fee charged on the AUM over a year.

https://github.com/code-423n4/2021-12-defiprotocol/blob/205d3766044171e325df6a8bf2e79b37856eece1/contracts/contracts/Basket.sol#L177-L192

changeLicenseFee shows that while the publisher must wait a timelock period of 1 day to change the licenseFee, they can set it to an arbitrarily large value.

The attack is then as follows:

  1. Publisher calls changeLicenseFee to prepare a change of the licenseFee to a huge value (e.g. 1e20 giving a 10000% yearly fee)
  2. Any users which have deposited into the basket now face a rush to the exits within the next 24hrs
  3. After 24hrs the Publisher executes the change in fees, now charging many times the AUM in fees. Anyone who attempts to leave the basket at this point will dilute themselves massively through basket tokens minted to the publisher.
  4. Publisher waits a short period and burns a negligible amount of basket tokens and mints themselves a large fraction of the (now much larger) total supply of basket tokens through fees.
  5. Over the next day the Publisher, reduces the fees to the minimum value. Anyone who attempts to exit the basket at this point has already lost much of their investment due to inflation.
  6. Publisher exits the basket, taking all of the other users' tokens.

This attack requires for other users in a basket to not leave during the first 1 day timelock period. While it's possible that all users will see this attack coming and avoid it, this is completely unrealistic especially with such a short timelock.

Enforce a maximum value for the rate at which the basket can charge fees.

Consider what powers those which receive fees have to influence their size.

#0 - frank-beard

2022-02-22T19:28:55Z

Findings Information

🌟 Selected for report: TomFrenchBlockchain

Also found by: WatchPug

Labels

bug
2 (Med Risk)
sponsor acknowledged

Awards

690.8489 USDC - $690.85

External Links

Handle

TomFrenchBlockchain

Vulnerability details

Impact

All user funds in a basket being held hostage by the publisher

Proof of Concept

The Basket publisher can propose an auction in order to set new tokens and weights with a 1 day timelock.

https://github.com/code-423n4/2021-12-defiprotocol/blob/205d3766044171e325df6a8bf2e79b37856eece1/contracts/contracts/Basket.sol#L216-L244

As part of this call they can set the minIbRatio variable which determines what the maximum slippage on the auction is allowed to be. If it's set to the current IbRatio then the Basket accepts no slippage.

The publisher can choose to set minIbRatio = type(uint256).max which will prevent any auction bids from being successful, locking the basket in the auction state.

It's not possible to enter or exit the basket while an auction is going on, so any users who hold any funds in the basket are forced to take the only option to kill the auction available to them.

https://github.com/code-423n4/2021-12-defiprotocol/blob/205d3766044171e325df6a8bf2e79b37856eece1/contracts/contracts/Basket.sol#L91-L119

If a user makes a bond and then waits a day to then call Auction.bondBurn, it will reset the auction and allow users to withdraw but it requires 0.25% of the supply of the basket token to be burned.

https://github.com/code-423n4/2021-12-defiprotocol/blob/205d3766044171e325df6a8bf2e79b37856eece1/contracts/contracts/Auction.sol#L121-L134

One of the basket's users is then forced to give up some of their assets to secure the release of the remaining assets in the basket (for a 24hr period until the publisher starts a new auction).

This attack can be launched at any time with only 24 hours warning. This is a very short amount of time which near guarantees that if other users hold funds in the basket that not all of them will successfully withdraw in that time and so will have funds locked.

Again this is tricky to mitigate as there are legitimate scenarios where we would expect the ibRatio to increase. e.g. a basket containing WBTC being changed to contain USDC as each basket token should be worth much more USDC than it was in terms of WBTC.

To be frank the entire auction mechanism is a bit shaky as it doesn't account for changes in the values of the tokens over time.

#0 - frank-beard

2022-02-22T19:31:25Z

this is where community action and the timelock should mitigate attacks of these types. users should be able to hold publishers accountable for their rebalances, whether that is through a dao or other means. we acknowledge there is some level of trust required between the user and the publisher however this is also intentional, for the types of products this protocol is for.

#1 - 0xleastwood

2022-03-26T07:02:22Z

Because a timelock is used in this instance, exploiting this issue proves more difficult and requires that the publisher is malicious. As we are dealing with an abuse of privileges, I think this fits the criteria of a medium severity issue as the issue can only be exploited by a trusted account.

#2 - 0xleastwood

2022-03-27T02:08:47Z

Actually I'm not sure if I understand the exploit:

  • The publisher must wait a day to call Basket.publishNewIndex(), setting new values and starting an auction. In that time, users are free to exit the protocol as they wish.
  • However, users who were not able to exit in time are obligated to call Auction.bondForRebalance() in order to unlock the basket's underlying assets. But because Auction.settleAuction() will always revert, this user forfeits their bond to unlock the rest of their tokens.

In this case, I see this as an abuse of the publisher's privileges and lack of oversight by the users. medium severity seems correct in this situation.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter