Skip to content

[5.6] Use hash_equals for verifying url signatures#23618

Merged
taylorotwell merged 1 commit intolaravel:5.6from
hmazter:5.6-url-signature-hash-equals
Mar 20, 2018
Merged

[5.6] Use hash_equals for verifying url signatures#23618
taylorotwell merged 1 commit intolaravel:5.6from
hmazter:5.6-url-signature-hash-equals

Conversation

@hmazter
Copy link
Copy Markdown
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
Copy Markdown

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.

3 participants