An authentication bypass vulnerability allows any unauthenticated attacker to forge arbitrary JWT tokens by setting "alg": "none" in the token header. The library's verification functions immediately return true for such tokens without performing any cryptographic verification, enabling complete impersonation of any user and privilege escalation.
The vulnerability exists in Sources/JSONWebSignature/JWS+Verify.swift at lines 34-37:
public func verify<Key>(key: Key?) throws -> Bool {
guard SigningAlgorithm.none != protectedHeader.algorithm else {
return true // <-- Vulnerability: returns true without verification
}
When the JWT header contains "alg": "none", the verify() method returns true immediately without:
The SigningAlgorithm enum in Sources/JSONWebAlgorithms/Signatures/SigningAlgorithm.swift:72 explicitly includes case none = "none" as a valid algorithm.
All verification methods are affected:
// Attacker's payload with escalated privileges let payload = #"{"sub":"user123","admin":true}"#
// Base64URL encode and concatenate with empty signature let forgedToken = base64url(header) + "." + base64url(payload) + "." // Result: eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJ1c2VyMTIzIiwiYWRtaW4iOnRydWV9.
This is an authentication bypass vulnerability. Who is impacted: Any application...
Exploitability
AV:NAC:LAT:NPR:NUI:NVulnerable System
VC:HVI:HVA:NSubsequent System
SC:NSI:NSA:N8.8/CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N/E:P