# CVE-2021-32701: Possible bypass of token claim validation when OAuth2 Introspection caching is enabled

> Attackers can bypass scope validation in ORY Oathkeeper when OAuth2 introspection caching is enabled, gaining unauthorized access to protected endpoints.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 22 Jun 2021
- **Updated:** 3 Aug 2024
- **Also known as:** GHSA-qvp4-rpmr-xwrr, GHSA-vfvf-6gx5-mqv6, GO-2022-0406, GO-2022-0920

## What is CVE-2021-32701?

CVE-2021-32701 is a high-severity authentication bypass vulnerability in ory oathkeeper, published on 22 Jun 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

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.

Weakness: CWE-863 (Incorrect Authorization)

## Which versions are affected by CVE-2021-32701?

6 open source packages ship an affected version, including github.com/ory/oathkeeper. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/ory/oathkeeper` | Go | From 0.38.0-beta.2 | 0.38.12-beta.1 |
| `github.com/ory/oathkeeper` | Go | From 0.38.0-beta.2 | 0.38.12-beta.1 |
| `github.com/ory/oathkeeper` | Go | From 0.38.0-beta.2 | 0.38.12-beta.1 |
| `github.com/ory/oathkeeper` | Go | From 0.38.0-beta.2 | 0.38.12-beta.1 |
| `github.com/ory/oathkeeper` | Go | From 0.38.0-beta.2 | 0.38.12-beta.1 |
| `github.com/ory/oathkeeper` | Go | From 0.38.0-beta.2 | 0.38.12-beta.1 |

Products: Ory Oathkeeper.

## How do I fix CVE-2021-32701?

Upgrade github.com/ory/oathkeeper to 0.38.12-beta.1 or later.

## Is CVE-2021-32701 being exploited?

There is no known exploitation of CVE-2021-32701 in the wild and no public exploit code.

## Other vulnerabilities in ory oathkeeper

- [CVE-2026-33494](https://insights.sbomify.com/CVE-2026-33494/): Ory Oathkeeper has a path traversal authorization bypass (critical 10.0)
- [CVE-2026-33496](https://insights.sbomify.com/CVE-2026-33496/): Ory Oathkeeper has an authentication bypass by cache key confusion (high 8.1)
- [CVE-2026-33495](https://insights.sbomify.com/CVE-2026-33495/): Ory Oathkeeper has an authentication bypass by usage of untrusted header (medium 6.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-32701 and fix it if it is affected.

What it is: CVE-2021-32701 is a high-severity authentication bypass vulnerability in ory oathkeeper, published on 22 Jun 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-32701 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/ory/oathkeeper (Go): affected from 0.38.0-beta.2; fixed in 0.38.12-beta.1
- github.com/ory/oathkeeper (Go): affected from 0.38.0-beta.2; fixed in 0.38.12-beta.1
- github.com/ory/oathkeeper (Go): affected from 0.38.0-beta.2; fixed in 0.38.12-beta.1
- github.com/ory/oathkeeper (Go): affected from 0.38.0-beta.2; fixed in 0.38.12-beta.1
- github.com/ory/oathkeeper (Go): affected from 0.38.0-beta.2; fixed in 0.38.12-beta.1
- github.com/ory/oathkeeper (Go): affected from 0.38.0-beta.2; fixed in 0.38.12-beta.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-32701/ (Markdown: https://insights.sbomify.com/CVE-2021-32701/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-32701
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-32701
- OSV: https://osv.dev/vulnerability/CVE-2021-32701

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-32701/
Summaries are generated and may contain mistakes; the official description above is the record.
