7.0high
Improper Scope Enforcement in OAuth client_credentials Flow Allows Read-Only API Key to Escalate to Full Access
- Severity
- 7.0high CVSS:4.0 by EEF
- Exploit likelihood
- 0.39% (higher than 35% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- EEF
- Also known as
- EEF-CVE-2026-21621GHSA-739m-8727-j6w3
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
| Product or package | Versions | Reported by |
|---|---|---|
| hex.pm | from 2025-08-18 before 2026-03-05 | CVE List |
| hexpm/hexpm | from 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b before 71c127afebb7ed7cc637eb231b98feb802d62999 | CVE List |
| https://github.com/hexpm/hexpm | from 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b before 71c127afebb7ed7cc637eb231b98feb802d62999 | Erlang Ecosystem Foundation |
| hex hexpm | from 2025-10-17 before 2026-03-05 | NVD |
All scores
| EEF | 7.0high CVSS:4.0 | 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 |
| Erlang Ecosystem Foundation | Not scored CVSS:4.0 | 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 |
| NVD | 5.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
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.
Erlang Ecosystem Foundation
Summary
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.
Workarounds
- 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.
NVD (es)
Vulnerabilidad de autorización incorrecta en hexpm hexpm/hexpm (módulo 'Elixir.HexpmWeb.API.OAuthController') permite la escalada de privilegios. Una clave API creada con permisos de solo lectura (dominio: "api", recurso: "read") puede ser escalada a acceso completo de escritura bajo condiciones específicas. Al intercambiar una clave API de solo lectura a través de la concesión OAuth client_credentials, el calificador de recurso es ignorado. El JWT resultante recibe el ámbito amplio "api" en lugar del ámbito esperado "api:read". Este token es, por lo tanto, tratado como si tuviera acceso completo a la API. Si un atacante es capaz de obtener una clave API de solo lectura de una víctima y un código 2FA (TOTP) válido para la cuenta de la víctima, pueden usar el JWT con ámbito incorrecto para crear una nueva clave API de acceso completo con permisos de API ilimitados que no expira por defecto y puede realizar operaciones de escritura como publicar, retirar o modificar paquetes. Esta vulnerabilidad está asociada con los archivos de programa lib/hexpm_web/controllers/api/oauth_controller.ex y las rutinas de programa 'Elixir.HexpmWeb.API.OAuthController':validate_scopes_against_key/2. Este problema afecta a hexpm: desde 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b antes de 71c127afebb7ed7cc637eb231b98feb802d62999.
References
| https://github.com/hexpm/hexpm/security/advisories/GHSA-739m-8727-j6w3 | advisory, mitigation, related, vendor-advisory | |
| https://cna.erlef.org/cves/CVE-2026-21621.html | related, web | |
| https://osv.dev/vulnerability/EEF-CVE-2026-21621 | related | |
| https://github.com/hexpm/hexpm/commit/71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b | related, web | |
| https://github.com/hexpm/hexpm/commit/71c127afebb7ed7cc637eb231b98feb802d62999 | fix, patch | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-21621 changed 2026-11-20 | CVE Terms of Use |
| Erlang Ecosystem Foundation | EEF-CVE-2026-21621 changed 2026-11-25 | CC-BY-4.0 |
| NVD | CVE-2026-21621 changed 2026-11-20 | Public domain |