Off-by-One Logic in Escrow End Timestamp Calculation May Cause Unintended Escrow Delay
The contract uses a less-than-or-equal comparison to decide whether to push an escrow end timestamp to the next day, while the comment says 'less than 12 hours'. When the timestamp is exactly 12 hours away, the escrow is delayed by an extra day.
Originally disclosed on Immunefi
- Disclosed after under an hour
#45731 [SC-Insight] Off-by-One Logic in Escrow End Timestamp Calculation May Cause Unintended Escrow Delay
Submitted on May 19th 2025 at 19:53:04 UTC by @MRXSNOWDEN for Audit Comp | Flare | FAssets
- Report ID: #45731
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/flare-foundation/fassets/blob/main/contracts/assetManager/implementation/CoreVaultManager.sol
- Impacts:
Description
Brief/Intro
The _getNextEscrowEndTimestamp function in CoreVaultManager uses a <= comparison to determine if the next escrow end timestamp should be moved to the following day, while the comment specifies "less than 12 hours." This off-by-one logic discrepancy could result in escrows being delayed by an extra day when the difference is exactly 12 hours, potentially causing operational inefficiencies or user confusion.
Vulnerability Details
The relevant code in CoreVaultManager.sol is :
if (escrowEndTimestamp <= block.timestamp + 12 hours) { // less than 12 hours from now, move to the next day
escrowEndTimestamp += 1 days;
}
The comment states "less than 12 hours," but the code uses <=, which means that if the escrow end timestamp is exactly 12 hours from the current block timestamp, it will still be pushed to the next day. The correct logic to match the comment should use < instead of <=. This subtle difference can cause escrows to be delayed by a full day in edge cases, which may not be the intended behavior
Impact Details
While this issue does not directly result in loss or theft of funds, it can cause escrows to be unnecessarily delayed by up to 24 hours in certain edge cases. This could lead to operational inefficiencies, user frustration, or missed deadlines in time-sensitive applications. The impact is best categorized as a Code Optimizations and Enhancements Insight, as it affects the precision and predictability of the contract's time-based logic
References
Proof of Concept
Proof of Concept
1- Suppose the current block.timestamp is T
2- The calculated escrowEndTimestamp is exactly T + 12 hours
3 - Since escrowEndTimestamp == block.timestamp + 12 hours, the condition is true, and the timestamp is incremented by 1 day
4 - As a result, the escrow end timestamp is now T + 1 day + 12 hours, which is a full day later than what the comment and likely the intended logic suggest
Change the condition to :
if (escrowEndTimestamp < block.timestamp + 12 hours) { ... }
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an off-by-one error: the code uses a less-than-or-equal comparison where the comment and intended logic require a strict less-than comparison.
Impact
Escrows could be delayed by up to 24 hours in edge cases, causing operational inefficiencies or user frustration, but no funds are lost or stolen.
What the attacker needed
Escrow end timestamp exactly 12 hours away
The fix
The condition should be changed to use a strict less-than comparison instead of less-than-or-equal.
How it was found
- Set the current block timestamp to T.
- Set the calculated escrow end timestamp to exactly T plus 12 hours.
- Observe that the condition is true and the timestamp is incremented by one day.
- The escrow end timestamp becomes T plus one day plus 12 hours, a full day later than intended.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Smart contracts often use timestamps to schedule actions. Here, a check meant to move a deadline to the next day when it is less than 12 hours away also triggers when it is exactly 12 hours away, because of a small difference in comparison operators. That makes the deadline one day later than intended in that exact case.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.