GHSA-3prj-6hqw-cm82: PHP JWT Library Denial of Service Vulnerability

HIGH
CWE-400 CWE-770
Published
Advisory Summary

GHSA-3prj-6hqw-cm82 is a HIGH denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting PHP JWT Library libraries in the Packagist ecosystem. The issue involves pbes2-hs*+a*kw unwrap accepts an unbounded p2c iteration count, enabling cpu-amplification denial of service. Remediation is available by upgrading affected packages to version 3.4.10, 4.0.7, 4.1.7.

GHSA-3prj-6hqw-cm82 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-3prj-6hqw-cm82
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product PHP JWT Library
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix GHSA-3prj-6hqw-cm82

To remediate this vulnerability, upgrade all affected PHP JWT Library dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

web-token/jwt-library fixed: 3.4.10
Upgrade web-token/jwt-library to 3.4.10
web-token/jwt-framework fixed: 3.4.10
Upgrade web-token/jwt-framework to 3.4.10
web-token/jwt-library fixed: 4.0.7
Upgrade web-token/jwt-library to 4.0.7
web-token/jwt-library fixed: 4.1.7
Upgrade web-token/jwt-library to 4.1.7
web-token/jwt-framework fixed: 4.0.7
Upgrade web-token/jwt-framework to 4.0.7
web-token/jwt-framework fixed: 4.1.7
Upgrade web-token/jwt-framework to 4.1.7
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for web-token/jwt-library

How to Check if You Are Affected

To determine whether your application is affected by GHSA-3prj-6hqw-cm82, inspect your project dependencies for PHP JWT Library:

inspect dependencies for web-token/jwt-library

Analyze the terminal output to locate any version of PHP JWT Library in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.4.10), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In PHP JWT Library, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact When a JWE uses a password-based key-encryption algorithm (`PBES2-HS256+A128KW`, `PBES2-HS384+A192KW`, `PBES2-HS512+A256KW`), `PBES2AESKW::unwrapKey()` reads the `p2c` (PBKDF2 iteration count) parameter directly from the attacker-controlled JOSE header and passes it to `hash_pbkdf2()` with **no upper bound**. The only validation performed (`checkHeaderAdditionalParameters()`) was `is_int($p2c) && $p2c > 0`. An unauthenticated attacker can craft a single JWE whose protected header sets a very large `p2c` (e.g. `100_000_000` ≈ 87 s of CPU, or `PHP_INT_MAX`), forcing a worker to spend an arbitrary amount of CPU inside PBKDF2 **before** the key unwrap can even fail. The decrypter swallows the eventual exception, so the attacker pays almost nothing while the server burns CPU. JSON General serialization (multiple recipients) and multi-key JWKSets multiply the cost. This is a classic uncontrolled-resource-consumption (CWE-400) denial of service. ### Affected configurations Applications that register any `PBES2-HS*+A*KW` algorithm in their decryption `AlgorithmManager`. ### Patches `PBES2AESKW` now enforces a configurable maximum iteration count (`DEFAULT_MAX_COUNT = 1_000_000`, well above realistic legitimate values which are a few thousand) in `checkHeaderAdditionalParameters()`, before any PBKDF2 computation. The bound is exposed as a constructor argument so operators can tune it. ### Workarounds Before upgrading: validate/limit the `p2c` header with a custom header checker, or do not enable PBES2 algorithms for untrusted tokens. ### References - RFC 7518 §4.8 (PBES2) - CWE-400: Uncontrolled Resource Consumption ## Résolution Un correctif a été préparé sur une branche dédiée basée sur `3.4.x`, avec des tests anti-régression dédiés (fork privé temporaire de cette advisory, PR #1). **PBES2** — `PBES2AESKW::unwrapKey()` borne désormais le paramètre `p2c` (constante `DEFAULT_MAX_COUNT = 1_000_000`, configurable via le constructeur) avant tout appel à `hash_pbkdf2()`, empêchant l'amplification CPU (DoS). **Validation :** `php -l` OK, PHPUnit vert, aucune nouvelle erreur PHPStan introduite (différentiel nul vs `3.4.x`), aucun commentaire ajouté dans le code source. Après merge, cascade prévue `3.4.x → 4.0.x → 4.1.x`.

GHSA-3prj-6hqw-cm82 Affected PHP JWT Library Versions

6 component(s)
Fixed Versions:
3.4.104.0.74.1.7
Product / Package Ecosystem Affected Versions Fixed Version
web-token/jwt-library
Packagist
< 3.4.10
3.4.10
web-token/jwt-framework
Packagist
< 3.4.10
3.4.10
web-token/jwt-library
Packagist
≥ 4.0.0
< 4.0.7
4.0.7
web-token/jwt-library
Packagist
≥ 4.1.0
< 4.1.7
4.1.7
web-token/jwt-framework
Packagist
≥ 4.0.0
< 4.0.7
4.0.7
web-token/jwt-framework
Packagist
≥ 4.1.0
< 4.1.7
4.1.7

References

Frequently Asked Questions

What is GHSA-3prj-6hqw-cm82?
GHSA-3prj-6hqw-cm82 is a security vulnerability in PHP JWT Library involving PBES2-HS*+A*KW unwrap accepts an unbounded p2c iteration count, enabling CPU-amplification denial of service under CWE-400: Uncontrolled Resource Consumption.
Which PHP JWT Library versions are affected?
Affected versions include releases prior to 3.4.10, 4.0.7, 4.1.7 across affected packages: web-token/jwt-library, web-token/jwt-framework.
What version fixes GHSA-3prj-6hqw-cm82?
Upgrading to 3.4.10, 4.0.7, 4.1.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is web-token/jwt-library affected?
Yes, web-token/jwt-library is affected in releases prior to 3.4.10, 4.0.7, 4.1.7. Upgrade your dependency to 3.4.10, 4.0.7, 4.1.7 or later.
Is web-token/jwt-framework affected?
Yes, web-token/jwt-framework is affected in releases prior to 3.4.10, 4.0.7, 4.1.7. Upgrade your dependency to 3.4.10, 4.0.7, 4.1.7 or later.
What CWE is associated with GHSA-3prj-6hqw-cm82?
GHSA-3prj-6hqw-cm82 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check Packagist dependencies for GHSA-3prj-6hqw-cm82?
Run the dependency tree command: 'inspect dependencies for web-token/jwt-library'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3prj-6hqw-cm82",
  "modified" : "2026-07-15T21:51:04Z",
  "published" : "2026-06-18T21:09:01Z",
  "aliases" : [ ],
  "summary" : "PHP JWT Library: PBES2-HS*+A*KW unwrap accepts an unbounded p2c iteration count, enabling CPU-amplification denial of service",
  "details" : "### Impact\n\nWhen a JWE uses a password-based key-encryption algorithm (`PBES2-HS256+A128KW`, `PBES2-HS384+A192KW`, `PBES2-HS512+A256KW`), `PBES2AESKW::unwrapKey()` reads the `p2c` (PBKDF2 iteration count) parameter directly from the attacker-controlled JOSE header and passes it to `hash_pbkdf2()` with **no upper bound**. The only validation performed (`checkHeaderAdditionalParameters()`) was `is_int($p2c) && $p2c > 0`.\n\nAn unauthenticated attacker can craft a single JWE whose protected header sets a very large `p2c` (e.g. `100_000_000` ≈ 87 s of CPU, or `PHP_INT_MAX`), forcing a worker to spend an arbitrary amount of CPU inside PBKDF2 **before** the key unwrap can even fail. The decrypter swallows the eventual exception, so the attacker pays almost nothing while the server burns CPU. JSON General serialization (multiple recipients) and multi-key JWKSets multiply the cost. This is a classic uncontrolled-resource-consumption (CWE-400) denial of service.\n\n### Affected configurations\n\nApplications that register any `PBES2-HS*+A*KW` algorithm in their decryption `AlgorithmManager`.\n\n### Patches\n\n`PBES2AESKW` now enforces a configurable maximum iteration count (`DEFAULT_MAX_COUNT = 1_000_000`, well above realistic legitimate values which are a few thousand) in `checkHeaderAdditionalParameters()`, before any PBKDF2 computation. The bound is exposed as a constructor argument so operators can tune it.\n\n### Workarounds\n\nBefore upgrading: validate/limit the `p2c` header with a custom header checker, or do not enable PBES2 algorithms for untrusted tokens.\n\n### References\n\n- RFC 7518 §4.8 (PBES2)\n- CWE-400: Uncontrolled Resource Consumption\n\n## Résolution\n\nUn correctif a été préparé sur une branche dédiée basée sur `3.4.x`, avec des tests anti-régression dédiés (fork privé temporaire de cette advisory, PR #1).\n\n**PBES2** — `PBES2AESKW::unwrapKey()` borne désormais le paramètre `p2c` (constante `DEFAULT_MAX_COUNT = 1_000_000`, configurable via le constructeur) avant tout appel à `hash_pbkdf2()`, empêchant l'amplification CPU (DoS).\n\n**Validation :** `php -l` OK, PHPUnit vert, aucune nouvelle erreur PHPStan introduite (différentiel nul vs `3.4.x`), aucun commentaire ajouté dans le code source. Après merge, cascade prévue `3.4.x → 4.0.x → 4.1.x`.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "web-token/jwt-library"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.4.10"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "web-token/jwt-framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.4.10"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "web-token/jwt-library"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.0.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "web-token/jwt-library"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.1.0"
      }, {
        "fixed" : "4.1.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "web-token/jwt-framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.0.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "web-token/jwt-framework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.1.0"
      }, {
        "fixed" : "4.1.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/web-token/jwt-framework/security/advisories/GHSA-3prj-6hqw-cm82"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/web-token/jwt-library/GHSA-3prj-6hqw-cm82.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/web-token/jwt-framework"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/web-token/jwt-framework/releases/tag/3.4.10"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/web-token/jwt-framework/releases/tag/4.0.7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/web-token/jwt-framework/releases/tag/4.1.7"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400", "CWE-770" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-18T21:09:01Z",
    "nvd_published_at" : null
  }
}