{"answers":{"affected":"24 open source packages ship an affected version, including web-token/jwt-bundle, web-token/jwt-experimental and web-token/jwt-framework.","exploited":"There is no known exploitation of GHSA-jc38-x7x8-2xc8 in the wild and no public exploit code.","fix":"Upgrade web-token/jwt-bundle to a fixed version for your release line: 3.4.10, 4.0.7 or 4.1.7.","what":"GHSA-jc38-x7x8-2xc8 is a vulnerability in web-token/jwt-bundle, published on 18 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-jc38-x7x8-2xc8 and fix it if it is affected.\n\nWhat it is: GHSA-jc38-x7x8-2xc8 is a vulnerability in web-token/jwt-bundle, published on 18 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-jc38-x7x8-2xc8 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- web-token/jwt-bundle (Packagist): affected all versions; fixed in 3.4.10\n- web-token/jwt-bundle (Packagist): affected all versions; fixed in 3.4.10\n- web-token/jwt-bundle (Packagist): affected from 4.0.0; fixed in 4.0.7\n- web-token/jwt-bundle (Packagist): affected from 4.0.0; fixed in 4.0.7\n- web-token/jwt-bundle (Packagist): affected from 4.1.0; fixed in 4.1.7\n- web-token/jwt-bundle (Packagist): affected from 4.1.0; fixed in 4.1.7\n- web-token/jwt-experimental (Packagist): affected all versions; fixed in 3.4.10\n- web-token/jwt-experimental (Packagist): affected all versions; fixed in 3.4.10\n- web-token/jwt-experimental (Packagist): affected from 4.0.0; fixed in 4.0.7\n- web-token/jwt-experimental (Packagist): affected from 4.0.0; fixed in 4.0.7\n- web-token/jwt-experimental (Packagist): affected from 4.1.0; fixed in 4.1.7\n- web-token/jwt-experimental (Packagist): affected from 4.1.0; fixed in 4.1.7\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-jc38-x7x8-2xc8/ (Markdown: https://insights.sbomify.com/GHSA-jc38-x7x8-2xc8/index.md)","id":"GHSA-jc38-x7x8-2xc8","markdown":"https://insights.sbomify.com/GHSA-jc38-x7x8-2xc8/index.md","name":"GHSA-jc38-x7x8-2xc8","record":{"aliases":[],"analysis":{"component_type":"library","fix_type":"patch","impacts":["security_bypass"],"network_reachable":"yes","non_default_config":false,"product_category":"PHP JWT library","requires_auth":"none","summary":"Attackers can bypass JWT signature verification by overriding the algorithm in unprotected headers, allowing token forgery.","user_interaction":"not_required","vuln_class":"security_feature_bypass"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"## Summary\n\n`JWSVerifier::getAlgorithm()` in `src/Library/Signature/JWSVerifier.php` (line 144) merges protected and unprotected headers using PHP's spread operator:\n\n```php\n$completeHeader = [...$signature-\u003egetProtectedHeader(), ...$signature-\u003egetHeader()];\n```\n\nIn PHP, when spreading arrays with duplicate string keys, the **last array's values take precedence**. Since the unprotected header (`getHeader()`) is spread second, an attacker can override the integrity-protected `alg` parameter by placing a different value in the unprotected header.\n\nThis creates a Time-of-Check/Time-of-Use (TOCTOU) vulnerability:\n1. `HeaderCheckerManager` validates `alg` from the **protected** header\n2. `JWSVerifier` uses `alg` from the **unprotected** header for actual verification\n\nThe same issue exists in `JWEDecrypter.php` (lines 120-124) where `array_merge()` exhibits the same last-wins behavior for `alg` and `enc`.\n\n## Affected Code\n\n**JWSVerifier.php line 144** — Spread operator merge order allows unprotected header to override `alg`:\n```php\n$completeHeader = [...$signature-\u003egetProtectedHeader(), ...$signature-\u003egetHeader()];\n```\n\n**JWEDecrypter.php lines 120-124** — `array_merge()` with same last-wins behavior:\n```php\n$completeHeader = array_merge(\n    $jwe-\u003egetSharedProtectedHeader(),\n    $jwe-\u003egetSharedHeader(),\n    $recipient-\u003egetHeader()\n);\n```\n\n## Attack Vectors\n\n### Vector A — Mixed key sets (HIGH probability)\nIf the application uses a JWKSet containing keys of different types (common in multi-tenant or federation scenarios), the JWSVerifier iterates all keys (line 86). An attacker can force a different algorithm that matches a different key in the set.\n\n### Vector B — alg ONLY in unprotected header (HIGH probability)\nIf `alg` is placed EXCLUSIVELY in the unprotected header (not in the protected header at all), `HeaderCheckerManager::checkDuplicatedHeaderParameters()` does NOT trigger. The JSON Flattened/General serializers allow tokens with no protected header or a protected header without `alg`. RFC 7515 Section 4.1.1 states `alg` MUST be integrity-protected, but the library does not enforce this.\n\n### Vector C — Direct JWSVerifier usage (HIGH probability)\n`JWSLoader` takes `?HeaderCheckerManager` (nullable). If developers use `JWSVerifier` directly or create `JWSLoader` without a `HeaderCheckerManager`, the duplicate header check never runs.\n\n## Contrast with JWSBuilder (safe)\n\n`JWSBuilder::findSignatureAlgorithm()` (line 196) uses `[...$header, ...$protectedHeader]` where protected wins. It also has `checkDuplicatedHeaderParameters()` (line 218). The JWSVerifier has **neither** safeguard.\n\n## Proof of Concept\n\n```php\n\u003c?php\n// Demonstrate algorithm override via unprotected header\n$protected = [\"alg\" =\u003e \"RS256\", \"typ\" =\u003e \"JWT\"];\n$unprotected = [\"alg\" =\u003e \"HS256\"];\n$merged = [...$protected, ...$unprotected];\n// $merged[\"alg\"] === \"HS256\" — unprotected wins!\n\n// JSON Flattened JWS with algorithm override:\n$maliciousJws = json_encode([\n    'payload' =\u003e base64url_encode($payload),\n    'protected' =\u003e base64url_encode('{\"alg\":\"RS256\"}'),\n    'header' =\u003e ['alg' =\u003e 'HS256'],  // OVERRIDE\n    'signature' =\u003e base64url_encode($sig),\n]);\n// HeaderCheckerManager validates RS256 from protected header -\u003e PASS\n// JWSVerifier uses HS256 from unprotected header -\u003e attacker's algorithm choice\n```\n\nA full working PoC demonstrating HS512-to-HS256 downgrade with mixed keysets is available upon request.\n\n## Suggested Fix\n\nIn `JWSVerifier::getAlgorithm()`, read `alg` exclusively from the protected header:\n\n```php\nprivate function getAlgorithm(Signature $signature): Algorithm\n{\n    $protectedHeader = $signature-\u003egetProtectedHeader();\n    if (! isset($protectedHeader['alg'])) {\n        throw new InvalidArgumentException('The \"alg\" parameter must be in the protected header.');\n    }\n    return $this-\u003esignatureAlgorithmManager-\u003eget($protectedHeader['alg']);\n}\n```\n\nFor `JWEDecrypter`, reverse the merge order so protected header wins, or extract `alg`/`enc` exclusively from the protected header.\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**JWS algorithm confusion** — `JWSVerifier` lit le paramètre `alg` exclusivement dans le header protégé en intégrité (RFC 7515 §4.1.1) ; un `alg` placé dans le header non protégé ne peut plus surcharger l'algorithme signé.\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`.","ecosystems":["Packagist"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"PHP JWT Framework: JWSVerifier uses algorithm from unprotected header, enabling algorithm confusion attacks","id":"GHSA-jc38-x7x8-2xc8","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"Packagist","product":null,"products":[],"type":"security_feature_bypass","year":"2026"},"n_packages":24,"n_references":null,"packages":[{"ecosystem":"Packagist","fixed":["3.4.10"],"introduced":["0"],"last_affected":[],"package":"web-token/jwt-bundle","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["3.4.10"],"introduced":["0"],"last_affected":[],"package":"web-token/jwt-bundle","purl":"pkg:composer/web-token/jwt-bundle","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.0.7"],"introduced":["4.0.0"],"last_affected":[],"package":"web-token/jwt-bundle","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.0.7"],"introduced":["4.0.0"],"last_affected":[],"package":"web-token/jwt-bundle","purl":"pkg:composer/web-token/jwt-bundle","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.1.7"],"introduced":["4.1.0"],"last_affected":[],"package":"web-token/jwt-bundle","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.1.7"],"introduced":["4.1.0"],"last_affected":[],"package":"web-token/jwt-bundle","purl":"pkg:composer/web-token/jwt-bundle","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["3.4.10"],"introduced":["0"],"last_affected":[],"package":"web-token/jwt-experimental","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["3.4.10"],"introduced":["0"],"last_affected":[],"package":"web-token/jwt-experimental","purl":"pkg:composer/web-token/jwt-experimental","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.0.7"],"introduced":["4.0.0"],"last_affected":[],"package":"web-token/jwt-experimental","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.0.7"],"introduced":["4.0.0"],"last_affected":[],"package":"web-token/jwt-experimental","purl":"pkg:composer/web-token/jwt-experimental","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.1.7"],"introduced":["4.1.0"],"last_affected":[],"package":"web-token/jwt-experimental","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.1.7"],"introduced":["4.1.0"],"last_affected":[],"package":"web-token/jwt-experimental","purl":"pkg:composer/web-token/jwt-experimental","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["3.4.10"],"introduced":["0"],"last_affected":[],"package":"web-token/jwt-framework","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["3.4.10"],"introduced":["0"],"last_affected":[],"package":"web-token/jwt-framework","purl":"pkg:composer/web-token/jwt-framework","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.0.7"],"introduced":["4.0.0"],"last_affected":[],"package":"web-token/jwt-framework","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.0.7"],"introduced":["4.0.0"],"last_affected":[],"package":"web-token/jwt-framework","purl":"pkg:composer/web-token/jwt-framework","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.1.7"],"introduced":["4.1.0"],"last_affected":[],"package":"web-token/jwt-framework","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.1.7"],"introduced":["4.1.0"],"last_affected":[],"package":"web-token/jwt-framework","purl":"pkg:composer/web-token/jwt-framework","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["3.4.10"],"introduced":["0"],"last_affected":[],"package":"web-token/jwt-library","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["3.4.10"],"introduced":["0"],"last_affected":[],"package":"web-token/jwt-library","purl":"pkg:composer/web-token/jwt-library","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.0.7"],"introduced":["4.0.0"],"last_affected":[],"package":"web-token/jwt-library","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.0.7"],"introduced":["4.0.0"],"last_affected":[],"package":"web-token/jwt-library","purl":"pkg:composer/web-token/jwt-library","source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.1.7"],"introduced":["4.1.0"],"last_affected":[],"package":"web-token/jwt-library","purl":null,"source":"GHSA-jc38-x7x8-2xc8"},{"ecosystem":"Packagist","fixed":["4.1.7"],"introduced":["4.1.0"],"last_affected":[],"package":"web-token/jwt-library","purl":"pkg:composer/web-token/jwt-library","source":"GHSA-jc38-x7x8-2xc8"}],"products":null,"published":"2026-06-18","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Attackers can bypass JWT signature verification by overriding the algorithm in unprotected headers, allowing token forgery.","url":"https://insights.sbomify.com/GHSA-jc38-x7x8-2xc8/"}