Skip to content
Heist/ feed
Back to feed
High

Improper Scope Enforcement in OAuth client_credentials Flow Allows Read-Only API Key to Escalate to Full Access

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2026-21621
Confirmed fixed CVEs
Not specified
Updated in this feed
3 Nov 2026, 04:17 UTC · Revision 1

Source evidence

Improper Scope Enforcement in OAuth client_credentials Flow Allows Read-Only API Key to Escalate to Full Access

core-osv · Original source

Published 5 Mar 2026, 19:20 UTC

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.

osv:CVE-2026-21621
Complete source record
{
  "id": "a26f4bf27c3f0ecc3249ef2113f61768d1887249fe90e40b339e9182c2ec700b",
  "url": "https://osv.dev/vulnerability/CVE-2026-21621",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Improper Scope Enforcement in OAuth client_credentials Flow Allows Read-Only API Key to Escalate to Full Access",
    "summary": "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.",
    "evidence": "osv:CVE-2026-21621",
    "products": [],
    "severity": "high",
    "structured": {
      "id": "CVE-2026-21621",
      "aliases": [
        "CVE-2026-21621",
        "EEF-CVE-2026-21621",
        "GHSA-739m-8727-j6w3"
      ],
      "metrics": [
        {
          "type": "CVSS_V4",
          "score": "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"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/hexpm/hexpm",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "71c127afebb7ed7cc637eb231b98feb802d62999"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "range": [
                      {
                        "fixed": "71c127afebb7ed7cc637eb231b98feb802d62999"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            },
            {
              "repo": "https://github.com/hexpm/hexpm.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b"
                },
                {
                  "fixed": "71c127afebb7ed7cc637eb231b98feb802d62999"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "range": [
                      {
                        "introduced": "71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b"
                      },
                      {
                        "fixed": "71c127afebb7ed7cc637eb231b98feb802d62999"
                      }
                    ],
                    "source": "AFFECTED_FIELD",
                    "strategy": "StandardRange"
                  }
                ]
              }
            }
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-21621.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:25.669210692Z",
      "provider": "osv",
      "references": [
        "https://cna.erlef.org/cves/CVE-2026-21621.html",
        "https://github.com",
        "https://osv.dev/vulnerability/EEF-CVE-2026-21621",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/21xxx/CVE-2026-21621.json",
        "https://github.com/hexpm/hexpm/security/advisories/GHSA-739m-8727-j6w3",
        "https://nvd.nist.gov/vuln/detail/CVE-2026-21621",
        "https://github.com/hexpm/hexpm/commit/71c127afebb7ed7cc637eb231b98feb802d62999",
        "https://github.com/hexpm/hexpm.git"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-863"
        ],
        "cna_assigner": "EEF",
        "unresolved_ranges": [
          {
            "extracted_events": [
              {
                "range": [
                  {
                    "introduced": "2025-08-18"
                  },
                  {
                    "fixed": "2026-03-05"
                  }
                ],
                "source": "AFFECTED_FIELD",
                "strategy": "StandardRange"
              }
            ]
          }
        ],
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/21xxx/CVE-2026-21621.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2026-21621",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 492425,
  "published_at": "2026-03-05T19:20:05.831+00:00"
}