Dec 2, 2026·11 min read·1 visit
Vapor JWTKit prior to 5.8.0 verifies cryptographic signatures, issuer claims, and expiration timestamps for Apple, Google, and Microsoft identity tokens, but omits audience (aud) validation by default. Attackers can replay valid identity tokens issued for arbitrary third-party OAuth/OIDC clients to authenticate to vulnerable applications.
Vapor JWTKit versions 4.0.0 prior to 5.8.0 fail to validate the audience (aud) claim in built-in vendor identity token payload types for Apple, Google, and Microsoft. This improper authentication flaw allows an attacker to obtain a legitimately signed ID token for a third-party client application and replay it against a relying party application using JWTKit, resulting in cross-client authentication bypass and account takeover.
Vapor JWTKit (github.com/vapor/jwt-kit) is a foundational Swift library used across server-side Swift applications and the Vapor web framework to generate, sign, and verify JSON Web Tokens (JWTs). In addition to low-level JWS and JWE primitives, JWTKit ships built-in payload structures for major OpenID Connect (OIDC) identity providers, including AppleIdentityToken, GoogleIdentityToken, MicrosoftIdentityToken, and FirebaseAuthIdentityToken. Application developers use these structures to authenticate users via federated login workflows.
In versions from 4.0.0 up to 5.8.0, the built-in verification routines for AppleIdentityToken, GoogleIdentityToken, and MicrosoftIdentityToken exhibit an authentication bypass vulnerability classified under CWE-287 (Improper Authentication) and CWE-345 (Insufficient Verification of Data Authenticity). When an application invokes JWTKeyCollection.verify(_:as:) with one of these vendor types, the library validates the cryptographic signature against the provider's JSON Web Key Set (JWKS), checks the token expiration (exp), and verifies the issuer (iss) claim. However, the verification routine fails to validate the audience (aud) claim against the relying party's expected client identifier.
Because the aud claim is decoded into the payload struct but ignored during verification, any authentic ID token issued by Apple, Google, or Microsoft for any registered application on their platforms is treated as valid by JWTKit. Unless the consuming application implements a separate, manual audience assertion after calling verify, the authentication check passes regardless of which client application requested the token.
This design flaw exposes relying party backends to cross-client token replay attacks. An adversary can obtain a genuine identity token issued to an arbitrary third-party OAuth/OIDC client and present it to the target application's authentication endpoint. The target backend accepts the foreign token as proof of identity, enabling unauthorized session creation or full account takeover.
The OpenID Connect Core 1.0 specification (Section 3.1.3.7, ID Token Validation) mandates strict audience binding for all relying parties. Specifically, the relying party must verify that the aud (audience) claim contains its assigned client_id value registered at the Issuer, and must reject the ID token if the aud claim does not list the relying party or contains untrusted audiences. Furthermore, if an azp (authorized party) claim is present, the relying party must verify that the client ID of the presenter is trusted.
A valid cryptographic signature from an Identity Provider (IdP) such as https://appleid.apple.com or https://accounts.google.com proves only that the IdP minted the token for some client on its platform. It does not bind the authentication assertion to a specific consuming service. Without checking aud, the verification boundary collapses from application-specific trust to global provider-wide trust.
In JWTKit prior to 5.8.0, token verification is driven by the JWTPayload protocol, which requires conforming types to implement func verify(using algorithm: some JWTAlgorithm) async throws. During verification inside JWTSigner.verify, the library checks the cryptographic signature over the header and payload bytes, deserializes the JSON into the target Payload type, and calls try await payload.verify(using: algorithm). Because payload.verify(using:) takes no context regarding the local application's configuration or expected client ID, the vendor structs had no mechanism to compare the decoded aud claim against an expected target value.
An architectural discrepancy existed within the same codebase prior to the patch. FirebaseAuthIdentityToken implicitly bound its validation to a specific project by checking that iss matched https://securetoken.google.com/<projectId>, deriving the project identifier directly from the token's audience claim. In contrast, AppleIdentityToken, GoogleIdentityToken, and MicrosoftIdentityToken relied on static or tenant-derived issuer URLs without verifying whether the audience claim belonged to the verifying application.
In vulnerable versions of JWTKit (< 5.8.0), the core verification path in Sources/JWTKit/JWTSigner.swift verifies the signature and delegates claim checks solely to the parameterless payload.verify(using:) method:
// Sources/JWTKit/JWTSigner.swift (Vulnerable Flow)
guard try algorithm.verify(signature, signs: data) else {
throw JWTError.signatureVerificationFailed
}
let (_, payload, _) = try parser.parse(token, as: Payload.self)
// Invokes claim verification without passing an expected audience context
try await payload.verify(using: algorithm)Within the vendor payload definitions, each struct implemented verify(using:) by validating only issuer, subject constraints, and expiration. Specifically, AppleIdentityToken.swift (lines 85-90) checked only iss == "https://appleid.apple.com" and exp. GoogleIdentityToken.swift (lines 139-148) checked only iss (accounts.google.com), sub length (<= 255), and exp. MicrosoftIdentityToken.swift (lines 149-158) checked only tid/iss consistency and exp. In all three implementations, self.audience.verifyIntendedAudience(...) was never called.
Commit a1551090db2a3bd86f0482622e2d201c199e75ad resolves this issue by introducing a dedicated JWTIdentityToken protocol and an accompanying JWTIdentityTokenValidation validator in Sources/JWTKit/Vendor/JWTIdentityToken.swift:
public protocol JWTIdentityToken: JWTPayload {
var audience: AudienceClaim { get }
}
struct JWTIdentityTokenValidation: Sendable {
let expectedAudiences: Set<String>
let trustedAdditionalAudiences: Set<String>
let trustedAuthorizedPresenters: Set<String>?
func validate(_ token: any JWTIdentityToken) throws {
// Reject empty audience configurations
guard !self.expectedAudiences.isEmpty, !self.expectedAudiences.contains("") else {
throw JWTError.generic(identifier: "Audience", reason: "Expected audience must not be empty")
}
// Ensure at least one expected audience is present in the token's aud claim
guard token.audience.value.contains(where: self.expectedAudiences.contains) else {
throw JWTError.claimVerificationFailure(
failedClaim: token.audience,
reason: "Token was not issued for an expected audience"
)
}
// Reject tokens that contain any untrusted extra audiences in multi-audience tokens
let allowedAudiences = self.trustedAdditionalAudiences.union(self.expectedAudiences)
guard token.audience.value.allSatisfy(allowedAudiences.contains) else {
throw JWTError.claimVerificationFailure(
failedClaim: token.audience,
reason: "Token includes an untrusted audience"
)
}
// Enforce Google azp (authorized presenter) validation when configured
if let trustedAuthorizedPresenters = self.trustedAuthorizedPresenters {
guard let google = token as? GoogleIdentityToken else {
throw JWTError.generic(
identifier: "AuthorizedPresenter",
reason: "Authorized presenter validation requires a Google identity token"
)
}
let allowedPresenters = trustedAuthorizedPresenters.union(self.expectedAudiences)
guard allowedPresenters.contains(google.authorizedPresenter) else {
throw JWTError.claimVerificationFailure(
failedClaim: nil,
reason: "Google identity token has an untrusted authorized presenter"
)
}
}
}
}The patch updates AppleIdentityToken, GoogleIdentityToken, MicrosoftIdentityToken, and FirebaseAuthIdentityToken to conform to JWTIdentityToken and adds overloaded verify methods on JWTKeyCollection that mandate expectedAudience or expectedAudiences parameters:
public func verify<Payload>(
_ token: String,
as _: Payload.Type = Payload.self,
expectedAudience: String,
trustedAdditionalAudiences: Set<String> = [],
iteratingKeys: Bool = false
) async throws -> Payload where Payload: JWTIdentityToken> [!NOTE]
> Regarding fix completeness: To preserve source compatibility within the 5.x release branch, the unparameterized verify(_:as:iteratingKeys:) overload was not removed outright. Instead, it was marked @available(*, deprecated) with a compiler warning and instrumented to emit a runtime warning via SwiftLog whenever an JWTIdentityToken is verified without an audience check. Applications that upgrade the library dependency without migrating to the new expectedAudience API overloads remain vulnerable until their call sites are updated.
Exploiting CVE-2026-142551 requires no cryptographic forgery or private key compromise. Instead, the attacker leverages the legitimate OAuth 2.0 / OIDC infrastructure of Apple, Google, or Microsoft to generate a genuine, provider-signed ID token for an external application and replays it against the target service.
In an account takeover scenario, the attacker registers a third-party OAuth 2.0 client (such as a mobile app or web service) with the same Identity Provider supported by the target application. When a user signs into the attacker's service using "Sign in with Apple", "Sign in with Google", or Microsoft Entra ID, the provider issues a cryptographically signed ID token to the attacker's client. This token contains the victim's real email claim (and, for Google or global providers, the victim's consistent sub identifier), alongside an aud claim identifying the attacker's client_id.
The attacker captures this ID token and submits it directly to the victim application's authentication API endpoint. The victim backend processes the token using keys.verify(token, as: GoogleIdentityToken.self). JWTKit validates the signature against Google's public JWKS keys, verifies that iss is accounts.google.com, checks that exp is in the future, and returns the decoded GoogleIdentityToken struct. The victim application then looks up the user record by email or sub and issues an authenticated session token for the victim's account.
The upstream security advisory (GHSA-gxx9-vxm7-hgrq) provides a self-contained Proof of Concept demonstrating that AppleIdentityToken, GoogleIdentityToken, and MicrosoftIdentityToken all pass verification when populated with attacker-controlled audience values:
import JWTKit
import Foundation
@main
struct PoC {
static func main() async throws {
let keys = JWTKeyCollection()
await keys.add(hmac: "secret", digestAlgorithm: .sha256)
// 1. Apple Identity Token with foreign aud
let apple = AppleIdentityToken(
issuer: "https://appleid.apple.com",
audience: "com.attacker.app",
expires: .init(value: Date().addingTimeInterval(3600)),
issuedAt: .init(value: Date()),
subject: "victim-apple-sub"
)
let appleJWT = try await keys.sign(apple)
_ = try await keys.verify(appleJWT, as: AppleIdentityToken.self)
print("Apple token accepted with aud=com.attacker.app")
// 2. Google Identity Token with foreign aud
let google = GoogleIdentityToken(
issuer: "https://accounts.google.com",
subject: "victim-google-sub",
audience: "attacker-client.apps.googleusercontent.com",
authorizedPresenter: "attacker-client.apps.googleusercontent.com",
issuedAt: .init(value: Date()),
expires: .init(value: Date().addingTimeInterval(3600))
)
let googleJWT = try await keys.sign(google)
_ = try await keys.verify(googleJWT, as: GoogleIdentityToken.self)
print("Google token accepted with attacker client audience")
// 3. Microsoft Identity Token with foreign aud
let tenant = "11111111-2222-3333-4444-555555555555"
let microsoft = MicrosoftIdentityToken(
audience: "00000000-1111-2222-3333-444444444444",
issuer: .init(value: "https://login.microsoftonline.com/\(tenant)/v2.0"),
issuedAt: .init(value: Date()),
identityProvider: nil,
notBefore: .init(value: Date()),
expires: .init(value: Date().addingTimeInterval(3600)),
codeHash: nil,
accessTokenHash: nil,
preferredUsername: "victim@example.com",
email: nil,
name: nil,
nonce: nil,
objectId: "victim-object-id",
roles: nil,
subject: "victim-ms-sub",
tenantId: .init(value: tenant),
uniqueName: nil,
version: "2.0"
)
let microsoftJWT = try await keys.sign(microsoft)
_ = try await keys.verify(microsoftJWT, as: MicrosoftIdentityToken.self)
print("Microsoft token accepted with attacker app audience")
}
}CVE-2026-142551 is assigned a CVSS v3.1 base score of 8.1 (High) with the vector CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N. The Attack Vector is Network (AV:N) and Attack Complexity is Low (AC:L) because authentication endpoints are directly exposed over HTTP/HTTPS and accept standard OIDC tokens without requiring race conditions or memory manipulation. Privileges Required is None (PR:N), while User Interaction is Required (UI:R) for targeted account takeover where a victim must authenticate to a third-party OIDC client from which the attacker can harvest an ID token.
The concrete security impact depends on how the relying party maps identity claims to local user accounts. For Google identity tokens, the sub claim is globally unique per Google account across independent OAuth clients (unless separated by specific Google Workspace configurations), and the email claim is consistent across all providers. Any application matching users by email, or matching Google/Microsoft users by sub or objectId, allows an attacker possessing a cross-client token for that user to take over the target account completely.
For Apple identity tokens, Apple generates a developer-team-scoped sub identifier, meaning two unrelated developer accounts receive different sub values for the same user. However, if the victim application links or authenticates accounts using the email claim inside AppleIdentityToken, or if multiple distinct applications belonging to the same Apple Developer Team trust AppleIdentityToken without checking aud, cross-application impersonation remains achievable. Furthermore, an attacker can always authenticate with their own provider account against an external client and replay the token to bypass client-restriction policies or forge an authenticated session on a backend that restricts access to specific first-party apps.
Successful exploitation grants high Confidentiality (C:H) and Integrity (I:H) impact within the scope of the compromised user account, allowing unauthorized reading and modification of application data. At the time of publication, the vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog and has an EPSS score of 0.00%.
Remediation requires both upgrading the Swift package dependency and updating application verification call sites to supply the expected audience parameter. Simply bumping the package version in Package.swift without modifying the verify function calls will result in compiler deprecation warnings and runtime log warnings, but will not enforce audience validation.
First, update Package.swift to require vapor/jwt-kit version 5.8.0 or higher (and vapor/jwt version 5.2.0 or higher if using the Vapor framework integration wrapper):
dependencies: [
.package(url: "https://github.com/vapor/jwt-kit.git", from: "5.8.0"),
.package(url: "https://github.com/vapor/jwt.git", from: "5.2.0")
]Second, update all calls to verify for AppleIdentityToken, GoogleIdentityToken, MicrosoftIdentityToken, and FirebaseAuthIdentityToken to pass the application's registered OAuth/OIDC client ID via expectedAudience or expectedAudiences:
// Vulnerable code (Deprecated in 5.8.0):
let appleToken = try await keys.verify(rawToken, as: AppleIdentityToken.self)
// Patched code enforcing single audience binding:
let appleToken = try await keys.verify(
rawToken,
as: AppleIdentityToken.self,
expectedAudience: "com.example.myservice"
)
// Patched code for Google hybrid mobile/backend flows enforcing azp:
let googleToken = try await keys.verify(
rawToken,
as: GoogleIdentityToken.self,
expectedAudience: "backend-server.apps.googleusercontent.com",
trustedAuthorizedPresenters: ["ios-client.apps.googleusercontent.com"]
)If an immediate upgrade to jwt-kit 5.8.0 is blocked by dependency constraints on the 4.x series, developers must implement an explicit audience check immediately after verifying the token signature and before trusting any identity claims:
// Workaround for vapor/jwt-kit < 5.8.0
let token = try await keys.verify(rawToken, as: AppleIdentityToken.self)
try token.audience.verifyIntendedAudience(includes: "com.example.myservice")> [!NOTE]
> When verifying multi-audience tokens, ensure that token.audience.value does not contain unrecognized audience strings in addition to your client ID. The JWTIdentityTokenValidation implementation in 5.8.0 enforces both inclusion of an expected audience and exclusion of any untrusted additional audiences.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
jwt-kit Vapor | >= 4.0.0, < 5.8.0 | 5.8.0 |
jwt Vapor | < 5.2.0 | 5.2.0 |
| Attribute | Detail |
|---|---|
| CVE ID | CVE-2026-142551 (GHSA-gxx9-vxm7-hgrq) |
| CWE Classification | CWE-287 (Improper Authentication) / CWE-345 |
| CVSS v3.1 Score | 8.1 High (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N) |
| Attack Vector | Network (Cross-Client OIDC ID Token Replay) |
| Affected Component | Vapor JWTKit (AppleIdentityToken, GoogleIdentityToken, MicrosoftIdentityToken) |
| Affected Versions | >= 4.0.0, < 5.8.0 |
| Patched Versions | vapor/jwt-kit 5.8.0, vapor/jwt 5.2.0 |
| Exploit & KEV Status | PoC Published / Not in CISA KEV |
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
GHSA-QMJC-65WP-7V34 documents a software supply-chain compromise targeting the Python Package Index (PyPI) package magique. Threat actors utilized stolen maintainer credentials to publish unauthorized phantom releases (versions 0.6.8 and 0.6.9) directly to PyPI on June 8, 2026. These distributions contain a malicious .pth path configuration file that automatically triggers an embedded JavaScript payload via the Bun runtime upon Python interpreter startup, resulting in credential theft, process memory scraping, and worm-like self-propagation.
CVE-2026-140231 is a memory exhaustion vulnerability in the node-tar package for Node.js prior to version 8.0.0. Because archive decompression lacks backpressure enforcement and zero-size archive entries queue in memory without upper bounds, an attacker who supplies a crafted compressed archive can force the host application to exhaust available resident memory and terminate via an Out-of-Memory (OOM) condition, bypassing existing decompression ratio checks.
CVE-2026-140230 (GHSA-xm6h-2993-3ch9) is an uncontrolled resource consumption vulnerability in the node-tar npm package (tar) prior to version 8.0.0. The flaw stems from asymmetric path depth validation during archive extraction: while entry.path is validated against a maximum segment depth (maxDepth = 1024), entry.linkpath is omitted from this check. When extracting a symbolic or hard link entry with a deeply nested linkpath defined via a GNU LongLink ('K') extended header, the PathReservations subsystem decomposes the path into every parent directory prefix, triggering quadratic O(N^2) string materialization in the V8 heap. A compressed archive as small as 181 bytes forces the Node.js runtime into an uncatchable fatal Out-Of-Memory (OOM) abort.
CVE-2026-141468 is a client-side script gadget vulnerability in the Bootstrap 6 pre-release Toggler plugin (versions >= 6.0.0-alpha.1, < 6.0.0-alpha.2). The plugin accepts untrusted attribute names via data-bs-attribute and values via data-bs-value, which standard HTML sanitizers such as DOMPurify preserve by default. Upon user click interaction, the Toggler._execute() method dynamically assigns these attributes using setAttribute() while only blocklisting the id attribute, allowing attackers to inject executable inline event handlers (CWE-79, CWE-83) or hijack form submission targets via the formaction attribute.
A path-reservation deadlock vulnerability exists in node-tar versions 7.5.22 through 7.5.24 on POSIX platforms. When an archive contains a hardlink or symbolic link entry whose linkpath is an ancestor or descendant of its own path, the internal PathReservations scheduling queue enters an unsatisfiable state. This causes asynchronous extraction operations to stall indefinitely without resolving or rejecting the extraction Promise, resulting in a persistent denial of service.
CVE-2026-140250 (GHSA-3wwj-8j6r-q339) is a high-severity symbolic link containment bypass and path traversal vulnerability in node-tar (npm package 'tar'), affecting versions 7.5.5 through 7.5.24. When extracting archives using default options, the Unpack class validates symbolic link targets using purely lexical path normalization. An attacker can supply a crafted archive containing chained symbolic links combined with directory traversal segments ('..') to create symbolic links that resolve outside the designated extraction directory. If the host application subsequently follows the created link, it can lead to arbitrary file disclosure or modification within the application's privilege context.