Skip to content
Race condition Audit finding Intermediate

Guaranteed citadel profit

The mintAndDistribute function increases the price of a staking share, allowing a user to deposit before the call and withdraw after to profit from the price increase. An attacker could sandwich the function to take a portion of the distributed citadels, reducing other users' profits.

georgypetrov Follow

Originally disclosed on Code4rena

Submitted by georgypetrov

User can sandwich mintAndDistribute function if mintable is high enough

  • Deposit before
  • Withdraw after
  • Take after 21 days citadels

Proof of Concept

mintAndDistribute increase a price of staking share, that allows to withdraw more than deposited. user takes part of distributed citadels, so different users have smaller profit from distribution

Recommended Mitigation Steps

Call mintAndDistribute through flashbots

GalloDaSballo (BadgerDAO) confirmed, disagreed with severity and commented:

My interpretation of the finding is that there’s no linear vesting in the way more rewards are distributed so they can be frontrun.

I have to disagree in that taking 21 days of exposure to a random token in order to gain a small sub 1% gain is probably not what I’d call a smart move.

That said, I believe the front-running finding to be valid, and while I disagree with High I believe the finding to have validity

jack-the-pug (judge) decreased severity to Medium and commented:

Downgrading to Medium as this attack vector is not economically profitable in practice (because of the 21 days vesting).


The original report as published on Code4rena, by georgypetrov. 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 lack of a vesting or lock-up period on deposits allows users to enter and exit around the reward distribution, capturing a share of the newly distributed tokens.

Impact

The attacker could gain a small profit (sub 1%) at the expense of other users, but the 21-day vesting makes the attack not economically profitable in practice.

What the attacker needed

Ability to front-run transactions; mintable amount high enough

The fix

The report recommends calling mintAndDistribute through flashbots to prevent front-running.

How it was found

  1. Deposit before the mintAndDistribute call
  2. Withdraw after the mintAndDistribute call
  3. Take after 21 days citadels

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.

When new rewards are added to a staking pool, the value of each share goes up. If someone can add their money just before that happens and take it out just after, they can grab a slice of the rewards meant for everyone else. This is called front-running or sandwiching.

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 georgypetrov

View all

2 more disclosed reports, best first.

More from Badger Citadel 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.