The contract performs arithmetic operations on unsigned and signed integers without explicitly handling overflow or underflow conditions. In the absence of proper checks or usage of libraries like SafeMath (or SafeCast for the specific data types used), this can result in unintended behavior such as incorrect calculations, contract failure, or manipulation of values, which can be exploited maliciously.
distributeValue(Data storage self, SD59x18 value)
:
This function divides and adds values based on the total number of shares and the distributed value. If totalShares
or value
is extremely large, it could overflow during the division or addition operations.
setActorShares(Data storage self, bytes32 actorId, UD60x18 newActorShares)
:
This function modifies the total number of shares and updates actor shares. The addition and subtraction of shares are potential candidates for overflow or underflow.
_updateLastValuePerShare(Data storage self, Actor storage actor, UD60x18 newActorShares)
:
Similar to setActorShares
, any arithmetic operation here could potentially overflow, particularly when large shares are set.
The contract performs arithmetic without explicit overflow and underflow checks, particularly when modifying totalShares
or shares
values. The arithmetic operations rely on casting, which may cause overflows or underflows when values exceed their respective bounds.
Data Corruption: If an overflow or underflow occurs, it could result in incorrect share calculations, leading to data corruption.
Loss of Funds: Actors may receive more or less than their fair share of the distributed value, causing financial discrepancies.
Contract Failure: If an overflow occurs during operations, it could cause the contract to fail or behave unexpectedly.
Security Exploits: Malicious users could exploit these vulnerabilities by crafting large values to manipulate or disrupt the intended distribution mechanism.
Mythril
Use SafeMath: To prevent overflow and underflow, use SafeMath or SafeCast libraries that automatically revert on arithmetic overflows and underflows.
For unsigned integers (like uint128
, uint256
), the OpenZeppelin SafeMath
library should be used.
For signed integers (like int256
), the SafeCast
library from OpenZeppelin can be used for safe casting.
Explicit Overflow Checks: Ensure that every arithmetic operation (addition, subtraction, multiplication, division) includes overflow/underflow checks.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.