Skip to content
Business logic Audit finding Intermediate

MixinPurchase:shareKey allows to generate keys without purchasing

The shareKey function allows a user to generate new keys without purchasing, even beyond the maximum number of keys. An attacker could create many addresses, buy one key, share minimal time with each address to generate new keys, and thereby cheaply allocate many keys, preventing honest users from purchasing keys due to the notSoldOut modifier.

GiveMeTestEther Follow

Originally disclosed on Code4rena

Submitted by GiveMeTestEther, also found by kenzo

The shareKey function allows a user to share some time with another user that doesn’t already has/had a key and this generates a new key. This even allows the user to generate more keys than \_maxNumberOfKeys.

Attacker generates a lot of EOA addresses, buys a key, share the minimum necessary time with each address and in each “sharing” a new key gets generated. This allows cheaply to allocate alot of “keys” with out really purchasing them and a lot of user can’t get a “key” because purchase has a modifier notSoldOut, that limits the max purchasable to “keys” to maxNumberOfKeys

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.

Tools Used

Manual Analysis

Recommended Mitigation Steps

  • rethink the whole shareKey thingy,

julien51 (Unlock Protocol) acknowledged and commented:

I am not sure this is a bug or even a risk. Someone could actually achieve the same thing by purchasing keys at the full price and cancelling them immediately getting an almost full refund (or even full refund when there is a free trial) and could quickly get the lock to “sell out”. It is actually the case with any NFT project where there is a cap/limit to number of tokens and someone can easily “Capture” them all.

One way to limit the impact for the lock manager would be to set a cancellation penalty AND a transfer fee.

0xleastwood (judge) commented:

Nice find! While I understand what the sponsor is saying, this does seem like a valid way to deny a lock from selling membership to honest users.

julien51 (Unlock Protocol) commented:

Note that a lock manager can easily increase supply to mitigate that (and even could delete existing keys/NFT to reduce the outstanding supply)

0xleastwood (judge) commented:

While the lock manager can restore the contract to some valid state, this will still impact protocol availability, even in the short-term.

The original report as published on Code4rena, by GiveMeTestEther. 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 shareKey function does not check whether the recipient already has a key or whether the maximum number of keys has been reached, allowing unlimited key generation.

Impact

This could allow an attacker to cheaply allocate many keys, potentially preventing honest users from purchasing keys because the purchase function has a notSoldOut modifier that limits the maximum purchasable keys.

What the attacker needed

Attacker has one key; Attacker can create many addresses; Lock has a maximum number of keys

The fix

The shareKey function should be redesigned to prevent generating keys beyond the maximum supply, for example by checking the recipient's existing keys and enforcing the maxNumberOfKeys limit.

How it was found

  1. Attacker generates a lot of EOA addresses.
  2. Attacker buys a key.
  3. Attacker shares the minimum necessary time with each address.
  4. Each sharing generates a new key.

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, a 'key' is like a membership token that can be bought. The shareKey function lets someone give a tiny bit of their membership time to another address, and this creates a new key for that address. The problem is that this can be repeated many times to create lots of keys without paying the full price, which can fill up the maximum number of keys and stop others from buying.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by GiveMeTestEther

View all

3 more disclosed reports, best first.

More from Unlock Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.