CVE-2021-32701: Github.com/ory/oathkeeper Incorrect Authorization Vulnerability

HIGH
Advisory Identifier: GHSA-vfvf-6gx5-mqv6
CVSS 7.5
CWE-863
Published
Advisory Summary

CVE-2021-32701 is a HIGH (CVSS 7.5) incorrect authorization vulnerability (CWE-863: Incorrect Authorization) affecting Github.com/ory/oathkeeper libraries in the Go ecosystem. The issue involves incorrect authorization in ory oathkeeper. Remediation is available by upgrading affected packages to version 0.38.12-beta.1.

CVE-2021-32701 at a Glance

CVE Identifier CVE-2021-32701
GHSA Identifier GHSA-vfvf-6gx5-mqv6
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 CVE-2021-32701

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 CVE-2021-32701, 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

ORY Oathkeeper is an Identity & Access Proxy (IAP) and Access Control Decision API that authorizes HTTP requests based on sets of Access Rules. 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. A patch will be released with `v0.38.12-beta.1`. Per default, caching is disabled for the `oauth2_introspection` authenticator. When caching is disabled, this vulnerability does not exist. 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. 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.

CVE-2021-32701 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 CVE-2021-32701?
CVE-2021-32701 is a security vulnerability in Github.com/ory/oathkeeper involving Incorrect Authorization in ORY Oathkeeper 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 CVE-2021-32701?
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 CVE-2021-32701?
CVE-2021-32701 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 CVE-2021-32701?
CVE-2021-32701 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 CVE-2021-32701?
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-vfvf-6gx5-mqv6",
  "modified" : "2021-06-23T20:38:29Z",
  "published" : "2021-06-24T20:16:02Z",
  "aliases" : [ "CVE-2021-32701" ],
  "summary" : "Incorrect Authorization in ORY Oathkeeper",
  "details" : "ORY Oathkeeper is an Identity & Access Proxy (IAP) and Access Control Decision API that authorizes HTTP requests based on sets of Access Rules. 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. A patch will be released with `v0.38.12-beta.1`. Per default, caching is disabled for the `oauth2_introspection` authenticator. When caching is disabled, this vulnerability does not exist. 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. 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.",
  "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"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32701"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ory/oathkeeper/pull/424"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ory/oathkeeper/commit/1f9f625c1a49e134ae2299ee95b8cf158feec932"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-863" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-06-23T20:38:29Z",
    "nvd_published_at" : "2021-06-22T20:15:00Z"
  }
}