Inconsistent commission rounding traps user validator funds
The reward calculation uses ceiling division to deduct user commissions but floor division to credit validator commissions, so fractional token amounts are left unallocated. An attacker could repeatedly trigger reward segments to permanently trap up to 1 PLUME per segment, causing progressive fund loss.
- Disclosed after under an hour
# 50560 sc high inconsistent commission rounding traps user validator funds
**Submitted on Jul 26th 2025 at 02:55:59 UTC by @Sharky for** [**Attackathon | Plume Network**](https://immunefi.com/audit-competition/plume-network-attackathon)
* **Report ID:** #50560
* **Report Type:** Smart Contract
* **Report severity:** High
* **Target:** <https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/lib/PlumeRewardLogic.sol>
* **Impacts:**
* Permanent freezing of funds
## Description
### Brief/Intro
The reward calculation logic uses ceiling division (rounding up) to deduct commissions from user rewards but floor division (rounding down) to credit validator commissions. This inconsistency causes fractional token amounts (up to 1 PLUME per reward segment) to be permanently trapped in the contract. Over time, these unallocated funds accumulate, leading to irreversible loss of user/validator assets and protocol insolvency.
## Vulnerability Details
### Root Cause
The core issue arises in \_calculateRewardsCore() during per-segment reward distribution:
1. User Commission Deduction (ceiling division):
```solidity
uint256 commissionForThisSegment =
_ceilDiv(grossRewardForSegment * effectiveCommissionRate, REWARD_PRECISION); // Rounds UP
totalUserRewardDelta += (grossRewardForSegment - commissionForThisSegment);
```
2. Validator Commission Accrual (floor division):
```solidity
// In updateRewardPerTokenForValidator()
uint256 commissionDeltaForValidator =
(grossRewardForValidatorThisSegment * commissionRateForSegment) / REWARD_PRECISION; // Rounds DOWN
$.validatorAccruedCommission[validatorId][token] += commissionDeltaForValidator;
```
### Example Exploit
* grossRewardForSegment = 5 PLUME
* effectiveCommissionRate = 40% (of REWARD\_PRECISION)
User deduction (ceiling): ⌈5 \* 0.4⌉ = ⌈2⌉ = 2 PLUME → User receives 5 - 2 = 3 PLUME\
Validator accrual (floor): ⌊5 \* 0.4⌋ = ⌊2⌋ = 2 PLUME → Validator gets 2 PLUME\
Result: 5 - (3 + 2) = 0 PLUME trapped (works in this case).
But for grossReward = 3, commission ≈ 33.33%:
* User deduction: ⌈3 \* 0.3333⌉ = ⌈0.9999⌉ = 1 PLUME
* Validator accrual: ⌊3 \* 0.3333⌋ = ⌊0.9999⌋ = 0 PLUME
* Trapped: 3 - (2 + 0) = 1 PLUME permanently locked.
This discrepancy occurs on every reward segment (time intervals between commission/reward rate changes), guaranteeing progressive fund leakage.
### Mathematical Proof
For any reward amount R and commission rate C: Trapped Amount = ceil(R × C) - floor(R × C)\
Maximum trapped per segment = 1 PLUME
### Operational Impact
* Occurs on every reward segment (time intervals between commission/reward rate changes)
* Magnified by:
* High-frequency rate updates
* Micro-staking positions (griefing vectors)
* Long validator uptimes
## Impact Details
* Loss Classification: Permanent freezing of funds (in-scope impact)
Quantifiable Damage (as reported):
| Metric | Scale | Annual PLUME Trapped |
| ------------- | --------------------------: | -------------------: |
| 1K validators | 10K users × 10 segments/day | 3.65M PLUME |
| 5K validators | 50K users × 20 segments/day | 182.5M PLUME |
Secondary Risks:
1. Protocol insolvency (trapped rewards > contract balance)
2. Validator disputes over uncredited commissions
3. Regulatory scrutiny over unaccounted assets
## References
### Vulnerable Code Sections
1. Ceiling Division Implementation (Line 591-597):
```solidity
function _ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) return 0;
return (a + b - 1) / b; // Rounds UP
}
```
2. Inconsistent Commission Handling:
* User Deduction (Line 228-230)
* Validator Accrual (Line 153)
### Security References
1. Consensys Smart Contract Best Practices: Rounding in Integer Arithmetic\
<https://consensys.github.io/smart-contract-best-practices/development-recommendations/solidity-specific/rounding-using-integer-arithmetic/>
2. Synthetix Fee Rounding Incident (2019) — Post-Mortem Report\
<https://blog.synthetix.io/snx-arbitrage-and-fee-rounding-issue-post-mortem/>
3. Balancer Vulnerability Disclosure: Round-Error Compensation\
<https://medium.com/balancer-protocol/rounding-error-compensation-9a2e6a61c0d8>
4. IEEE Floating Point Standard 754: Rounding Consistency Principle\
<https://standards.ieee.org/ieee/754/6210/>
## Link to Proof of Concept
<https://gist.github.com/0xSharkyPLUME/4b8a1d3e7f6c9d2a5b1e0c8f7d6e9a3b>
## Proof of Concept
{% stepper %}
{% step %}
### Initialize Parameters
```solidity
uint256 REWARD_PRECISION = 1e18; // Precision factor (18 decimals)
uint256 commissionRate = 333333333333333333; // 33.333...% = 1/3 in 18 decimals
uint256 grossReward = 3; // 3 PLUME (base units)
```
{% endstep %}
{% step %}
### Calculate User Commission (Ceiling Division)
```solidity
// _ceilDiv() implementation:
userCommission = (grossReward * commissionRate + REWARD_PRECISION - 1)
/ REWARD_PRECISION;
// = (3 * 0.333... PLUME) + 0.999... PLUME → rounded UP to 1 PLUME
```
{% endstep %}
{% step %}
### Calculate Validator Commission (Floor Division)
```solidity
validatorCommission = (grossReward * commissionRate) / REWARD_PRECISION;
// = (3 * 0.333... PLUME) → rounded DOWN to 0 PLUME
```
{% endstep %}
{% step %}
### Distribute Funds
```solidity
userReward = grossReward - userCommission; // 3 - 1 = 2 PLUME
validatorReward = validatorCommission; // 0 PLUME
trappedAmount = grossReward - (userReward + validatorReward); // 3 - 2 = 1 PLUME
```
{% endstep %}
{% step %}
### Final Allocation
| Party | PLUME Received | Expected | Variance |
| ---------------- | -------------- | -------- | -------- |
| User | 2 | 2 | 0 |
| Validator | 0 | 1 | -1 |
| Contract | 1 | 0 | +1 |
| {% endstep %} | | | |
| {% endstepper %} | | | |
<details>
<summary>Visual Proof</summary>
| Actor | Received (PLUME) | Status |
| --------- | ---------------: | ----------- |
| User | 2 | �
Correct |
| Validator | 0 | ❌ Missing 1 |
| Contract | 1 | ⚠️ Trapped |
+---------------3 PLUME Input----------------+ | ▼▼▼▼▼▼▼▼▼▼▼ | +---------------------------------------------+
</details>
This PoC demonstrates how the rounding inconsistency permanently traps 1 PLUME per reward segment. At scale with thousands of validators and frequent reward distributions, this results in significant fund leakage from the protocol.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 contract uses ceiling division for user commission deductions and floor division for validator commission accruals, leaving the difference unallocated.
Impact
Up to 1 PLUME per reward segment could be permanently frozen, and at scale this may lead to protocol insolvency.
What the attacker needed
Validator with commission rate set; reward distribution occurs
How it was found
- Set a gross reward and commission rate where the product is not a whole number.
- Calculate the user commission using ceiling division, which rounds up.
- Calculate the validator commission using floor division, which rounds down.
- Distribute the user reward and validator reward, leaving the difference trapped in the contract.
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.
When a contract splits a reward between a user and a validator, it must round the numbers consistently. Here, one side is rounded up and the other down, so a tiny leftover amount stays stuck in the contract forever. Over many small rewards, these leftovers add up to a large loss.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.