CVE-2024-21631: Integer overflow in URI leading to potential host spoofing

Published Jan 3, 2024
·
Updated

Vapor is an HTTP web framework for Swift. Prior to version 4.90.0, Vapor's vaporurlparserparse function uses uint16t indexes when parsing a URI's components, which may cause integer overflows when parsing untrusted inputs. This vulnerability does not affect Vapor directly but could impact applications relying on the URI type for validating user input. The URI type is used in several places in Vapor. A developer may decide to use URI to represent a URL in their application (especially if that URL is then passed to the HTTP Client) and rely on its public properties and methods. However, URI may fail to properly parse a valid (albeit abnormally long) URL, due to string ranges being converted to 16-bit integers. An attacker may use this behavior to trick the application into accepting a URL to an untrusted destination. By padding the port number with zeros, an attacker can cause an integer overflow to occur when the URL authority is parsed and, as a result, spoof the host. Version 4.90.0 contains a patch for this issue. As a workaround, validate user input before parsing as a URI or, if possible, use Foundation's URL and URLComponents utilities.

Other sources

Vapor's vaporurlparserparse function uses uint16t indexes when parsing a URI's components, which may cause integer overflows when parsing untrusted inputs.

This vulnerability does not affect Vapor directly but could impact applications relying on the URI type for validating user input.

The URI type is used in several places in Vapor. A developer may decide to use URI to represent a URL in their application (especially if that URL is then passed to the HTTP Client) and rely on its public properties and methods. However, URI may fail to properly parse a valid (albeit abnormally long) URL, due to string ranges being converted to 16-bit integers. An attacker may use this behaviour to trick the application into accepting a URL to an untrusted destination.

By padding the port number with zeros, an attacker can cause an integer overflow to occur when the URL authority is parsed and, as a result, spoof the host.

Impact Users attempting to treat untrusted input as a URI are vulnerable to a host spoofing attack due to an integer overflow.

Workarounds Validate user input before parsing as a URI or, if possible, use Foundation's URL and URLComponents utilities.

— GitHub

Affected Software

2 affected componentsFixes available
swift/github.com/vapor/vapor<=4.89.3
4.90.0
Vapor Vapor<4.90.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

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

    Fixed in 4.90.0
  2. Upgrade

    Upgrade vapor to a version that resolves this vulnerability.

    Fixed in 4.90.0
  3. Configuration

    Before treating user-supplied data as a URI, validate it first; if possible, use Foundation `URL` and `URLComponents` rather than parsing untrusted strings as Vapor URI/authority components.

    URI/URL parsing in application URI parsing validation strategy = Validate user input before parsing as a URI; where possible use Foundation's `URL` and `URLComponents` utilities instead of directly parsing with Vapor's URI handling

Event History

Jan 3, 2024
CVE Published
04:55 PM
Data Sourced
04:55 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·09:44 PM
Data Sourced
via GitHub·09:44 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-21631?

CVE-2024-21631 has not been assigned a specific CVSS score, but it poses a moderate risk due to potential integer overflows.

2

How do I fix CVE-2024-21631?

To fix CVE-2024-21631, update to Vapor version 4.90.0 or later.

3

Which versions of Vapor are affected by CVE-2024-21631?

CVE-2024-21631 affects Vapor versions before 4.90.0, including 4.89.3 and earlier.

4

What causes CVE-2024-21631?

CVE-2024-21631 is caused by the use of uint16_t indexes in the vapor_urlparser_parse function leading to possible integer overflows.

5

Who is impacted by CVE-2024-21631?

Applications relying on the URI type in Vapor for validating untrusted inputs may be impacted by CVE-2024-21631.

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