Timelock operations can be executed due to incorrect usage of expirationPeriod
#44
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-21
grade-b
Q-10
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_11_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-10-kleidi/blob/ab89bcb443249e1524496b694ddb19e298dca799/src/Timelock.sol#L399-L404
https://github.com/code-423n4/2024-10-kleidi/blob/ab89bcb443249e1524496b694ddb19e298dca799/test/unit/Timelock.t.sol#L651-L678
https://github.com/code-423n4/2024-10-kleidi/blob/ab89bcb443249e1524496b694ddb19e298dca799/src/Timelock.sol#L972-L977
https://github.com/code-423n4/2024-10-kleidi/blob/ab89bcb443249e1524496b694ddb19e298dca799/test/unit/Timelock.t.sol#L691-L748
Vulnerability details
isOperationReady
function uses the currentexpirationPeriod
value, which can be updated after an operation is scheduled, instead of using theexpirationPeriod
value that was active when the operation was scheduled.Here's what causes it: Combination of two factors
isOperationReady
using the currentexpirationPeriod
valueupdateExpirationPeriod
allowing theexpirationPeriod
to be increased after operations are scheduledCan be confirmed by
MINIMUM_DELAY
and anexpirationPeriod
ofEXPIRATION_PERIOD
.MINIMUM_DELAY
).updateExpirationPeriod
to increase theexpirationPeriod
toEXPIRATION_PERIOD + 1
.timestamp + EXPIRATION_PERIOD
).Proof of Concept
In
Timelock.sol
, theisOperationReady
function uses the currentexpirationPeriod
instead of the one that was set when the operation was scheduled isOperationReady#L399-L404In Timelock.t.sol, does not cover the case where
expirationPeriod
is increased after scheduling Timelock.t.sol#L651-L677And the
updateExpirationPeriod
function allows theexpirationPeriod
to be increased after operations have been scheduled updateExpirationPeriod#L972-L977The
isOperationReady()
uses the currentexpirationPeriod
value instead of the one that was active when the operation was scheduled. TheupdateExpirationPeriod()
function allows increasing this value after the fact, which enables executing expired operations. The test suite does not cover this scenario.The following test in Timelock.t.sol#L691-L748 demonstrates the vulnerability
This test schedules an operation to update the
expirationPeriod
, waits until it's ready, executes it, and then verifies that the operation is done and theexpirationPeriod
is updated. However, it doesn't check if the operation can still be executed after the original expiration time has passed.Recommended Mitigation Steps
isOperationReady()
should check against the expiration period that was active when the operation was scheduled, not the current value by storing the expiration period with each scheduled operation.Assessed type
Governance
The text was updated successfully, but these errors were encountered: