GHSA-qvp4-rpmr-xwrr: Github.com/ory/oathkeeper Possible Bypass Of Token Claim Vulnerability

HIGH
CVSS 7.5
CWE-863
Published
Advisory Summary

GHSA-qvp4-rpmr-xwrr is a HIGH (CVSS 7.5) possible bypass of token claim vulnerability (CWE-863: Incorrect Authorization) affecting Github.com/ory/oathkeeper libraries in the Go ecosystem. The issue involves possible bypass of token claim validation when oauth2 introspection caching is enabled. Remediation is available by upgrading affected packages to version 0.38.12-beta.1.

GHSA-qvp4-rpmr-xwrr at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-qvp4-rpmr-xwrr
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-863: Incorrect Authorization
Affected Product Github.com/ory/oathkeeper
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.5

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

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

How to Fix GHSA-qvp4-rpmr-xwrr

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

github.com/ory/oathkeeper fixed: 0.38.12-beta.1
Upgrade github.com/ory/oathkeeper to 0.38.12-beta.1
Verify Direct and Transitive Dependencies

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

inspect dependencies for github.com/ory/oathkeeper

How to Check if You Are Affected

To determine whether your application is affected by GHSA-qvp4-rpmr-xwrr, inspect your project dependencies for Github.com/ory/oathkeeper:

inspect dependencies for github.com/ory/oathkeeper

Analyze the terminal output to locate any version of Github.com/ory/oathkeeper in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.38.12-beta.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-863: Incorrect Authorization, where the product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. In Github.com/ory/oathkeeper, 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

### Impact When you make a request to an endpoint that requires the scope `foo` using an access token granted with that `foo` scope, introspection will be valid and that token will be cached. The problem comes when a second requests to an endpoint that requires the scope `bar` is made before the cache has expired. Whether the token is granted or not to the `bar` scope, introspection will be valid. ### Patches A patch will be released with `v0.38.12-beta.1`. ### Workarounds Per default, caching is disabled for the `oauth2_introspection` authenticator. When caching is disabled, this vulnerability does not exist. ### Trace The cache is checked in [`func (a *AuthenticatorOAuth2Introspection) Authenticate(...)`](https://github.com/ory/oathkeeper/blob/6a31df1c3779425e05db1c2a381166b087cb29a4/pipeline/authn/authenticator_oauth2_introspection.go#L152). From [`tokenFromCache()`](https://github.com/ory/oathkeeper/blob/6a31df1c3779425e05db1c2a381166b087cb29a4/pipeline/authn/authenticator_oauth2_introspection.go#L97) it seems that it only validates the token expiration date, but ignores whether the token has or not the proper scopes. ### Post-Mortem The vulnerability was introduced in PR #424. During review, we failed to require appropriate test coverage by the submitter which is the primary reason that the vulnerability passed the review process. To avoid this from happening again we enabled codecov with a strict policy on the Ory Oathkeeper repository: Without an increase in code coverage the PR can not be merged. To address this issue and any regressions we have added a test suite ensuring that the cache behaviour is correct in the different scenarios: - Scope strategy is `none`, cache is enabled, and `requested_scope` is not empty -> cache will not be used; - Scope strategy is `none`, cache is enabled, and `requested_scope` is empty -> cache will be used; - Scope strategy is not `none`, cache is enabled, and `requested_scope` is not empty -> cache will be used; as well as validating if `iss`, `aud`, `exp`, `token_use`, and scope are validated. Additionally, we added [CodeQL scanning](https://github.com/ory/oathkeeper/commit/64ac7562669287d391cd72dfd43c5d71ff9f89a1) to the CI.

GHSA-qvp4-rpmr-xwrr Affected Github.com/ory/oathkeeper Versions

1 component(s)
Fixed Versions:
0.38.12-beta.1
Product / Package Ecosystem Affected Versions Fixed Version
github.com/ory/oathkeeper
Go
≥ 0.38.0-beta.2
< 0.38.12-beta.1
0.38.12-beta.1

References

Frequently Asked Questions

What is GHSA-qvp4-rpmr-xwrr?
GHSA-qvp4-rpmr-xwrr is a security vulnerability in Github.com/ory/oathkeeper involving Possible bypass of token claim validation when OAuth2 Introspection caching is enabled under CWE-863: Incorrect Authorization.
Which Github.com/ory/oathkeeper versions are affected?
Affected versions include releases prior to 0.38.12-beta.1 across affected packages: github.com/ory/oathkeeper.
What version fixes GHSA-qvp4-rpmr-xwrr?
Upgrading to 0.38.12-beta.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/ory/oathkeeper affected?
Yes, github.com/ory/oathkeeper is affected in releases prior to 0.38.12-beta.1. Upgrade your dependency to 0.38.12-beta.1 or later.
What is the CVSS score of GHSA-qvp4-rpmr-xwrr?
GHSA-qvp4-rpmr-xwrr has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with GHSA-qvp4-rpmr-xwrr?
GHSA-qvp4-rpmr-xwrr is classified under CWE-863: Incorrect Authorization (The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check.).
How can I check Go dependencies for GHSA-qvp4-rpmr-xwrr?
Run the dependency tree command: 'inspect dependencies for github.com/ory/oathkeeper'. 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-qvp4-rpmr-xwrr",
  "modified" : "2021-06-22T20:50:44Z",
  "published" : "2021-06-23T18:00:20Z",
  "aliases" : [ ],
  "summary" : "Possible bypass of token claim validation when OAuth2 Introspection caching is enabled",
  "details" : "### Impact\n\nWhen you make a request to an endpoint that requires the scope `foo` using an access token granted with that `foo` scope, introspection will be valid and that token will be cached. The problem comes when a second requests to an endpoint that requires the scope `bar` is made before the cache has expired. Whether the token is granted or not to the `bar` scope, introspection will be valid.\n\n### Patches\n\nA patch will be released with `v0.38.12-beta.1`.\n\n### Workarounds\n\nPer default, caching is disabled for the `oauth2_introspection` authenticator. When caching is disabled, this vulnerability does not exist.\n\n### Trace\n\nThe cache is checked in [`func (a *AuthenticatorOAuth2Introspection) Authenticate(...)`](https://github.com/ory/oathkeeper/blob/6a31df1c3779425e05db1c2a381166b087cb29a4/pipeline/authn/authenticator_oauth2_introspection.go#L152). From [`tokenFromCache()`](https://github.com/ory/oathkeeper/blob/6a31df1c3779425e05db1c2a381166b087cb29a4/pipeline/authn/authenticator_oauth2_introspection.go#L97) it seems that it only validates the token expiration date, but ignores whether the token has or not the proper scopes.\n\n### Post-Mortem\n\nThe vulnerability was introduced in PR #424. During review, we failed to require appropriate test coverage by the submitter which is the primary reason that the vulnerability passed the review process.\n\nTo avoid this from happening again we enabled codecov with a strict policy on the Ory Oathkeeper repository: Without an increase in code coverage the PR can not be merged.\n\nTo address this issue and any regressions we have added a test suite ensuring that the cache behaviour is correct in the different scenarios:\n\n- Scope strategy is `none`, cache is enabled, and `requested_scope` is not empty -> cache will not be used;\n- Scope strategy is `none`, cache is enabled, and `requested_scope` is empty -> cache will be used;\n- Scope strategy is not `none`, cache is enabled, and `requested_scope` is not empty -> cache will be used;\n\nas well as validating if `iss`, `aud`, `exp`, `token_use`, and scope are validated.\n\nAdditionally, we added [CodeQL scanning](https://github.com/ory/oathkeeper/commit/64ac7562669287d391cd72dfd43c5d71ff9f89a1) to the CI.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/ory/oathkeeper"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.38.0-beta.2"
      }, {
        "fixed" : "0.38.12-beta.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.38.11-beta.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ory/oathkeeper/security/advisories/GHSA-qvp4-rpmr-xwrr"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-863" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-06-22T20:50:44Z",
    "nvd_published_at" : null
  }
}