[8.x] Throw if tag is passed but is not supported #41479
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original PR for 9.x: #41469
This allows Laravel to throw a
DecryptException
(which is ignored by bug catching libraries like Sentry) instead of throwing an open_ssl exception ofopenssl_decrypt(): The tag cannot be used because the cipher algorithm does not support AEAD
when a tag is passed with a value but AEAD is not supported.This commonly seems to happen in malicious web scripts that modify the encrypted cookie values to insert exploitable tag values. The way Laravel works
tag
is never exploitable in this way. However it ends up causing a 500 error and additionally if you are using any error reporting engine you end up with thousands of issues a day withopenssl_decrypt(): The tag cannot be used because the cipher algorithm does not support AEAD
tag.One such example of a compromised cookie:
An easy way to exploit this yourself is to go to any Laravel 9 site. Copy out the base64 session cookie, modify the
tag
key to add any value and then re-encode the cookie. As long as the site does not support AEAD it will cause a 500 error.This simply throws a
DecryptException
if AEAD is not supported and a tag was still sent. ThrowingDecryptException
allows Laravel to function without 500ing and prevents bug catchers from reporting this.