Hardcoded deadline for the openPosition params in the _placePerpOrder function
kaysoft
Medium
Summary
The deadline param for the openPosition is hardcoded to block.timestamp in the _placePerpOrder function.
Vulnerability Detail
The idea of the deadline is to allow the client to pass the deadline which is the time specified in milliseconds that have passed since the beginning of the Unix epoch plus allowed extra time (e.g 20minutes) so that the transaction fails whenever block.timestamp is more than the deadline. There is a check for require(deadline <= block.timestamp) to validate deadline.
Since the deadline is hardcoded as block.timestamp , the deadline will be irrelevant since block.timestamp <= block.timestamp will always be true anytime the transaction is mined
Impact
Since the deadline is hardcoded as block.timestamp , the deadline will be irrelevant since block.timestamp <= block.timestamp will always be true anytime the transaction is mined.
The deadline is hardcoded to block.timestamp which will make the deadline parameter irrelevant. Allow the deadline to be passed as input parameter to the _placePerpOrder function.
kaysoft
medium
Hardcoded
deadline
for theopenPosition
params in the _placePerpOrder functionkaysoft
Medium
Summary
The
deadline
param for the openPosition is hardcoded toblock.timestamp
in the _placePerpOrder function.Vulnerability Detail
The idea of the deadline is to allow the client to pass the deadline which is the time specified in milliseconds that have passed since the beginning of the Unix epoch plus allowed extra time (e.g 20minutes) so that the transaction fails whenever block.timestamp is more than the deadline. There is a check for
require(deadline <= block.timestamp)
to validate deadline. Since thedeadline
is hardcoded as block.timestamp , thedeadline
will be irrelevant sinceblock.timestamp <= block.timestamp
will always be true anytime the transaction is minedImpact
Since the
deadline
is hardcoded as block.timestamp , thedeadline
will be irrelevant sinceblock.timestamp <= block.timestamp
will always be true anytime the transaction is mined.Code Snippet
see: PerpDepository.sol#L362
The
deadline
is hardcoded to block.timestamp which will make the deadline parameter irrelevant. Allow thedeadline
to be passed as input parameter to the _placePerpOrder function.Tool used
Manual Review
Recommendation
Consider accepting the deadline as parameter to the _placePerpOrder function like below