PoL Security Guidelines: Reward Distribution
Low

Threat 1: Double-claiming rewards through re-entrancy attacks
Allowing re-entrancy on functions that control token flow within a contract can lead to unauthorized token withdrawal through re-entrancy attacks, resulting in system-wide losses.
Impact
Medium
A successful re-entrancy attack allows a user to withdraw more than their legitimate rewards, causing direct financial loss to the protocol or other users. Therefore, it is assessed as 'Medium'.
Guideline
Adhere to the Checks-Effects-Interactions pattern
Use ReentrantGuard7
Best Practice
Threat 2: Manipulation and use of incentive tokens by unauthorized users
An unauthorized user could add or duplicate incentive tokens, leading to excessive rewards from the system. Without a whitelist, token count limits, and duplication prevention logic, a malicious user could disrupt the incentive structure.
Impact
Low
If an attacker adds a malicious token to the incentive tokens, they could intercept validator and user rewards or increase the incentive rate, rapidly depleting the protocol's incentive tokens. However, since token registration is a process managed by governance, this is assessed as 'Low'.
Guideline
Permission to add incentive tokens: Factory Owner
Permission to remove incentive tokens: Factory Vault Manager
Currently, a maximum of 3 incentive tokens can be registered
Verify max/min range when setting reward rates and restrict manager permissions
When adding incentive tokens, verify
minIncentive > 0When changing the incentive rate, set it higher than the minimum rate
Current incentive manager permissions
Can add incentive token supply with
addIncentive(),accountIncentives()When recovering ERC20 tokens, transfer excluding incentive and deposited tokens
Best Practice
Threat 3: Threats from unverified ERC20 compliance of incentive tokens
Lack of verification procedures, such as checking for ERC20 standard compliance for incentive tokens, can lead to asset loss due to approval mismatches or transfer failures during the network reward processing.
Impact
Low
Non-compliant ERC20 tokens or errors in the approval process can cause unintended token transfer failures or quantity mismatches in specific transactions, leading to partial asset loss or functional impairment. Therefore, it is assessed as 'Low'.
Guideline
Secure token approval and transfer
Calculate and set the exact approval amount for each transaction
Verify that the approved amount matches the actual usage
Verify return values after all token transfers and roll back the entire transaction on failure
Token standard compatibility verification
Pre-verify ERC20 standard compliance
Token whitelist management
Pre-screening and approval process for supported tokens
Operate a blacklist for malicious tokens with real-time updates
Best Practice
Threat 4: System errors due to incorrect configuration during contract initialization
During the initial contract deployment, missing essential verification procedures and filtering functions can lead to system errors from incorrect settings.
Impact
Low
If a contract is deployed with an incorrect address, it may not function correctly. This is more likely to cause a temporary suspension of functionality rather than asset theft, so it is assessed as Low. However, preventing re-initialization is critical for upgradeable contracts, as cases like the Parity Wallet incident have shown that it can lead to severe consequences.
Guideline
Verify all contract initializations for zero addresses and essential parameters
Validate the rational range of initial configuration parameters
Ensure the integrity of the initial state, such as initial deposit root settings
Ensure the immutability of the initialization function and prevent re-initialization (use
__disableInitializers())Implement a rollback mechanism for major parameter changes
Best Practice
Threat 5: Unauthorized reward withdrawal or manipulation due to incorrect access control
If contract access control is not handled correctly, it can lead to reward withdrawal or manipulation by unintended malicious users.
Impact
Low
An attacker stealing another user's rewards is a significant threat, but the onlyOperatorOrUser modifier restricts withdrawals to the depositor or their delegate, making the likelihood of this occurring low. Thus, it is assessed as 'Low'.
Guideline
Log all administrative activities (permission changes, critical function calls, etc.)
Use modifiers like
onlyOwnerandonlyDistributorclearlyAdhere to the principle of least privilege for each address, role, or component
Owner
- Holds overall ownership of the contract - Appoints and dismisses Admin roles - Sets the most critical contract parameters (e.g., adding incentive tokens, delegating pause/resume authority) - Executes contract upgrades (when using a proxy pattern)
Operator
- Performs routine system operation tasks (more limited than Owner, specific function execution rights) - Executes periodic processes (e.g., triggering reward distribution logic, updating oracle price information) - Monitors system status and records relevant data
User
- Uses the core functions of the protocol (e.g., asset deposit, swap, loan, repayment) - Views and manages their own account-related information (e.g., checking balance, claiming rewards) - Participates in governance (for token holders, voting, etc.)
Best Practice
Threat 6: Cumulative loss of user rewards due to precision errors in division operations during reward calculation
During reward distribution calculations, division precision errors9 can cause some users' rewards to be consistently lost below the decimal point, leading to accumulation of losses.
Impact
Low
Due to the limited calculation precision of the contract, users may receive slightly less than the promised reward amount. However, this is a minute difference, often within the acceptable tolerance of financial systems (0.01%), and is not an intentional theft. Therefore, it is assessed as 'Low'.
Guideline
Add logic to verify the accuracy of the claimed reward amount
Use the
_verifyRewardCalculationfunction to reverse-calculate and verify the reward amountSet an error margin of 0.01%10 (a common tolerance in most financial systems)
Recommend using FixedPointMathLib
Use functions like
mulDivto perform multiplication and division safely while preserving maximum precisionUser-favorable rounding policy
If a user is entitled to a reward but the amount is truncated to zero by division, guarantee a minimum value (1 wei)
Best Practice
Custom Code
Threat 7: Double accumulation of rewards by withdrawing all LP tokens and calling notifyRewardAmount
After calling notifyRewardAmount, withdrawing all LP tokens to make the balance zero can cause the reward balance to accumulate twice, leading to an abnormal increase in the total recorded rewards. If staking resumes, the APR could spike, and if the allowance is insufficient, an InsolventReward revert could occur.
Conversely, if notifyRewardAmount is called when the LP token balance is zero, the rewards for that period may not carry over and could be lost.
Impact
Low
This can cause a temporary calculation error in the reward distribution logic or cause rewards to be lost or duplicated, but the probability of totalSupply becoming zero is low, so it is assessed as 'Low'.
Guideline
Prevent
totalSupplyfrom becoming zero by requiring a minimum LP token deposit when creating a reward vault.
Best Practice
Custom Code
Threat 8: Reward suspension due to normal removal of an incentive token
When a valid incentive token is removed, it can cause sudden user confusion due to the suspension of rewards and potential issues arising from changes to the reward structure.
Impact
Low
If an administrator removes an incentive while users are still eligible for rewards, those users will lose their rewards. However, since the administrator is determined by governance, the likelihood of this happening is low, so it is assessed as 'Low'.
Guideline
Incentive token removal or replacement should be queued and applied after a delay (3 hours).
This is to align with the maximum reward claim delay of 3 hours (MAX_REWARD_CLAIM_DELAY)11 in the
BGTIncentiveDistributor.To be added to the queue, it must pass validation logic.
The current balance of the incentive token must be zero.
Must be the
FactoryVaultManager.The token to be removed must be on the whitelist.
Adding an Incentive Token
Only
FactoryOwnercan add.
addIncentivecannot be called for a token in the removal queue.Changes to the reward vault's structure (adding/removing tokens) must be clearly communicated to users in advance and displayed on the UI.
Create a bot that listens for
IncentiveTokenWhitelistedandIncentiveTokenRemovedevents to display a popup on the protocol's website when a change occurs.
Best Practice
Custom Code
\
Footnotes
Last updated