CVE-2026-142550: JWTKit: Unauthenticated denial of service when parsing malicious JWT headers

Published Dec 2, 2026
·
Updated

Summary JWTKit can crash while parsing a JWT header containing an extremely large integer value.

When decoding header fields, the library parses JSON numbers as Double and converts integral values to Int without checking whether the value fits into the valid Int range. A header containing a value such as 1e300 causes a Swift runtime trap.

Because JWT headers are parsed before signature verification, an attacker can crash the application by sending a specially crafted JWT without requiring a valid signature.

Details JWTKeyCollection.verify() parses the JWT header before selecting a signer and verifying the token signature.

The header is decoded by JWTParser.parseHeader(), which deserializes the JSON into JWTHeader. During this process, JWTHeaderField.init(from:) decodes JSON numbers as Double and converts integral values to Int without validating that they fit within the representable Int range:

let doubleValue = try container.decode(Double.self) if doubleValue.truncatingRemainder(dividingBy: 1) == 0 { self = .int(Int(doubleValue)) }

An attacker can supply an extremely large integral value (for example, 1e300), causing the Int(doubleValue) conversion to trigger a Swift runtime trap. Because this occurs while parsing the JWT header, the application crashes before signature verification.

Affected code:

Sources/JWTKit/JWTKeyCollection.swift (verify() - parseHeader()) Sources/JWTKit/JWTParser.swift (parseHeader()) Sources/JWTKit/JWTHeaderField.swift (JWTHeaderField.init(from:) unchecked Double - Int conversion)

PoC

The following code reproduces the issue through the public JWT verification API:

import JWTKit

let keys = JWTKeyCollection() let token = """ eyJhbGciOiJIUzI1NiIsIngiOjFlMzAwfQ.eyJzdWIiOiIxMjMifQ.invalid """

do { struct Payload: JWTPayload { let sub: String

func verify(using algorithm: some JWTAlgorithm) async throws {} }

= try await keys.verify(token, as: Payload.self)

print("Unexpected success") } catch { print("JWT error:", error) } Result:

Fatal error: Double value cannot be converted to Int because the result would be greater than Int.max

Example stack trace:

JWTHeaderField.init(from:) JWTParser.parseHeader(:) JWTKeyCollection.verify(:as:) Processing a JWT containing this header causes the application to crash while parsing the header, before the signature is verified.

Impact A remote unauthenticated attacker can cause a denial of service by sending a specially crafted JWT. No valid signature or knowledge of the signing key is required because the crash occurs before signature verification.

Recommendations

Validate numeric values before converting Double to Int in JWTHeaderField.init(from:).

The conversion should only be performed when the value is finite and within the valid Int range. Values outside this range should result in a decoding error instead of triggering a runtime trap.

Alternatively, decode JSON integer values directly as Int first and only use Double for non-integer numeric values to avoid unsafe floating-point conversions. This ensures malformed JWT headers are rejected safely before signature verification.

Other sources

JWTKit is a Swift library for signing and verifying JSON Web Tokens. Prior to 5.8.0, JWTKeyCollection.verify() in Sources/JWTKit/JWTKeyCollection.swift parses the JWT header using JWTParser.parseHeader() in Sources/JWTKit/JWTParser.swift before selecting a signer and verifying the signature. During parsing, JWTHeaderField.init(from:) in Sources/JWTKit/JWTHeaderField.swift decodes JSON numbers as Double and converts integral values to Int without checking the representable range. A remote unauthenticated attacker can provide an extremely large integral header value that triggers a Swift runtime trap and crashes the application without a valid signature or knowledge of the signing key. This issue is fixed in version 5.8.0.

— MITRE

Affected Software

3 affected componentsFixes available
Vapor JWTKit<5.8.0
swift/github.com/vapor/jwt-kit<=5.7.1
5.8.0
swift/github.com/vapor/jwt-kit<5.8.0
5.8.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade swift/github.com/vapor/jwt-kit to a version that resolves this vulnerability.

    Fixed in 5.8.0
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 5.8.0

Event History

Dec 2, 2026
CVE Published
via MITRE·08:52 PM
Data Sourced
via MITRE·08:52 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:18 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·10:08 PM
Data Sourced
via GitHub·10:08 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via OSV·10:08 PM
Affected Software

Frequently Asked Questions

1

Which applications are exposed to this issue?

Applications using Vapor JWTKit versions earlier than 5.8.0 are exposed if they call JWTKeyCollection.verify() on JWTs supplied by remote clients. The vulnerable header parsing occurs before signer selection and signature verification.

2

Does an attacker need a valid JWT or signing key?

No. An unauthenticated remote attacker can trigger the crash with a malicious JWT header containing an extremely large integral value; no valid signature or signing-key knowledge is required.

3

What is the impact of successful exploitation?

The malformed header can cause a Swift runtime trap while converting an integral JSON value to Int, crashing the application. The stated impact is denial of service.

4

How can this be remediated?

Upgrade Vapor JWTKit to version 5.8.0, which fixes the issue.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203