CVE-2026-21621
Received Received - Intake
Incorrect Authorization in Hexpm OAuthController Enables Privilege Escalation

Publication date: 2026-03-05

Last updated on: 2026-04-06

Assigner: EEF

Description
Incorrect Authorization vulnerability in hexpm hexpm/hexpm ('Elixir.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 'Elixir.HexpmWeb.API.OAuthController':validate_scopes_against_key/2. This issue affects hexpm: from 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b before 71c127afebb7ed7cc637eb231b98feb802d62999.
CVSS Scores
EPSS Scores
Probability:
Percentile:
Meta Information
Published
2026-03-05
Last Modified
2026-04-06
Generated
2026-05-06
AI Q&A
2026-03-05
EPSS Evaluated
2026-05-05
NVD
EUVD
Affected Vendors & Products
Showing 1 associated CPE
Vendor Product Version / Range
hex hexpm From 2025-10-17 (inc) to 2026-03-05 (exc)
Helpful Resources
Exploitability
CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-863 The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check.
Attack-Flow Graph
AI Powered Q&A
Can you explain this vulnerability to me?

[{'type': 'paragraph', 'content': 'CVE-2026-21621 is an Incorrect Authorization vulnerability in the hexpm package manager\'s OAuth client_credentials flow. It occurs because the system improperly ignores the resource qualifier when exchanging a read-only API key, causing the issued JWT token to have a broad "api" scope instead of the restricted "api:read" scope.'}, {'type': 'paragraph', 'content': "This means that an API key created with read-only permissions can be escalated to full write access under specific conditions. If an attacker obtains a victim's read-only API key and a valid two-factor authentication (2FA) TOTP code, they can use the improperly scoped JWT to create a new full-access API key with unrestricted permissions that does not expire by default."}, {'type': 'paragraph', 'content': 'The vulnerability was caused by the function `validate_scopes_against_key/2` ignoring the resource field within the "api" domain, always allowing the broad "api" scope regardless of the key\'s restrictions. The fix involved properly validating scopes against the key\'s permissions to prevent privilege escalation.'}] [1, 2]


How can this vulnerability impact me? :

[{'type': 'paragraph', 'content': "This vulnerability can lead to privilege escalation from read-only API access to full write access. An attacker who obtains a victim's read-only API key and valid 2FA code can create a new API key with unrestricted permissions."}, {'type': 'list_item', 'content': 'The attacker can perform write operations such as publishing, retiring, or modifying packages.'}, {'type': 'list_item', 'content': 'The new API key created does not expire by default, allowing persistent unauthorized access.'}, {'type': 'paragraph', 'content': 'This can compromise the integrity of the package repository and potentially disrupt software supply chains relying on hexpm.'}] [1, 2]


How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:

I don't know


How can this vulnerability be detected on my network or system? Can you suggest some commands?

[{'type': 'paragraph', 'content': 'Detection of this vulnerability involves monitoring for unusual API key usage and creation patterns, especially the creation of new full-access API keys from read-only API keys.'}, {'type': 'paragraph', 'content': 'Specifically, you should audit logs for any unexpected API key creation events that grant unrestricted permissions, which may indicate exploitation of the OAuth client_credentials scope escalation.'}, {'type': 'paragraph', 'content': 'Commands or methods to detect this might include:'}, {'type': 'list_item', 'content': 'Review API key creation logs for new keys with full write permissions that were generated recently.'}, {'type': 'list_item', 'content': 'Check OAuth token issuance logs to identify tokens issued with broad "api" scope when only "api:read" scope was expected.'}, {'type': 'list_item', 'content': 'Use system or application log search commands such as `grep` or `jq` on JSON logs to filter for suspicious API key or token creation events.'}, {'type': 'list_item', 'content': 'Example command to search logs for API key creation events with full access (assuming JSON logs): `jq \'.event == "api_key_created" and .permissions == "api"\' /var/log/hexpm.log`'}, {'type': 'list_item', 'content': 'Monitor for usage of read-only API keys that suddenly perform write operations, which can be detected by analyzing API request logs.'}] [2]


What immediate steps should I take to mitigate this vulnerability?

Immediate mitigation steps include revoking and reissuing any exposed API keys, especially those with read-only permissions that might have been escalated.

Avoid relying on read-only API keys as strict security boundaries until the vulnerability is fully patched.

Monitor audit logs closely for unexpected API key creation or usage patterns that could indicate exploitation.

Enforce strong two-factor authentication (2FA) hygiene to reduce the risk of attackers obtaining valid 2FA codes.

Ultimately, apply the official patch that fixes the scope validation logic in the OAuth client_credentials flow to fully resolve the issue.


Ask Our AI Assistant
Need more information? Ask your question to get an AI reply (Powered by our expertise)
0/70
EPSS Chart