BriVault

First Flight #52
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

[L-2] Redundant and Misplaced Timestamp Check in `briVault::_setFinallizedVaultBalance()`

[L-2] Redundant and Misplaced Timestamp Check in briVault::_setFinallizedVaultBalance()

Description

The internal function `briVault::_setFinallizedVaultBalance()` checks whether block.`timestamp > eventStartDate` before recording the vault balance. However, it is called within `setWinner()`, which already ensures `block.timestamp > eventEndDate`. Because the event end time is necessarily after the start time, the additional check is redundant and logically misplaced.
Additionally, the function assigns and returns `finalizedVaultAsset` in a single statement, which reduces code readability. No validation exists to prevent multiple finalizations or zero-balance states.
Furthermore, the contract lacks proper NatSpec documentation for key functions, forcing reliance on external README files for understanding behavior. This increases maintenance burden and misunderstanding risk.
```solidity
function _setFinallizedVaultBalance () internal returns (uint256) {
@> if (block.timestamp <= eventStartDate) {
@> revert eventNotStarted();
@> }
return finalizedVaultAsset = IERC20(asset()).balanceOf(address(this));
}
```

Risk

Likelihood:

  • Reason 1 // Describe WHEN this will occur (avoid using "if" statements)

  • Reason 2

Impact:

1. Minor logical confusion in time validation flow.
2. Slight gas inefficiency due to redundant conditional.
3. Could cause unintended revert if eventStartDate and eventEndDate are close or equal.

Proof of Concept

Recommended Mitigation

- remove this code
+ add this code
1. Alternatively, handle vault finalization earlier and keep the logic separated from the winner selection flow.
2. Add state checks for non-zero and single finalization.
3. Refactor combined assignment-return for clarity.
4. Implement proper Natspec for better clarity of the code base.
```diff
+ function _setFinallizedVaultBalance () internal returns (uint256) {
- if (block.timestamp <= eventStartDate) {
- revert eventNotStarted();
- }
- return finalizedVaultAsset = IERC20(asset()).balanceOf(address(this));
- }
+ /// @notice Records the vault’s asset balance once the event has started.
+ /// @dev Should not be called more than once.
+ /// @return The finalized vault balance.
+ function _setFinalizedVaultBalance() internal returns (uint256) {
+ if (finalizedVaultAsset != 0) revert AlreadyFinalized();
+ uint256 balance = IERC20(asset()).balanceOf(address(this));
+ if (balance == 0) revert EmptyVault();
+ finalizedVaultAsset = balance;
+ return balance;
}
```
Updates

Appeal created

bube Lead Judge 19 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!