This long-read blog post aims to shed light on a recent vulnerability, identified by the Common Vulnerabilities and Exposures ID CVE-2022-31690, in the Spring Security framework. The exploit is specific to the OAuth2 access token response function and could lead to privilege escalation under particular conditions. We will provide details on the vulnerable versions, a code snippet to understand the issue, links to original references, and important information about the exploit itself.

Vulnerable Versions

The vulnerability affects Spring Security versions 5.7 prior to 5.7.5, 5.6 prior to 5.6.9, and older unsupported versions. Users of these versions are recommended to update to the latest versions or patch their applications as soon as possible to mitigate the risk of exploitation.

Exploit Details

A malicious user or attacker can exploit the vulnerability by altering a request initiated by the client (via the browser) to the Authorization Server. The attacker targets the scenario where the Authorization Server responds with an OAuth2 Access Token Response containing an empty scope list (per RFC 6749, Section 5.1) when a subsequent request to the token endpoint is made to obtain the access token. This process can lead to a privilege escalation on the approval that follows, allowing the attacker to gain unauthorized access to sensitive information.

Code Snippet

To better understand the issue, here is a code snippet that demonstrates the vulnerable pattern in Spring Security:

// Initiate an OAuth2 Access Token Request
OAuth2AccessTokenRequest tokenRequest = new OAuth2AccessTokenRequest(clientId, scope, ..);

// Malicious user modifies the 'scope' here
scope = null; // As per the request manipulation, the scope becomes empty/null

// Authorization Server responds with an OAuth2 Access Token Response with an empty scope list (RFC 6749, Section 5.1)
OAuth2AccessTokenResponse tokenResponse = new OAuth2AccessTokenResponse(token, tokenType, null, expiresIn, refreshToken);

// Privilege Escalation occurs here due to the empty 'scope' in the token response

This snippet demonstrates how the use of an empty scope list can unintentionally give way to a privilege escalation vulnerability in the authentication process.

Original References

The Spring Security team acknowledged this vulnerability and released an advisory providing details about the affected versions and mitigation recommendations. Users are encouraged to consult the original advisory here to understand the scope of the issue and apply any necessary updates to their projects.

In addition, the official RFC document for OAuth2 (RFC 6749) can be accessed here for an in-depth understanding of the OAuth2 Access Token Response.


CVE-2022-31690 is a significant security vulnerability in Spring Security that could lead to privilege escalation. Users of the affected versions should update their applications promptly or apply security patches to protect their projects against potential exploitation.

By understanding the specifics of the exploit, developers can be better equipped to identify and mitigate similar vulnerabilities in the future, thus enhancing the overall security of their applications.


Published on: 10/31/2022 20:15:00 UTC
Last modified on: 08/08/2023 14:22:00 UTC