Skip to content

Commit

Permalink
Use absolute timestamp delta to check hmac tolerance
Browse files Browse the repository at this point in the history
This avoids unexpected behaviour if the timestamp of a worker is ahead
of the webuis time.
  • Loading branch information
nicksinger committed Jul 23, 2024
1 parent fd0c330 commit 3883e61
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/OpenQA/Shared/Controller/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ sub _is_timestamp_valid ($self, $our_timestamp, $remote_timestamp) {
my $tolerance = $self->config->{api_hmac_time_tolerance}
// 300; # make extra sure this value is never empty to avoid security issues

return 1 if ($our_timestamp - $remote_timestamp <= $tolerance);
return 1 if (abs($our_timestamp - $remote_timestamp) <= $tolerance);
$log->debug(
qq{Timestamp mismatch over ${tolerance}s; our_timestamp: $our_timestamp, X-API-Microtime (from worker): $remote_timestamp}
);
Expand Down

0 comments on commit 3883e61

Please sign in to comment.