Contradictory Documentation and actual function
The RewardSettings contract's variable name and comment contradict the actual calculation logic, so an admin could misconfigure the reward cap and unintentionally allow a single wallet to claim a large share of epoch rewards.
- Disclosed after under an hour
#41256 [SC-Insight] Contradictory Documentation and actual function
Submitted on Mar 13th 2025 at 03:27:02 UTC by @xdead4f for Audit Comp | Yeet
- Report ID: #41256
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/RewardSettings.sol
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
The RewardSettings.sol contract contains critical inconsistencies between variable names, comments, and actual implementation logic, creating significant risk of misunderstanding by developers, auditors, and users. This misconception could lead to unexpected reward distribution behavior and potential exploitation.
Vulnerability Details
RewardSettings.sol: Variable MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR
Reward.sol: Integration with the above variable in reward calculation logic
The variable MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR has a comment stating:
constructor() Ownable(msg.sender) {
/// @dev this is in percentage, 1/10 of the total rewards
MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR = 30;
}
This comment suggests:
- The value represents a percentage
- It should equate to "1/10" of total rewards
- But is initialized to 30
These statements are internally inconsistent and don't align with how the value is actually used.
Impact Details
- Unintended Reward Distribution: If an admin intends to increase the reward cap by increasing the parameter value (based on its name), they would actually be decreasing the maximum reward.
- Whale Exploitation Risk: If mistakenly set too low (e.g., 2 instead of 20), a single wallet could claim up to 50% of epoch rewards, potentially draining the reward pool unfairly.
Proof of Concept
Given this scenario :
- Current setting: 30 → Max reward = ~3.33% of epoch rewards
- Admin wants to double maximum rewards
- Misled by documentation, changes to 60
- Actual result: Max reward = ~1.67% (halved instead of doubled)
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 variable name and comment describe the value as a percentage that increases the cap, while the reward calculation divides by it, so the meaning is inverted.
Impact
An admin could unintentionally reduce the cap, or if set too low, a single wallet could claim up to 50% of epoch rewards and drain the pool unfairly.
What the attacker needed
Admin misconfigures the reward cap
The fix
The variable name and comment should be corrected to match the actual division logic, or the logic should be changed to match the documented percentage behaviour.
How it was found
- Current setting is 30, giving a maximum reward of about 3.33% of epoch rewards.
- Admin wants to double the maximum reward.
- Misled by the documentation, the admin changes the value to 60.
- The actual result is a maximum reward of about 1.67%, halved instead of doubled.
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 stores a number that controls the maximum reward one wallet can get. The name and comment suggest bigger numbers mean bigger rewards, but the code actually divides by that number, so bigger numbers mean smaller rewards. An admin following the misleading documentation could accidentally let one wallet take a huge share of the rewards.
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.