Vulnerabilities in pkg:maven/com.google.oauth-client/google-oauth-client

PACKAGE
Advisory Identifier: GHSA-hw42-3568-wj87
Advisory Summary

CVE-2021-22573 is a HIGH (CVSS 7.3) google-oauth-java-client improperly verifies cryptographic signature vulnerability (CWE-347: Improper Verification of Cryptographic Signature) affecting Google oauth client libraries in the Maven ecosystem. The issue involves google-oauth-java-client improperly verifies cryptographic signature. Remediation is available by upgrading affected packages to version 1.33.3.

3 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:maven/com.google.oauth-client/google-oauth-client

3 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:maven/com.google.oauth-client/google-oauth-client. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-hw42-3568-wj87 CVE-2021-22573 HIGH google-oauth-java-client improperly verifies cryptographic signature
GHSA-xh97-72ww-2w58 - HIGH Duplicate Advisory: Improper Verification of Cryptographic Signature in google-oauth-java-client
GHSA-f263-c949-w85g CVE-2020-7692 HIGH Improper Authorization in Google OAuth Client

CVE-2021-22573 at a Glance

CVE Identifier CVE-2021-22573
GHSA Identifier GHSA-hw42-3568-wj87
Severity HIGH
CVSS v3.1 Base Score 7.3
CWE Classification CWE-347: Improper Verification of Cryptographic Signature
Affected Product Google oauth client
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 7.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2021-22573

To remediate this vulnerability, upgrade all affected Google oauth client dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

com.google.oauth-client:google-oauth-client fixed: 1.33.3
<dependency>
    <groupId>com.google.oauth-client</groupId>
    <artifactId>google-oauth-client</artifactId>
    <version>1.33.3</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=com.google.oauth-client

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2021-22573, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=com.google.oauth-client

Analyze the terminal output to locate any version of Google oauth client in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.33.3), your application is affected.

Note: The mvn dependency:tree -Dincludes=com.google.oauth-client command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-347: Improper Verification of Cryptographic Signature, where the product does not verify, or incorrectly verifies, the cryptographic signature for data. In Google oauth client, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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

CVE-2021-22573 Affected Google oauth client Versions

1 component(s)
Fixed Versions:
1.33.3
Product / Package Ecosystem Affected Versions Fixed Version
com.google.oauth-client:google-oauth-client
Maven
≥ 1.16.0-rc
< 1.33.3
1.33.3

References

Frequently Asked Questions

What is CVE-2021-22573?
CVE-2021-22573 is a security vulnerability in Google oauth client involving google-oauth-java-client improperly verifies cryptographic signature under CWE-347: Improper Verification of Cryptographic Signature.
Which Google oauth client versions are affected?
Affected versions include releases prior to 1.33.3 across affected packages: com.google.oauth-client:google-oauth-client.
What version fixes CVE-2021-22573?
Upgrading to 1.33.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is google-oauth-client affected?
Yes, com.google.oauth-client:google-oauth-client is affected in releases prior to 1.33.3. Upgrade your dependency to 1.33.3 or later.
What is the CVSS score of CVE-2021-22573?
CVE-2021-22573 has a CVSS v3.1 base score of 7.3 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2021-22573?
CVE-2021-22573 is classified under CWE-347: Improper Verification of Cryptographic Signature (The product does not verify, or incorrectly verifies, the cryptographic signature for data.).
How can I check Maven dependencies for CVE-2021-22573?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.google.oauth-client'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hw42-3568-wj87",
  "modified" : "2024-04-09T15:11:24Z",
  "published" : "2024-04-09T15:11:24Z",
  "aliases" : [ "CVE-2021-22573" ],
  "summary" : "google-oauth-java-client improperly verifies cryptographic signature",
  "details" : "### Summary\nThe 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.\n\nAn 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. \n\nIf 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. \n\nReporter: [Tamjid al Rahat](https://github.com/tamjidrahat), contributor\n\n### Patches\nThe issue was fixed in the 1.33.3 version of the library\n\n### Proof of Concept\nTo 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.\n\n```\n  /** A default http transport factory for testing */\n  static class DefaultHttpTransportFactory implements HttpTransportFactory {\n    public HttpTransport create() {\n      return new NetHttpTransport();\n    }\n  }\n\n// The below token has some modified bits in the signature\n private static final String SERVICE_ACCOUNT_RS256_TOKEN_BAD_SIGNATURE =    \n\"eyJhbGciOiJSUzI1NiIsImtpZCI6IjJlZjc3YjM4YTFiMDM3MDQ4NzA0MzkxNmFjYmYyN2Q3NG\" +\n\"VkZDA4YjEiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL2V4YW1wbGUuY29tL2F1ZGllbm\" +\n\"NlIiwiZXhwIjoxNTg3NjMwNTQzLCJpYXQiOjE1ODc2MjY5NDMsImlzcyI6InNvbWUgaXNzdWVy\" +\n\"Iiwic3ViIjoic29tZSBzdWJqZWN0In0.gGOQW0qQgs4jGUmCsgRV83RqsJLaEy89-ZOG6p1u0Y26\" +\n\"FyY06b6Odgd7xXLsSTiiSnch62dl0Lfi9D0x2ByxvsGOCbovmBl2ZZ0zHr1wpc4N0XS9lMUq5RJ\" + \n\"QbonDibxXG4nC2zroDfvD0h7i-L8KMXeJb9pYwW7LkmrM_YwYfJnWnZ4bpcsDjojmPeUBlACg7tjjOgBFby\" +\n\"QZvUtaERJwSRlaWibvNjof7eCVfZChE0PwBpZc_cGqSqKXv544L4ttqdCnm0NjqrTATXwC4gYx\" + \n\"ruevkjHfYI5ojcQmXoWDJJ0-_jzfyPE4MFFdCFgzLgnfIOwe5ve0MtquKuv2O0pgvg\";\n\nIdTokenVerifier tokenVerifier =\n        new IdTokenVerifier.Builder()\n            .setClock(clock)\n            .setCertificatesLocation(\"https://www.googleapis.com/robot/v1/metadata/x509/integration-tests%40chingor-test.iam.gserviceaccount.com\")\n            .setHttpTransportFactory(new DefaultHttpTransportFactory())\n            .build();\n\n// verification will return true despite modified signature for versions <1.33.3\ntokenVerifier.verify(IdToken.parse(GsonFactory.getDefaultInstance(), SERVICE_ACCOUNT_RS256_TOKEN_BAD_SIGNATURE));\n\n```\n\n### Remediation and Mitigation\nUpdate to the version 1.33.3 or higher \n\nIf 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: \n[google-auth-library-java](https://github.com/googleapis/google-auth-library-java/blob/main/oauth2_http/java/com/google/auth/oauth2/TokenVerifier.java)\n[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)\n\n### Timeline\nDate reported: 12 Dec 2021\nDate fixed: 13 Apr 2022\nDate disclosed: 2 May 2022\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in the [google-oauth-java-client](https://github.com/googleapis/google-oauth-java-client) repo",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.google.oauth-client:google-oauth-client"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.16.0-rc"
      }, {
        "fixed" : "1.33.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/googleapis/google-oauth-java-client/security/advisories/GHSA-hw42-3568-wj87"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-22573"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/googleapis/google-oauth-java-client/pull/872"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/googleapis/google-oauth-java-client/commit/c634ad4e31cac322bb1aa8a9feb0569749011bf0"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/googleapis/google-oauth-java-client"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-347" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-09T15:11:24Z",
    "nvd_published_at" : null
  }
}