Skip to content

CSRF tokens are vulnerable to a BREACH attack #4001

Closed

Description

@johnraycp

Summary

The CSRF tokens generated by Spring are vulnerable to a BREACH attack. More details at http://breachattack.com/

I'll create a pull request with a proposed code change to fix this.

Actual Behavior

Spring always returns the same CSRF token to the browser.

Expected Behavior

The simplest way to mitigate this would be to return a token which is composed of a random per secret request XORed with an internal CSRF token. This effectively means that the browser receives a new CSRF token with each request.

Configuration

This only occurs when you turn on CSRF protection in Spring and also have HTTP compression enabled somewhere in your web server stack.

Version

Currently exists in latest version in Git.

Sample

N/A

Activity

  1. self-assigned this
    on Aug 29, 2016
  2. added this to the 5.0.0.M1 milestone on Sep 2, 2016
  3. jgrandja commented on Sep 2, 2016

    @jgrandja
    Collaborator

    The proposed solution will be to introduce a default method to CsrfToken, as follows:

    public interface CsrfToken {
        …
        default boolean matches(CsrfToken token) {
            return getToken().equals(token.getToken());
        }
    }
    

    Then override the default method in DefaultCsrfToken to handle the XOR logic.

    Targeted for 5.0 RELEASE which will support Java 8.

  4. removed their assignment
    on Sep 2, 2016
  5. modified the milestones: 5.0.0.M2, 5.0.0.M1 on May 9, 2017
  6. modified the milestones: 5.0.0.M2, 5.0.0.M3 on Jun 15, 2017
  7. modified the milestones: 5.0.0.M3, 5.0.0.M4 on Jul 24, 2017
  8. 38 remaining items

  9. modified the milestones: 5.8.x, 5.8.0-RC1 on Oct 4, 2022
  10. added a commit that references this issue on Oct 5, 2022
    dce1c30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webAn issue in web modules (web, webmvc)type: enhancementA general enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions