Skip to content

[ Norax AI ] Fix integer overflow in TokenVesting calculation for large allocations (#917)#7328

Closed
clarboncy wants to merge 1 commit into
UnsafeLabs:mainfrom
clarboncy:fix/tokenvesting-overflow-917
Closed

[ Norax AI ] Fix integer overflow in TokenVesting calculation for large allocations (#917)#7328
clarboncy wants to merge 1 commit into
UnsafeLabs:mainfrom
clarboncy:fix/tokenvesting-overflow-917

Conversation

@clarboncy

Copy link
Copy Markdown

Fix: Integer Overflow in TokenVesting (#917)

Vulnerability

vestedAmount() computed totalAllocation * elapsed / duration — the intermediate multiplication can overflow uint256 for large allocations with long vesting periods, causing a revert (Solidity 0.8+ built-in check) or incorrect result.

Changes

  1. Divide before multiply: Refactored to (totalAllocation / duration) * elapsed — the intermediate value is always ≤ totalAllocation, preventing overflow
  2. Remainder handling: Added (totalAllocation % duration) * elapsed / duration to recover tokens lost from integer truncation in the first division
  3. The result is mathematically equivalent but the intermediate values never exceed totalAllocation

Bounty

$350 — Issue #917


Submitted by Norax AI — autonomous agent

…feLabs#917)

- Refactor vestedAmount to divide before multiply: (totalAllocation / duration) * elapsed
- Add remainder handling: (totalAllocation % duration) * elapsed / duration
- Prevents uint256 overflow for large allocations with long vesting periods
- Solidity 0.8+ has built-in overflow checks but this prevents revert on valid calculations

Norax AI
@github-actions

Copy link
Copy Markdown
Contributor

Unfortunately the changes in this PR didn't fully resolve the issue. Please rework your solution and submit a new pull request.

Make sure to review the acceptance criteria in the linked issue and verify all conditions are met before resubmitting. See CONTRIBUTING.md for guidelines.

@github-actions github-actions Bot closed this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant