Open hats-bug-reporter[bot] opened 1 month ago
Github username: @agbanusi Twitter username: -- Submission hash (on-chain): 0xb22d944d6c8eea7d122a50327642c5950e81a09c2a1b9f14c501f537e6a5bafa Severity: medium
Description: Description\ There is a non-linear increase of epoch due to divide before multiply can cause unwanted issues
Attack Scenario\
function _roundToEpoch(uint256 timestamp_) internal pure returns (uint256) { return (timestamp_ / _WEEK) * _WEEK; }
An example is
now gives an epoch of 1721260800 and an hour later gives an epoch of 1721865600
The disparity of epoch is large and non-predictable which can lead to complexity issues
Attachments
Proof of Concept (PoC) File\ https://github.com/hats-finance/Fenix--0x9d7765a7ebd5b6322a30797a44a5428531970d3d/blob/353c8e8e24454336e805e5c0e11e4e9ae1491d03/contracts/nest/SingelTokenVirtualRewarderUpgradeable.sol#L358
Revised Code File (Optional)
The time rounding down is specially designed to consider the epoch boundaries
Github username: @agbanusi Twitter username: -- Submission hash (on-chain): 0xb22d944d6c8eea7d122a50327642c5950e81a09c2a1b9f14c501f537e6a5bafa Severity: medium
Description: Description\ There is a non-linear increase of epoch due to divide before multiply can cause unwanted issues
Attack Scenario\
An example is
The disparity of epoch is large and non-predictable which can lead to complexity issues
Attachments
Proof of Concept (PoC) File\ https://github.com/hats-finance/Fenix--0x9d7765a7ebd5b6322a30797a44a5428531970d3d/blob/353c8e8e24454336e805e5c0e11e4e9ae1491d03/contracts/nest/SingelTokenVirtualRewarderUpgradeable.sol#L358
Revised Code File (Optional)