Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Use hash_equals for verifying url signatures #23618

Merged
merged 1 commit into from
Mar 20, 2018
Merged

[5.6] Use hash_equals for verifying url signatures #23618

merged 1 commit into from
Mar 20, 2018

Conversation

hmazter
Copy link
Contributor

@hmazter hmazter commented Mar 19, 2018

The PR updates the comparison of the URL signature to use the timing attack safe hash_equals function instead of a simple ===.

I don't know if this is strictly necessary for this use case. But since there exists a function for comparing hashes, I think it could/should be used.

Feel free to reject it if it is not needed.

@taylorotwell taylorotwell merged commit e29b33f into laravel:5.6 Mar 20, 2018
@hmazter hmazter deleted the 5.6-url-signature-hash-equals branch March 20, 2018 10:26
@ludo237
Copy link

ludo237 commented Mar 28, 2018

This change broke my test

ErrorException: hash_equals(): Expected user_string to be a string, null given

/app/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:350
/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221
/app/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php:57
/app/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php:106
/app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ValidateSignature.php:21
/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:149
/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
/app/app/Http/Middleware/RedirectIfAuthenticated.php:28

Which works with 5.6.13

Basically if asignature parameter is not provided it breaks. You should change this line to

$request->query('signature', '') in order to throw an InvalidSignatureException instead of an ErrorException

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.

None yet

3 participants