Epoch-boundary checkpoints retroactively qualify for the previous epoch’s rewards
The epoch-end timestamp used for reward snapshots equals the first second of the next epoch, and the voting escrow's historical lookup includes checkpoints at that exact timestamp. An attacker could create or increase a lock at that boundary second and retroactively qualify for the previous epoch's rewards, stealing or diluting emissions.
0xastronatey Follow with 0x15, 0xanmol and 39 others
Originally disclosed on Code4rena
Submitted by 0xastronatey, also found by 0x15, 0xanmol, 0xApple, 0xDemon, 0xscater, 0xsolisec, aestheticbhai, ahahaHard1k, akhilmanga, Alan_Clan_67, b_void, beer, BlockKnock, dna-thug, Drynooo, gesha17, Hakeem_is_here, happykilling, hiram, hodlturk, jerry0422, jhongamersx, kb520, kind0dev, legat, meganpark, NexusAudits, nstatoshi, oreztker, qed, QuillAudits_Team, saamin, sgtpepper, skipper, solarizer_ai, th3_hybrid, udaykiranpedda, Waiyaki, winfunc, XDZIBECX, and y4y
/protocol/emissions/CoreEmissionsController.sol#L178-L180/protocol/emissions/CoreEmissionsController.sol#L207-L213/protocol/emissions/TrustBonding.sol#L194-L213/protocol/emissions/TrustBonding.sol#L475-L492
TrustBonding snapshots veTRUST at epochTimestampEnd(epoch), but currentEpoch() already advances at that exact timestamp. Because VotingEscrow now resolves historical checkpoints with an inclusive ts <= t lookup, a lock created, topped up, or extended at the first second of epoch N+1 is still counted inside epoch N’s reward snapshot, letting an attacker steal or dilute the previous epoch’s emissions without actually being bonded during that epoch.
This is distinct from the known post-mortem underflow issue (POST-MORTEM.md#L22-L57). That outage required a checkpoint strictly after the boundary (ts > t); this issue exploits a checkpoint exactly at the boundary (ts == t), which the fixed binary-search lookup now intentionally includes (VotingEscrow.sol#L544-L576, VotingEscrow.sol#L590-L623).
Root Cause
1. Controller epoch arithmetic makes epochTimestampEnd(n) equal to the first moment of epoch n+1
CoreEmissionsController.sol#L178-L180
function _calculateEpochTimestampEnd(uint256 epoch) internal view returns (uint256) {
return _START_TIMESTAMP + (epoch * _EPOCH_LENGTH) + _EPOCH_LENGTH;
// <-- returns the first timestamp of epoch+1
}
CoreEmissionsController.sol#L207-L213
function _calculateTotalEpochsToTimestamp(uint256 timestamp) internal view returns (uint256) {
if (timestamp < _START_TIMESTAMP) {
return 0;
}
return (timestamp - _START_TIMESTAMP) / _EPOCH_LENGTH;
// <-- at timestamp == epochTimestampEnd(n), currentEpoch() is already n+1
}
The controller-side epoch arithmetic makes epochTimestampEnd(n) equal to the first moment of epoch n+1, not the last in-epoch moment of n.
2. TrustBonding allocates rewards from boundary snapshots, so the inclusive choice directly feeds reward accounting
function totalBondedBalanceAtEpochEnd(uint256 epoch) public view returns (uint256) {
if (epoch > currentEpoch()) {
revert TrustBonding_InvalidEpoch();
}
return _totalSupply(_epochTimestampEnd(epoch));
// <-- previous-epoch rewards use the inclusive boundary timestamp as the snapshot time
}
function userBondedBalanceAtEpochEnd(address account, uint256 epoch) public view returns (uint256) {
if (account == address(0)) {
revert TrustBonding_ZeroAddress();
}
if (epoch > currentEpoch()) {
revert TrustBonding_InvalidEpoch();
}
return _balanceOf(account, _epochTimestampEnd(epoch));
// <-- a checkpoint created exactly at that boundary is eligible for this snapshot
}
function _userEligibleRewardsForEpoch(address account, uint256 epoch) internal view returns (uint256) {
if (account == address(0)) {
revert TrustBonding_ZeroAddress();
}
if (epoch > currentEpoch()) {
revert TrustBonding_InvalidEpoch();
}
uint256 userBalance = userBondedBalanceAtEpochEnd(account, epoch);
uint256 totalBalance = totalBondedBalanceAtEpochEnd(epoch);
// <-- reward allocation depends entirely on those boundary snapshots
if (userBalance == 0 || totalBalance == 0) {
return 0;
}
return userBalance * _emissionsForEpoch(epoch) / totalBalance;
}
3. VotingEscrow checkpoint writes and inclusive historical lookups admit boundary-second mutations
u_new.ts = block.timestamp;
u_new.blk = block.number;
user_point_history[addr][user_epoch] = u_new;
// <-- lock/create/top-up/extend writes a checkpoint at the exact transaction timestamp
if (point_history[_mid].ts <= _ts) {
_min = _mid;
// <-- global checkpoint lookup is inclusive: ts == snapshot time is selected
} else {
_max = _mid - 1;
}
if (user_point_history[addr][_mid].ts <= _ts) {
_min = _mid;
// <-- user checkpoint lookup is inclusive too
} else {
_max = _mid - 1;
}
uint256 target_epoch = _find_user_timestamp_epoch(addr, _t, user_point_epoch[addr]);
// <-- a user checkpoint created at _t is treated as part of the balance snapshot at _t
uint256 target_epoch = _find_timestamp_epoch(t, epoch);
// <-- same rule for total supply
Lock mutations in VotingEscrow always checkpoint at block.timestamp, and both the global and per-user historical lookups now deliberately select the latest checkpoint whose timestamp is <= t. That means a checkpoint written exactly at epochTimestampEnd(prevEpoch) is included in prevEpoch’s reward snapshot.
4. claimRewards targets the previous epoch whose snapshot still admits brand-new checkpoints
uint256 currentEpochLocal = currentEpoch();
if (currentEpochLocal == 0) {
revert TrustBonding_NoClaimingDuringFirstEpoch();
}
uint256 prevEpoch = currentEpochLocal - 1;
uint256 rawUserRewards = _userEligibleRewardsForEpoch(msg.sender, prevEpoch);
// <-- once the boundary is reached, the contract claims prevEpoch,
// but prevEpoch's snapshot still includes checkpoints created at that same boundary
So once the boundary timestamp is reached, the contract immediately claims the previous epoch, but that previous-epoch snapshot still admits brand-new checkpoints created in the same second.
Internal Pre-conditions
The satellite controller must hold claimable emissions for the target epoch, which is the normal operating condition for claimRewards().
External Pre-conditions
The attacker must be able to submit a lock mutation at the exact timestamp returned by epochTimestampEnd(prevEpoch). An EOA can do this through ordinary VotingEscrow entry points such as create_lock, increase_amount, or increase_unlock_time. The exploit does not require any privileged role. EOA access is allowed because the inherited gate only blocks contract callers unless whitelisted.
Attack Path
- The attacker waits until
t = epochTimestampEnd(prevEpoch). - At that exact timestamp,
currentEpoch()already returnsprevEpoch + 1because epoch arithmetic is integer-division based on(timestamp - start) / epochLength. - In that same second, the attacker calls
create_lock,increase_amount, orincrease_unlock_time.VotingEscrowwrites a checkpoint withts = block.timestamp, i.e.ts = epochTimestampEnd(prevEpoch). claimRewards()now targetsprevEpoch, and_userEligibleRewardsForEpoch()computes balances from_balanceOf/_totalSupplyatepochTimestampEnd(prevEpoch).- Because the historical lookup is inclusive (
ts <= t), the attacker’s brand-new boundary checkpoint is treated as part ofprevEpoch’s snapshot. The attacker receives rewards for an epoch they did not actually participate in. - If nobody else was bonded during
prevEpoch, the attacker can capture the entire epoch’s emissions by joining only at the first second of the next epoch. If others were bonded, the attacker still retroactively dilutes them.
Impact
This is direct reward theft. The cleanest version is at the epoch-0/epoch-1 boundary: the attacker can join only when epoch 1 has already started, yet still claim epoch 0 emissions. For epochs 0 and 1, the personal-utilization path is automatically 100%, so the exploit does not even need MultiVault activity to get through the utilization layer.
The bug also generalizes beyond the very first epoch. Any existing veTRUST holder can retroactively increase their previous-epoch voting weight by topping up or extending at the first second of the next epoch, which steals emissions from honest participants every cycle. Because the attacker’s capital is only locked, not spent, the attack cost is mainly timing and temporary capital commitment, while the extracted value is live emissions. I would rate this High.
Negative Check (why blockers don’t apply)
- Access control does not stop it. The relevant lock-mutating entry points are inherited
VotingEscrowuser flows, and EOAs can call them permissionlessly. claimRewards()itself works exactly as intended; the bug is the historical snapshot timestamp it relies on. The claim path simply consumes the corrupted-at-boundary snapshot.- The known underflow fix does not prevent this. It changed historical lookup behavior to select checkpoints with
ts <= t(POST-MORTEM.md(PR #126 context),VotingEscrow.sol#L544-L576,VotingEscrow.sol#L590-L623); that inclusive rule is exactly what makes the boundary checkpoint count toward the old epoch. - This is not the prior zero-amount/utilization-driven repeat-claim issue (
Zero-amount claims bypass claimed check) documented in the published V12 findings (README.md#L30-L34,code_423n4_2026_03_intuition__main_0a19e25_findings.md#L256-L275). This issue does not rely on utilization gaming or missing claims; it is purely a temporal snapshot-admission bug.
Mitigation
Make the epoch-end reward snapshot exclusive.
The simplest fix is to snapshot at epochTimestampEnd(epoch) - 1 instead of epochTimestampEnd(epoch), so only voting power that existed strictly before the next epoch began is eligible. A more invasive but cleaner alternative is to redefine the controller’s “epoch end” helper to be an inclusive in-epoch timestamp and keep that convention consistent across currentEpoch(), epochAtTimestamp(), _balanceOf(), and _totalSupply().
Add regression tests for:
create_lockexactly atepochTimestampEnd(n)increase_amountexactly atepochTimestampEnd(n)increase_unlock_timeexactly atepochTimestampEnd(n)- immediate
claimRewards()forn
Proof of Concept
View Detailed Proof of Concept
Local Verification
Command run locally:
forge test --match-path tests/PoCEpochBoundaryRewards.t.sol --match-test test_boundaryJoinRetroactivelyEarnsPreviousEpochRewards -v
Output:
Ran 1 test for tests/PoCEpochBoundaryRewards.t.sol:PoCEpochBoundaryRewards
[PASS] test_boundaryJoinRetroactivelyEarnsPreviousEpochRewards() (gas: 523951)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 8.57ms (765.96µs CPU time)
Ran 1 test suite in 150.34ms (8.57ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
- Updated
CoreEmissionsControllerepoch-end calculation to be boundary-exclusive across epochs (end = start + (epoch+1)*length - 1).- Added per-epoch budget guardrails in
TrustBonding.claimRewards(revert when exhausted, clamp to remaining budget otherwise).- Updated and added unit tests to reflect the new closed-interval semantics and to regression-test boundary eligibility and budget invariants.
Status: Mitigation confirmed. Full details in reports from jerry0422, gesha17, and 0xastronatey.
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 epoch-end helper returns the first timestamp of the next epoch, and the voting escrow's historical balance lookup includes checkpoints at exactly that timestamp, so a lock mutation at the boundary is counted in the previous epoch's snapshot.
Impact
An attacker could steal the entire previous epoch's emissions if nobody else was bonded, or retroactively dilute other participants' rewards; the attack costs only timing and temporary capital lock-up.
What the attacker needed
Ability to submit a transaction at the exact boundary second; claimable emissions exist for the target epoch; no privileged role required
The fix
The epoch-end snapshot was made boundary-exclusive (end = start + (epoch+1)*length - 1) and per-epoch budget guardrails were added; the mitigation was confirmed.
How it was found
- Wait until the timestamp equal to the end of the previous epoch.
- At that exact second, call a lock-mutating function such as create_lock, increase_amount, or increase_unlock_time.
- Call claimRewards, which targets the previous epoch and computes balances at that boundary timestamp.
- Because the lookup includes checkpoints at that timestamp, the new lock counts toward the previous epoch's rewards.
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.
This is a smart contract that pays rewards to people who lock tokens for a period. The reward for each period is based on how many tokens were locked at the moment the period ended. The code mistakenly treats the first second of the next period as still part of the previous one, so someone can lock tokens right at that second and still get paid for the period that just finished.
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.