Conviction scoring fails to initialize and bootstrap
New users' conviction scores never initialise because the checkpoint count is zero and the balance is zero, so the update function exits early. This prevents the protocol's core conviction scoring feature from bootstrapping for any new user.
FairSide contest
Originally disclosed on Code4rena
Conviction scores for new addresses/users fail to initialize+bootstrap in ERC20ConvictionScore’s _updateConvictionScore() because a new user’s numCheckpoints will be zero and never gets initialized.
This effectively means that FairSide conviction scoring fails to bootstrap at all, leading to the failure of the protocol’s pivotal feature.
When Alice transfers FSD tokens to Bob for the first time, _beforeTokenTransfer(Alice, Bob, 100) is triggered which calls _updateConvictionScore(Bob, 100) on Line55 of ERC20ConvictionScore.sol.
In function _updateConvictionScore(), given that this is the first time Bob is receiving FSD tokens, numCheckpoints[Bob] will be 0 (Line116) which will make ts = 0 (Line120), and Bob’s FSD balance will also be zero (Bob never has got FSD tokens prior to this) which makes convictionDelta = 0 (Line122) and not let control go past Line129.
This means that a new checkpoint never gets written, i.e., conviction score never gets initialized, for Bob or for any user for that matter.
FairSide’s adjustment of Compound’s conviction scoring is based on time and therefore needs an initialization to take place vs Compound’s implementation. Therefore, a new checkpoint needs to be created+initialized for a new user during token transfer.
fairside-core (FairSide) confirmed:
Fixed in PR#18.
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 update function returns early when the checkpoint count is zero and the balance delta is zero, so no initial checkpoint is written for a new user.
Impact
The protocol's pivotal conviction scoring feature fails to bootstrap for any new user, so the core functionality does not work.
What the attacker needed
A new user receives FSD tokens for the first time
The fix
The issue was fixed by creating and initialising a new checkpoint for a new user during token transfer.
How it was found
- Alice transfers FSD tokens to Bob for the first time.
- The transfer triggers _beforeTokenTransfer, which calls _updateConvictionScore for Bob.
- Because Bob has no prior checkpoints, numCheckpoints[Bob] is zero, making ts zero.
- Bob's balance is also zero, so convictionDelta is zero and the function exits before writing a checkpoint.
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 scoring is meant to reward users for holding tokens over time. When a new user first receives tokens, the code that sets up their score sees they have no history and no balance yet, so it does nothing. As a result, their score is never created and the feature does not work for anyone new.
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.