Skip to content
Business logic Audit finding Intermediate

TributeAccrual.availableTribute() & TributeAccrual.availableGovernanceTribute() Distributes Tributes Unfairly

The tribute claim functions calculate a user's share based on their conviction score, which can be updated at will. An attacker can update their conviction score just before claiming to receive more than their fair share, potentially draining the contract and preventing others from claiming.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

Impact

Conviction scores are calculated by taking the user’s balance and multiplying it by the time elapsed. This score is updated upon each token transfer, or alternatively by directly calling ERC20ConvictionScore.updateConvictionScore(). The availableTribute() and availableGovernanceTribute() functions calculate a user’s share by calculating their percentage of the total conviction score to find the amount owed to them.

This is shown in the following statement where userCS is the user’s conviction score and totalCS is the protocol’s total conviction score:

return amount.mul(userCS).div(totalCS);

The tribute amount that can be successfully claimed disproportionally favours users who have updated their conviction score more recently and who are early to claim their allocated tribute.

Proof of Concept

Consider the following POC:

  • Two users Alice and Bob both have a conviction score of 5 at time = 1.
  • Time advances such that time = 2.
  • Bob calls updateConvictionScore() which sets his conviction score to 5 * time = 10 where time = 2.
  • Therefore, the total conviction score is now 15 and Alice and Bob’s individual conviction scores are 5 and 10 respectively.
  • Bob attempts to call claimTribute() where the tribute to claim is of size 15 tokens. As a result, Bob receives 10 tokens according to the calculation mentioned above ((15*10)/15).
  • Alice updates her conviction score and also attempts to call claimTribute(), receiving 7.5 tokens in the process.
  • As a result, a total of 22.5 tokens were transferred out despite the tribute amount being only 15 tokens in total.

As you can see from the above example, the amount of tokens transferred favours user’s who claim early and update their conviction score. It is entirely possible that due to the finite amount of tokens stored in the contract, a number of user’s won’t be able to successfully claim their allocated tribute.

Tools Used

Manual code review.

Recommended Mitigation Steps

There is no easy solution to the mentioned issue. Ideally, all users should have an up to date conviction score whenever claimTribute() or claimGovernanceTribute() are called, although this would be an incredibly gas intensive mitigation. Alternatively, the protocol’s total conviction score can be calculated by tracking the total minted balance of FSD.sol’s token and multiplying this by a running total of time elapsed. This will need to be adjusted whenever tokens are minted or burned and updated during tribute claims.

YunChe404 (FairSide) disputed and disagreed with severity

The original report as published on Code4rena, by leastwood. 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 tribute calculation uses a user's conviction score that can be arbitrarily updated by the user just before claiming, without ensuring all users' scores are current, leading to an unfair distribution.

Impact

A user could claim more tokens than their fair share, potentially causing other users to be unable to claim their allocated tribute due to insufficient contract balance.

What the attacker needed

A user with a conviction score; ability to call updateConvictionScore(); tribute tokens available in contract

The fix

The protocol should ensure all users' conviction scores are up to date when claims are made, or use a running total of minted tokens multiplied by elapsed time to calculate the total conviction score.

How it was found

  1. Two users Alice and Bob both have a conviction score of 5 at time = 1.
  2. Time advances such that time = 2.
  3. Bob calls `updateConvictionScore()` which sets his conviction score to `5 * time = 10` where time = 2.
  4. Therefore, the total conviction score is now 15 and Alice and Bob’s individual conviction scores are 5 and 10 respectively.
  5. Bob attempts to call `claimTribute()` where the tribute to claim is of size 15 tokens. As a result, Bob receives 10 tokens according to the calculation mentioned above (`(15*10)/15`).
  6. Alice updates her conviction score and also attempts to call `claimTribute()`, receiving 7.5 tokens in the process.

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.

Conviction scores track how long users have held tokens. The tribute claim function uses these scores to decide how many tokens each user gets. Because users can update their score right before claiming, they can temporarily boost their share and take more tokens than they should, leaving less for others.

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 leastwood

View all

70 more disclosed reports, best first.

More from FairSide 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.