Protocol safeguards for time durations are skewed by a factor of 7. Protocol may potentially lock NFT for period of 7 years.
Submitted by Trust, also found by subtle77, wagmi, Madalad, Matin, mookimgo, evan, Apocalypto, kaliberpoziomka8552, poirots, aga7hokakological, and yixxas
In VRFNFtRandomDraw\.sol initialize(), the MONTHINSECONDS variable is used to validate two values:
- configured time between redraws is under 1 month
- recoverTimelock (when NFT can be returned to owner) is less than 1 year in the future
if (_settings.drawBufferTime > MONTH_IN_SECONDS) {
revert REDRAW_TIMELOCK_NEEDS_TO_BE_LESS_THAN_A_MONTH();
}
...
if (
_settings.recoverTimelock >
block.timestamp + (MONTH_IN_SECONDS * 12)
) {
revert RECOVER_TIMELOCK_NEEDS_TO_BE_LESS_THAN_A_YEAR();
}
The issue is that MONTHINSECONDS is calculated incorrectly:
/// @dev 60 seconds in a min, 60 mins in an hour
uint256 immutable HOUR_IN_SECONDS = 60 * 60;
/// @dev 24 hours in a day 7 days in a week
uint256 immutable WEEK_IN_SECONDS = (3600 * 24 * 7);
// @dev about 30 days in a month
uint256 immutable MONTH_IN_SECONDS = (3600 * 24 * 7) * 30;
MONTHINSECONDS multiplies by 7 incorrectly, as it was copied from WEEKINSECONDS. Therefore, actual seconds calculated is equivalent of 7 months. Therefore, recoverTimelock can be up to a non-sensible value of 7 years, and re-draws every up to 7 months.
Impact
Protocol safeguards for time durations are skewed by a factor of 7. Protocol may potentially lock NFT for period of 7 years.
Recommended Mitigation Steps
Fix MONTHINSECONDS calculation: uint256 immutable MONTH_IN_SECONDS = (3600 * 24) * 30;
iainnash (Forgeries) confirmed
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity smart contracts bug in Forgeries contest. Code4rena made it public on 28 February 2023. Found in the 2022-12-forgeries audit contest (finding M-03), also found by 11 other wardens.
About Smart contracts
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.