Skip to content

[Security] Randomize CSRF token to harden BREACH attacks #39919

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

Merged
merged 1 commit into from
Jan 23, 2021

Conversation

jderusse
Copy link
Member

@jderusse jderusse commented Jan 21, 2021

Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR TODO

This PR randomize the CSRF token in each request in order to hardening the BREACH attack

@jderusse jderusse changed the title Randomize response length to harden BREACH attacks Randomize CSRF token to harden BREACH attacks Jan 21, 2021
@carsonbot carsonbot changed the title Randomize CSRF token to harden BREACH attacks [Security] Randomize CSRF token to harden BREACH attacks Jan 21, 2021
@nicolas-grekas nicolas-grekas added this to the 5.x milestone Jan 21, 2021
@nicolas-grekas
Copy link
Member

(failure is related)

@jderusse jderusse force-pushed the sec-breach branch 4 times, most recently from e24c286 to cb16125 Compare January 21, 2021 14:37
@jderusse
Copy link
Member Author

last failed test is about tests in branch < 5.3 working with my patch and failed.
The test tries to generte 2 logout links (with CSRF token) and expect there are identical which is exactly what my PR prevent.

Once this PR merge, I've to fix the test in downstream branches

jderusse added a commit that referenced this pull request Jan 21, 2021
This PR was merged into the 4.4 branch.

Discussion
----------

[SecurityBundle] Remove wrong test

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This tests, asserts that all links to logout are identical, which is wrong and incompatible with BREACH mitigation #39919

Commits
-------

91c360e Remove wrong test
@jderusse
Copy link
Member Author

green \o/

@nicolas-grekas
Copy link
Member

Thank you @jderusse.

@liweiyi88
Copy link

Hi Team, sorry to add a post-merge comment but I am learning and curious about the implementation choice used in this PR.
I am not a security expert on encryption but I read that people mentioned XOR encryption is not that secure compared with AES related algorithm. I wonder if anyone could tell if it is more secure/better to achieve encryption by using openssl related method like what has been implemented in Laravel Encryption?

@jderusse
Copy link
Member Author

jderusse commented May 17, 2021

BREACH attack is all about guessing a secret the content of an encrypted page by comparing the size of a compressed page.

There is nothing secret here (as an evidence: the KEY used to XOR is included in the payload).
We only need to generate random content

@stof
Copy link
Member

stof commented May 17, 2021

To be clear, this PR does not even implement encryption at all (so there is no question about whether the encryption is secure or no)

@liweiyi88
Copy link

Cool, thanks for the explainations!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants