Skip to content
Race condition Audit finding Intermediate

burn and mintTo in Basket.sol vulnerable to reentrancy

The mintTo and burn functions in Basket.sol make external token transfers before updating internal state, so a malicious token could call back into the contract. An attacker could then mint more basket tokens than they actually deposited.

0xalpharush Follow

Originally disclosed on Code4rena

Submitted by 0xalpharush, also found by hack3r-0m, JMukesh, and johnsterlacci

Impact

The functions mintTo and burn make external calls prior to updating the state. If a basket contains an ERC777 token, attackers can mint free basket tokens.

Proof of Concept

An attacker could reenter the mintTo function when the contract pulls an ERC777 token from the user and mint more tokens than they deposited.

Tools Used

Slither

Recommended Mitigation Steps

Move external calls after state updates. It is best practice to make external calls after updating state in accordance with the check-effect-interact pattern.

frank-beard (Kuiper) acknowledged:

For now we are only concerned with ‘Defi Safe’ tokens that conform to the erc-20 standard. It is expected that publishers and users should do due diligence when adding assets to a basket

Alex the Entreprenerd (judge) commented:

I agree with the warden finding that the function can be subject to re-entrancy.

Because the exploit is dependent on the token of choice, this is not a guarantee but rather the possibility of the system being vulnerable.

I highly recommend the sponsor to add re-entrancy checks.

As for the finding, because it is conditional on using a vulnerable token, I’ll downgrade to medium severity as it requires an external condition for the re-entrance to be possible

Alex the Entreprenerd (judge) commented:

After re-review I agree with medium severity on reentrancy findings on burn and mint, in contract with the “generic” re-entrancy finding with the additional bounties that lack any poc.

The findings with specific poc have been rated as separate findings (some of which have high risk) as they show an actual way to exploit the protocol

The original report as published on Code4rena, by 0xalpharush. 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 contract performs external token transfers before updating its own balances, violating the check-effect-interact pattern.

Impact

An attacker could mint basket tokens for free, but only if the basket contains a token with a callback hook, so the risk depends on which tokens are used.

What the attacker needed

Basket contains a callback-capable token; attacker can call mintTo or burn

The fix

External calls should be moved after state updates, following the check-effect-interact pattern, and reentrancy checks should be added.

How it was found

  1. A basket holds a token that can call back into the contract during a transfer, such as an ERC777 token.
  2. The attacker calls mintTo, and the contract pulls the token from them.
  3. During that transfer the token reenters mintTo before state is updated.
  4. The attacker ends up with more basket tokens than they deposited.

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 reentrancy bug happens when a contract sends a token or calls another contract before it has finished updating its own records. The other contract can call straight back in and act on the old, unfinished records, so it can repeat an action like minting tokens. Here the basket contract would hand out more tokens than the user paid for.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by 0xalpharush

View all

4 more disclosed reports, best first.

More from Kuiper contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.