code-423n4 / 2021-04-vader-findings

1 stars 0 forks source link

The Calculation For nextEraTime Drifts, Causing Eras To Occur Further And Further Into The Future #193

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

jvaqa

Vulnerability details

Impact

The Calculation For nextEraTime Drifts, Causing Eras To Occur Further And Further Into The Future.

In Vader.sol, eras are intended to occur every 24 hours. This means that a correct implementation would add 24 hours to the end-time of the previous era to find the end-time of the next era. However, the current method for calculating the next era's end-time uses block.timestamp, rather than the previous era's end-time.

Proof of Concept

This line of code will cause a perpetual drift of era times, causing each era to actually be 24 hours plus the time between when the last era ended and when Vader._transfer() is next called.

Recommended Mitigation Steps

In Vader.sol, change this:

nextEraTime = block.timestamp + secondsPerEra;

to this:

nextEraTime = nextEraTime + secondsPerEra;