Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel] Use xxh128 algorithm instead of sha256 for http cache store key#47094

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.2frompascalwoerde:xxh-cache-key
Aug 14, 2022

Conversation

@pascalwoerde
Copy link
Contributor

QA
Branch?6.2
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#46893
LicenseMIT

Use xxh3 algorithm instead of sha256 for http cache store key. PR as requested in#46893

  • Note that the xxHash support is available since PHP 8.1 as noted in thechange log.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@nicolas-grekas
Copy link
Member

Thanks for the PR, that's always the best way to start a conversation on this repo :)

Now that I double checked xxh3, it's not cryptographically secure, isn't it? Since we're using this hash as the key to the cached response payload, this means we could open the storage to hash collisions attacks, provided the hacker can somehow control the response content. WDYT? Doesn't this disqualify xxh3 for this use case?

@pascalwoerde
Copy link
ContributorAuthor

That's right the whole xxh family isn't cryptographically secure, so it's easier for someone to recalculate a potential collision. I don't think that a hacker can have any benefit from this, since it is a oneway direction to retrieve data. xxh is great for change detection, which is ideal for this situation IMO. While I'm typing the only thing that I can imaging now is a collision by the number of responses, because xxh3 is 64 bit. Which means that when there are over a bilion of responses cached there will be a small change resulting in identical hash. I will suggest to use the xxh128 instead to extend the range.

@GromNaN
Copy link
Member

This is a great performance optimization. I shared some references ontwigphp/Twig#3588.

Regarding security: the hashed contents comes from an external input. An attacker could manipulate the query string so that the hash of a request URI would colite with an other. This is a cache poisoning attack: you could make the content of the pagehttps://connect.symfony.com/profile/pascalwoerde appear under the URIhttps://connect.symfony.com/profile/fabpot. I don't have the skills to do so, but we have to trust the experts that flagged this algorithm as non-cryptographically safe.

@alexislefebvre
Copy link
Contributor

Regarding security: the hashed contents comes from an external input. An attacker could manipulate the query string so that the hash of a request URI would colite with an other.

In this PR, the hash is not on the URL but on$response->getContent(), so an attacker would have to alter the content of the resulting HTML?

@GromNaN
Copy link
Member

Oh exact. So at most the attacker could update a page without invalidate the cache. That seems safe.

@pascalwoerdepascalwoerdeforce-pushed thexxh-cache-key branch 2 times, most recently from12fa328 to4ed78baCompareAugust 6, 2022 09:24
@pascalwoerdepascalwoerde changed the title[HttpKernel] Use xxh3 algorithm instead of sha256 for http cache store key[HttpKernel] Use xxh128 algorithm instead of sha256 for http cache store keyAug 6, 2022
@fabpot
Copy link
Member

Note that this change invalidates all the cached items when upgrading to 6.2.

dkarlovi and goetas reacted with thumbs up emoji

@fabpot
Copy link
Member

Thank you@pascalwoerde.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

[HttpKernel] HttpCache Store cache key algorithm speed improvement

6 participants

@pascalwoerde@carsonbot@nicolas-grekas@GromNaN@alexislefebvre@fabpot

[8]ページ先頭

©2009-2025 Movatter.jp