Am I affected?

type your hexpm/hexpm version to check

Description

Insufficient Session Expiration vulnerability in OAuth token issuance in hexpm hexpm allows a user whose organization membership or session has ended to keep reading the organization's private packages and their documentation tarballs via a retained refresh token.

generate_refresh_token/4 in lib/hexpm/oauth/jwt.ex signs the refresh token with the same iss, aud and scope claims as the access token, so it carries the same repository:<org> scopes. The CDN service that serves private repositories verifies the signature and time claims and then authorizes from the scope claim, with no database lookup and no way to tell the two token kinds apart. Removing a member or revoking a session therefore takes effect at the CDN only when the 30 day refresh token expires, instead of after the 30 minute access token lifetime. Access is read-only and limited to organizations the account belonged to when the token was granted.

This issue affects hex.pm: from 2025-10-10 before 2026-09-22.

Technical analysis

1. Token issuance

Hexpm.OAuth.JWT.generate_refresh_token/4 builds its claim set from the same template as generate_access_token/4, changing only exp, so a refresh token carries the scope claim of the access token it is issued with. hexpm itself never reads that claim: the refresh grant resolves scopes from the database, and Hexpm.OAuth.Tokens.lookup/3 matches an access token on the jti column and a refresh token on refresh_jti, so hexpm's API rejects a refresh token presented as a bearer credential.

2. Edge authorization

The CDN service in front of private repositories consults no database. It verifies the ES256 signature, iss, aud, nbf and exp, then grants access when scope contains repository:<org>. A refresh token sent as Authorization: Bearer passes every check and is authorized like an access token.

3. Effect

Member removal, session revocation and an organization single sign-on session lapsing rely on the 30 minute access token lifetime to take effect at the CDN, because the CDN has no revocation list. A copy of the refresh token extends that window to its 30 day lifetime.

Proof of concept

  1. Authenticate a CLI session with mix hex.user auth for an account that is a member of an organization with private packages. ~/.hex/hex.config then holds an access token and a refresh token.
  2. Copy the refresh token out of that file.
  3. Remove the account from the organization, or revoke the session.
  4. Request https://repo.hex.pm/repos/<org>/tarballs/<package>-<version>.tar with the header Authorization: Bearer <refresh token>.
  5. The CDN serves the tarball until the refresh token's 30 day expiry, while the access token from the same file stops working within 30 minutes.

Weaknesses & attack patterns

Weakness

CWE-613 · Insufficient Session Expiration in catalog → MITRE ↗

Attack patterns

CAPEC-60 · Reusing Session IDs (aka Session Replay) MITRE ↗

A user removed from an organization, or anyone holding a copy of a revoked session's refresh token, can keep downloading that organization's private packages and their documentation tarballs for up to 30 days after access was withdrawn.

Affected — hexpm / hexpm

2025-10-10 < 2026-09-22 affected
every other version: unaffected
cpe cpe:2.3:a:hexpm:hexpm:*:*:*:*:*:*:*:*
modules · source files · routines
modules 'Elixir.Hexpm.OAuth.JWT' · 'Elixir.Hexpm.OAuth.Tokens'
source files lib/hexpm/oauth/jwt.ex · lib/hexpm/oauth/tokens.ex
routines 'Elixir.Hexpm.OAuth.JWT':generate_refresh_token/4 · 'Elixir.Hexpm.OAuth.Tokens':create_for_user/6

Affected — GitHub / hexpm/hexpm Repository ↗

650faa0 < db58cf3 affected
every other version: unaffected
cpe cpe:2.3:a:hexpm:hexpm:*:*:*:*:*:*:*:*
modules · source files · routines
modules 'Elixir.Hexpm.OAuth.JWT' · 'Elixir.Hexpm.OAuth.Tokens'
source files lib/hexpm/oauth/jwt.ex · lib/hexpm/oauth/tokens.ex
routines 'Elixir.Hexpm.OAuth.JWT':generate_refresh_token/4 · 'Elixir.Hexpm.OAuth.Tokens':create_for_user/6

References

Credits

Peter Ullrich Finder
Jonatan Männchen / EEF Analyst
Eric Meadows-Jönsson Remediation developer

CVSS breakdown

CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:L/VI:N/VA:N/SC:L/SI:N/SA:N
« All CVEs