Closed sherlock-admin closed 9 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid: watson should provide a POC
Invalid, I don't see the issue of allowing multiple sessions starting on the same block
Mylifechangefast_eth
medium
Race condition will occur when submitting block specimen proof
Summary
n the provided code snippet, there is a potential vulnerability related to the management of the sessionDeadline variable. The vulnerability arises due to the lack of proper synchronization between the check for sessionDeadline being equal to 0 and the subsequent assignment of a new value to sessionDeadline.
Vulnerability Detail
the condition checks if the sessionDeadline is zero, indicating that this is the first specimen submission for a block (as it was initialized to zero before the update).
The require statement ensures that the session is still open for submissions (session.requiresAudit should be false). If requiresAudit is true, it implies that the session has closed, and submissions are no longer accepted.
This line calculates the current block on the target chain by extrapolating based on the elapsed time since the last update of blockOnCurrentChain. It takes into account the time difference, converting it to blocks based on the provided _secondsPerBlock parameter.
It determines the lower bound for the valid block height, considering the allowed threshold. If the current block on the target chain is greater than or equal to the threshold, it subtracts the threshold; otherwise, it sets the lower bound to zero.
This require statement ensures that the submitted block height is within the allowed range for live synchronization. It checks if the block height is greater than or equal to the lower bound and less than or equal to the upper bound.
Initial State:
sessionDeadline is 0, indicating no ongoing session. Concurrent Transactions:
Two transactions simultaneously check sessionDeadline and find it to be 0. Concurrent Session Initialization:
Both transactions calculate currentBlockOnTargetChain and lowerBound. Both transactions set a new value for sessionDeadline, initiating multiple sessions for the same block. Duplicate Session Start:
The result is multiple sessions started concurrently for the same block.
Emitting a just concluded blockspecimenproof of both transactions.
Impact
Code Snippet
Tool used
Sleepless night
Recommendation
// Use a locking mechanism to prevent concurrent session initialization bool private sessionInitiated;
Or better still find another way to have a locking mechanism in this function