Repository navigation
Reject a client id that isn't UTF-8 - #26
Merged
Merged
Conversation
PHP url-decodes cookie values, so a cookie holding %FF gives a client id with a byte that isn't UTF-8. The database rejects it, like a client id over 255 characters, and an application that writes the client id to its own tables fails the request. The cookie provider now treats such a cookie as no cookie, so the visitor gets a new client id and a new cookie.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
PHP url-decodes cookie values, so a
setono_client_idcookie holding%FFgives a client id with a byte that isn't UTF-8. The provider now treats it like an empty client id or one over 255 bytes (#20): as no cookie, so the visitor gets a new client id and a new cookie.The check is
preg_match('//u', …), so it needs noext-mbstring.Found by setono/sylius-conversion-attribution-plugin's architecture review. The plugin writes the client id to
varchar(255)and JSON columns at checkout, so a hand-edited cookie gives a 500 at checkout. The bundle's own metadataclientIdcolumn rejects these bytes too. The same rule goes into 2.x'sClientCookieJar::isValid()in a separate PR. This should be in v1.2.1 (the draft release targets1.x).Evidence
src/change stashed, the new tests fail:client-id-øis still accepted.Merge Danger
Door: two-way
Blast Radius: small
A visitor whose cookie holds a client id that isn't UTF-8 gets a new client id, and their metadata row (if any) is no longer found. Such a cookie can't come from the bundle, which issues UUIDs, and the database couldn't store such a row anyway.