Skip to content

Conversation

thinkverse
Copy link
Contributor

The use of !== over hash_equals was bothering me, not sure if the validation needs a timing-safe string comparison but better safe than sorry. It is also the way Lemon Squeezy uses in their example:

$secret    = '[SIGNING_SECRET]'; // from your webhook settings
$payload   = file_get_contents('php://input');
$hash      = hash_hmac('sha256', $payload, $secret);
$signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';

if (!hash_equals($hash, $signature)) {
    throw new Exception('Invalid signature.');
}

@driesvints
Copy link
Contributor

Thanks! I think I took the example as it was presented in the docs at the time. They've probably changed since.

@driesvints driesvints merged commit d5a7265 into lmsqueezy:main Aug 14, 2023
@thinkverse thinkverse deleted the use_hash_equals branch August 14, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants