CVE-2026-21621 Details
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.
A privilege escalation vulnerability has been identified in Hexpm's OAuth implementation, specifically in the 'Elixir.HexpmWeb.API.OAuthController' module. This vulnerability arises from incorrect authorization handling, allowing an API key with read-only permissions (domain: 'api', resource: 'read') to be escalated to full write access under certain conditions. When a read-only API key is exchanged through the OAuth client_credentials grant, the resource qualifier is overlooked, resulting in a JSON Web Token (JWT) that carries the broad 'api' scope instead of the expected 'api:read' scope. Consequently, this token is treated as having full API access. An attacker who obtains a victim's read-only API key and a valid two-factor authentication (TOTP) code can exploit this vulnerability to create a new API key with unrestricted permissions, enabling write operations such as publishing or modifying packages.
Users should revoke and reissue any exposed API keys if compromise is suspected. After the vulnerability was identified, the scope validation logic was corrected to ensure that the resource field is properly respected. Instructions for updating to the patched version can be found in the Hexpm repository.
Metrics
CVSS 4.0 Severity and Vector Strings:
CVSS 3.x Severity and Vector Strings:
No data available for CVSS Version 2.0 on this CVE.
CISA-ADP
Assessed Mar 6, 2026References to Advisories, Solutions, and Tools
By selecting these links, you will be leaving this site. These are references gathered from the official CVE record and are not endorsed by Volerion.
Weakness Enumeration
| CWE-ID | CWE Name | Source |
|---|---|---|
| CWE-863 | Incorrect Authorization | EEF |
Affected Products
| Product | Versions |
|---|---|
| hex hexpm | >= 2025-10-17, < 2026-03-05 |
CPE
Remediation
| |
Change History
6 change records found show changes
| Date | Action | Recorded By |
|---|---|---|
| Nov 20, 2026 | CVE Modified | EEF |
| Jun 17, 2026 | CVE Modified | EEF |
| Jun 17, 2026 | CVE Modified | CISA-ADP |
| Apr 6, 2026 | CVE Modified | EEF |
| Mar 25, 2026 | Initial Analysis | [email protected] |
| Mar 5, 2026 | New CVE Received | EEF |