CVE-2026-21621
Improper Scope Enforcement in OAuth client_credentials Flow Allows Read-Only API Key to Escalate to Full Access
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.
Who should check
- Anyone running hexpm >= 2025-08-18, < 2026-03-05
- Anyone running hexpm >= 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b, < 71c127afebb7ed7cc637eb231b98feb802d62999
Vulnerability facts
- Affected
- hexpm >= 2025-08-18, < 2026-03-05; hexpm >= 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b, < 71c127afebb7ed7cc637eb231b98feb802d62999
- Fixed in
- hexpm 2026-03-05, hexpm 71c127afebb7ed7cc637eb231b98feb802d62999
- Exploited in the wild
- Not in CISA KEV
- Public exploit / PoC
- None known
- Remote exploitation
- Remote, login needed
- 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:NOpen in CVSS calculator
Show all 11 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
- EPSS
- 0.47% chance of exploitation in 30 days (percentile 33, 2026-11-26)
- CWE
- CWE-863
- Modified
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
Check your systems with an agent
Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.
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.
References
Patches
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-26).
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.