Permanent freezing of additional reward tokens
The registerGauge function in PoolVoter never adds a pool to the internal _pools array because its guard condition is always false, so the array stays empty. As a result, distributeEx cannot distribute additional reward tokens and they remain permanently locked in the contract.
Originally disclosed on Immunefi
- Disclosed after under an hour
28992 - [SC - High] Permanent freezing of additional reward tokens
Submitted on Mar 4th 2024 at 04:59:12 UTC by @MahdiKarimi for Boost | ZeroLend
Report ID: #28992
Report type: Smart Contract
Report severity: High
Target: https://github.com/zerolend/governance
Impacts:
- Permanent freezing of unclaimed yield
Description
Brief/Intro
The registerGuage function never adds pool address to _pool array and set isPool mapping, it would block distributeEx function which leads to permanent freezing of additional reward tokens.
Vulnerability Details
In registerGuagethere is an if statement as follows and if it's true it would add _asset to the pool array and set isPool to true, since isPool have been set only here, this if statement always will be false and this piece of code never runs.
if (isPool[_asset]) {
_pools.push(_asset);
isPool[_asset] = true;
}
this means registering a gauge won't add underlying pool to _pool array and _pool array has no value. distributeEx function uses _pool array to distribute additional reward tokens, it iterates through _pool array and transfers rewards to pool gauges, since _pool array is empty, there is no way to transfer additional reward tokens and funds get blocked in PoolVoter contract .
Impact Details
This leads to a situation which distributeEx is unable to distribute additional rewards, and permanent freezing of additional reward tokens.
References
Proof of Concept
describe("freezing of additional reward tokens", () => {
it("distributeEx is unable to distribute additional rewaard tokens", async function () {
// so there is no differece
// some parts has been added to deployement as follow
// a new lending pool has been deployed during deployment and its gauge has been registered at pool voter during deployment
// some zero tokens has been transferred to ant.address, so ant.address have enough zero token balance
// voting to both gauges equally
let vote1 = 1e8/2;
let vote2 = 1e8/2;
await poolVoter.connect(ant).vote([reserve.target, reserve2.target],[vote1, vote2]);
// we consider zero is additional reward token of the pool voter ( not main reward token )
// transferring rewards to pool voter
await zero.connect(ant).transfer(poolVoter.target, 1e6);
// retrieve pool voter contract balance
let balance = await zero.balanceOf(poolVoter);
// distributeEx function wouldn't distribute any token, since _pool array is empty
await poolVoter["distributeEx(address)"](zero.target);
// there is no change at balance of contract meaning no distribution happened
let balanceAfter = await zero.balanceOf(poolVoter);
expect(balanceAfter).eq(balance);
});
});
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
The registration code checks whether a pool is already registered before marking it as registered, so the condition is always false and the pool is never added to the list.
What the attacker needed
A pool gauge is registered; additional reward tokens are sent to PoolVoter
How it was found
- Deploy the contracts and register a gauge for a lending pool.
- Vote for the gauges with the test account.
- Transfer additional reward tokens to the PoolVoter contract.
- Call distributeEx with the reward token address.
- Observe that the contract balance does not change, so no distribution happened.
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 smart contract keeps a list of pools so it knows where to send extra reward tokens. A mistake in the code that registers a pool means the list is never filled, so the function that pays out rewards has nowhere to send them and the tokens stay stuck in the contract.
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.