Spring Security Advisories

CVE-2021-22112: Changing SecurityContext More Than Once in Single Request Can Fail to Save

LOW | FEBRUARY 19, 2021 | CVE-2021-22112


Spring Security versions 5.4.0 to 5.4.3, 5.3.0.RELEASE to 5.3.8.RELEASE, 5.2.0.RELEASE to 5.2.8.RELEASE, and older unsupported versions can fail to save the SecurityContext if it is changed more than once in a single request. The SecurityContext can fail to save to the HttpSession if a developer changes the SecurityContext twice in a single request when both of the following conditions are met: First the developer must change the SecurityContext before the HttpResponse is committed and then the HttpResponse must be committed before the SecurityContextPersistenceFilter completes. Then the developer must attempt to change the SecurityContext again before the SecurityContextPersistenceFilter completes. A malicious user cannot cause the bug to happen (it must be programmed in). However, if the application's intent is to only allow the user to run with elevated privileges in a small portion of the application, the bug can be leveraged to extend those privileges to the rest of the application.

Affected Spring Products and Versions

  • Spring Security
    • 5.4.0 to 5.4.3
    • 5.3.0.RELEASE to 5.3.8.RELEASE
    • 5.2.0.RELEASE to 5.2.8.RELEASE


Users of affected versions should apply the following mitigation: 5.4.x users should upgrade to 5.4.4, 5.3.x users should upgrade to 5.3.9.RELEASE, 5.2.x users should upgrade to 5.2.9.RELEASE. Older versions should upgrade to a supported branch. There are no other mitigation steps necessary. Releases that have fixed this issue include:

  • Spring Security
    • 5.4.4
    • 5.3.9.RELEASE
    • 5.2.9.RELEASE


This issue was discovered and responsibly reported by Daniel Beck, Jeff Thompson, Jesse Glick, and Wadeck Follonier, CloudBees, Inc.


  • 2021-02-19: Corrected Fixed Versions
  • 2021-02-19: Initial vulnerability report published.

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all

© 2023 VMware, Inc. or its affiliates. Terms of Use PrivacyTrademark Guidelines Your California Privacy Rights Cookie Settings

Apache®, Apache Tomcat®, Apache Kafka®, Apache Cassandra™, and Apache Geode™ are trademarks or registered trademarks of the Apache Software Foundation in the United States and/or other countries. Java™, Java™ SE, Java™ EE, and OpenJDK™ are trademarks of Oracle and/or its affiliates. Kubernetes® is a registered trademark of the Linux Foundation in the United States and other countries. Linux® is the registered trademark of Linus Torvalds in the United States and other countries. Windows® and Microsoft® Azure are registered trademarks of Microsoft Corporation. “AWS” and “Amazon Web Services” are trademarks or registered trademarks of Amazon.com Inc. or its affiliates. All other trademarks and copyrights are property of their respective owners and are only mentioned for informative purposes. Other names may be trademarks of their respective owners.