# CVE-2026-21621: Improper Scope Enforcement in OAuth client\_credentials Flow Allows Read-Only API Key to Escalate to Full Access

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.0
- **CVSS:** 7.0 (v4.0, CNA) `CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:H/VA:L/SC:N/SI:H/SA:N`
- **CVSS metrics:** Attack vector: Network; Attack complexity: Low; Attack requirements: Present; Privileges required: Low; User interaction: None; Confidentiality impact: None; Integrity impact: High; Availability impact: Low; Confidentiality impact on other systems: None; Integrity impact on other systems: High; Availability impact on other systems: None
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, login needed
- **EPSS:** 0.47% (percentile 33, 2026-11-28)
- **CWE:** CWE-863
- **Published:** 2026-03-05T19:20:05.831Z
- **Modified:** 2026-11-20T04:17:10.800Z

## Who should check

- Anyone running hexpm \>= 2025-08-18, \< 2026-03-05
- Anyone running hexpm \>= 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b, \< 71c127afebb7ed7cc637eb231b98feb802d62999

## Description

Incorrect Authorization vulnerability in hexpm hexpm/hexpm (HexpmWeb.API.OAuthController module) allows Privilege Escalation.

An API key created with read-only permissions (domain: "api", resource: "read") can be escalated to full write access under specific conditions.

When exchanging a read-only API key via the OAuth client\_credentials grant, the resource qualifier is ignored. The resulting JWT receives the broad "api" scope instead of the expected "api:read" scope. This token is therefore treated as having full API access.

If an attacker is able to obtain a victim's read-only API key and a valid 2FA (TOTP) code for the victim account, they can use the incorrectly scoped JWT to create a new full-access API key with unrestricted API permissions that does not expire by default and can perform write operations such as publishing, retiring, or modifying packages.

This vulnerability is associated with program files lib/hexpm\_web/controllers/api/oauth\_controller.ex and program routines HexpmWeb.API.OAuthController.validate\_scopes\_against\_key/2.

This issue affects hex.pm: from 2025-08-18 before 2026-03-05; hexpm/hexpm: from 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b before 71c127afebb7ed7cc637eb231b98feb802d62999.

## Affected and fixed versions

- hexpm: \>= 2025-08-18, \< 2026-03-05 (cvelist)
- hexpm: \>= 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b, \< 71c127afebb7ed7cc637eb231b98feb802d62999 (cvelist)

## Mitigation

- Upgrade hexpm to 2026-03-05 or later.
- Upgrade hexpm to 71c127afebb7ed7cc637eb231b98feb802d62999 or later.
- Vendor workaround: \* Revoke and reissue exposed API keys immediately if compromise is suspected.
- \* Avoid relying on read-only API keys as a strict security boundary in high-risk environments.
- \* Closely monitor audit logs for unexpected API key creation events.
- \* Enforce strong 2FA hygiene and protect TOTP seeds carefully.
- 
- There is no complete mitigation without upgrading, as the issue exists in server-side scope validation logic.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2026-21621. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-21621.md
Affected: hexpm >= 2025-08-18, < 2026-03-05; hexpm >= 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b, < 71c127afebb7ed7cc637eb231b98feb802d62999
Fixed in: hexpm 2026-03-05, hexpm 71c127afebb7ed7cc637eb231b98feb802d62999

Steps:
1. Search this machine and project for hexpm: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2026-21621 being exploited?

There is no confirmed exploitation: CVE-2026-21621 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.47% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2026-21621?

High: CVSS 7.0 (v4.0, scored by CNA). Remote, login needed.

### Which versions are affected by CVE-2026-21621?

hexpm \>= 2025-08-18, \< 2026-03-05; hexpm \>= 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b, \< 71c127afebb7ed7cc637eb231b98feb802d62999.

### Is there a fix for CVE-2026-21621?

Yes. Fixed in hexpm 2026-03-05, hexpm 71c127afebb7ed7cc637eb231b98feb802d62999. Upgrade hexpm to 2026-03-05 or later. Upgrade hexpm to 71c127afebb7ed7cc637eb231b98feb802d62999 or later. Vendor workaround: \* Revoke and reissue exposed API keys immediately if compromise is suspected. \* Avoid relying on read-only API keys as a strict security boundary in high-risk environments. \* Closely monitor audit logs for unexpected API key creation events. \* Enforce strong 2FA hygiene and protect TOTP seeds carefully.  There is no complete mitigation without upgrading, as the issue exists in server-side scope validation logic.

### How do I check if I'm affected by CVE-2026-21621?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/hexpm/hexpm/security/advisories/GHSA-739m-8727-j6w3>
- patch: <https://github.com/hexpm/hexpm/commit/71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b>
- patch: <https://github.com/hexpm/hexpm/commit/71c127afebb7ed7cc637eb231b98feb802d62999>
- other: <https://cna.erlef.org/cves/CVE-2026-21621.html>
- other: <https://osv.dev/vulnerability/EEF-CVE-2026-21621>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2026-21621>

HTML: <https://flawdb.com/CVE-2026-21621> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-21621>
