<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Jwt-Library &gt;= 4.1.0, &lt; 4.1.7 - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/jwt-library--4.1.0--4.1.7/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Thu, 18 Jun 2026 21:14:03 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/jwt-library--4.1.0--4.1.7/feed.xml" rel="self" type="application/rss+xml"/><item><title>PHP JWT Framework Algorithm Confusion Vulnerability (TOCTOU)</title><link>https://feed.craftedsignal.io/briefs/2026-06-php-jwt-algo-confusion/</link><pubDate>Thu, 18 Jun 2026 21:14:03 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-06-php-jwt-algo-confusion/</guid><description>A Time-of-Check/Time-of-Use (TOCTOU) vulnerability exists in the `JWSVerifier` and `JWEDecrypter` components of the `web-token/jwt-framework` and `web-token/jwt-library` PHP packages, allowing an attacker to override the integrity-protected `alg` parameter from the unprotected header, leading to authentication bypass and unauthorized access.</description><content:encoded><![CDATA[<p>The <code>web-token/jwt-framework</code> and <code>web-token/jwt-library</code> PHP packages are affected by a Time-of-Check/Time-of-Use (TOCTOU) vulnerability that allows attackers to perform algorithm confusion attacks. Specifically, in <code>JWSVerifier::getAlgorithm()</code> and <code>JWEDecrypter</code>, header merging logic (<code>...</code> spread operator or <code>array_merge()</code>) incorrectly prioritizes the unprotected <code>alg</code> (algorithm) parameter over the integrity-protected one when duplicate keys exist. This means that while the protected header's <code>alg</code> might be validated (e.g., <code>RS256</code>), the actual signature verification or decryption might proceed with an attacker-specified <code>alg</code> from the unprotected header (e.g., <code>HS256</code> or <code>none</code>). This bypasses cryptographic integrity checks, enabling authentication bypass, unauthorized access, or information disclosure, making it critical for applications relying on these libraries for secure JWT handling.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li><strong>Initial Access / Reconnaissance:</strong> An attacker identifies a web application utilizing JSON Web Tokens (JWTs) for authentication or authorization.</li>
<li><strong>Malicious JWT Creation:</strong> The attacker crafts a JWT containing a protected header with a strong, integrity-protected algorithm (e.g., <code>alg: RS256</code>) and an unprotected header specifying a weaker or symmetric algorithm (e.g., <code>alg: HS256</code> or <code>alg: none</code>), intending for the unprotected <code>alg</code> to override the protected one.</li>
<li><strong>Token Submission:</strong> The attacker sends this crafted, malicious JWT to the vulnerable web application, typically within an HTTP <code>Authorization</code> header or as a cookie.</li>
<li><strong>Header Merging (TOCTOU):</strong> Upon receiving the JWT, the application's <code>JWSVerifier</code> or <code>JWEDecrypter</code> component merges the protected and unprotected headers. Due to the vulnerability, the <code>alg</code> parameter from the unprotected header overwrites the <code>alg</code> from the protected header in the internal merged array.</li>
<li><strong>Algorithm Validation (Time-of-Check):</strong> An initial check (e.g., by <code>HeaderCheckerManager</code>) might validate the <code>alg</code> from the <em>protected</em> header (e.g., <code>RS256</code>), which passes, creating a false sense of security.</li>
<li><strong>Signature/Decryption (Time-of-Use):</strong> The <code>JWSVerifier</code> or <code>JWEDecrypter</code> proceeds to verify the JWT signature (or decrypt the payload) using the <code>alg</code> parameter that was <em>overridden</em> by the unprotected header (e.g., <code>HS256</code> or <code>none</code>).</li>
<li><strong>Authentication Bypass / Data Compromise:</strong> If the attacker chose an <code>alg</code> like <code>none</code> or could forge a valid signature for a symmetric key (<code>HS256</code>), the system may successfully validate the JWT.</li>
<li><strong>Impact:</strong> This leads to unauthorized access, impersonation of legitimate users, or decryption of sensitive data, allowing the attacker to bypass authentication mechanisms.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>If exploited, this vulnerability leads to a severe authentication bypass, allowing attackers to forge valid JSON Web Tokens (JWTs) and gain unauthorized access to web applications. This could result in full account takeover, privilege escalation, and access to sensitive data or functionality that should be restricted. The impact is significant for applications that rely on <code>web-token/jwt-framework</code> or <code>web-token/jwt-library</code> for secure session management, API authentication, or inter-service communication. Organizations across all sectors using PHP applications with these specific JWT libraries are at risk, as the integrity of their authentication and authorization mechanisms is compromised.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Immediately update <code>composer/web-token/jwt-framework</code> to a patched version (e.g., newer than 4.2.99) to address the algorithm confusion vulnerability.</li>
<li>Immediately update <code>composer/web-token/jwt-library</code> to a patched version (e.g., &gt;= 3.4.10, &gt;= 4.0.7, &gt;= 4.1.7) to address the algorithm confusion vulnerability.</li>
<li>Review application logs for entries indicating JWT verification failures or unexpected algorithm usage for authentication (refer to the <code>Detect JWT Algorithm Verification Errors</code> rule).</li>
<li>Ensure verbose application logging is enabled for JWT processing and verification steps to aid in detection of anomalous <code>alg</code> parameter usage (refer to the <code>Detect JWT 'none' Algorithm Usage</code> rule).</li>
<li>Deploy the Sigma rules in this brief to your SIEM and tune for your environment, specifically for <code>webserver</code> logs that might contain application-level JWT processing details.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>vulnerability</category><category>php</category><category>jwt</category><category>web</category><category>authentication-bypass</category></item></channel></rss>