CVE-2024-21631: Github.com/vapor/vapor Vapor Contains An Integer Overflow Vulnerability

MODERATE
Advisory Identifier: GHSA-r6r4-5pr8-gjcp
CVSS 6.5
CWE-190 CWE-1104
Published
Advisory Summary

CVE-2024-21631 is a MODERATE (CVSS 6.5) vapor contains an integer overflow vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Github.com/vapor/vapor libraries in the SwiftURL ecosystem. The issue involves vapor contains an integer overflow in uri leading to potential host spoofing. Remediation is available by upgrading affected packages to version 4.90.0.

CVE-2024-21631 at a Glance

CVE Identifier CVE-2024-21631
GHSA Identifier GHSA-r6r4-5pr8-gjcp
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product Github.com/vapor/vapor
Package Ecosystem SwiftURL
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2024-21631

To remediate this vulnerability, upgrade all affected Github.com/vapor/vapor dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/vapor/vapor fixed: 4.90.0
Upgrade github.com/vapor/vapor to 4.90.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/vapor/vapor

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-21631, inspect your project dependencies for Github.com/vapor/vapor:

inspect dependencies for github.com/vapor/vapor

Analyze the terminal output to locate any version of Github.com/vapor/vapor in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.90.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. In Github.com/vapor/vapor, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Vapor's `vapor_urlparser_parse` function uses `uint16_t` 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.

CVE-2024-21631 Affected Github.com/vapor/vapor Versions

1 component(s)
Fixed Versions:
4.90.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/vapor/vapor
SwiftURL
< 4.90.0
4.90.0

References

Frequently Asked Questions

What is CVE-2024-21631?
CVE-2024-21631 is a security vulnerability in Github.com/vapor/vapor involving Vapor contains an integer overflow in URI leading to potential host spoofing under CWE-190: Integer Overflow or Wraparound.
Which Github.com/vapor/vapor versions are affected?
Affected versions include releases prior to 4.90.0 across affected packages: github.com/vapor/vapor.
What version fixes CVE-2024-21631?
Upgrading to 4.90.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/vapor/vapor affected?
Yes, github.com/vapor/vapor is affected in releases prior to 4.90.0. Upgrade your dependency to 4.90.0 or later.
What is the CVSS score of CVE-2024-21631?
CVE-2024-21631 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2024-21631?
CVE-2024-21631 is classified under CWE-190: Integer Overflow or Wraparound (The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.).
How can I check SwiftURL dependencies for CVE-2024-21631?
Run the dependency tree command: 'inspect dependencies for github.com/vapor/vapor'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-r6r4-5pr8-gjcp",
  "modified" : "2024-02-09T00:29:14Z",
  "published" : "2024-01-03T21:44:35Z",
  "aliases" : [ "CVE-2024-21631" ],
  "summary" : "Vapor contains an integer overflow in URI leading to potential host spoofing",
  "details" : "Vapor's `vapor_urlparser_parse` function uses `uint16_t` indexes when parsing a URI's components, which may cause integer overflows when parsing untrusted inputs.\n\nThis vulnerability does not affect Vapor directly but could impact applications relying on the URI type for validating user input. \n\nThe 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.\n\nBy 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.\n\n### Impact\nUsers attempting to treat untrusted input as a URI are vulnerable to a host spoofing attack due to an integer overflow.\n\n### Workarounds\nValidate user input before parsing as a URI or, if possible, use Foundation's `URL` and `URLComponents` utilities.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "SwiftURL",
      "name" : "github.com/vapor/vapor"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.90.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.89.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/vapor/vapor/security/advisories/GHSA-r6r4-5pr8-gjcp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-21631"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vapor/vapor/commit/6db3d917b5ce5024a84eb265ef65691383305d70"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/vapor/vapor"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1104", "CWE-190" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-01-03T21:44:35Z",
    "nvd_published_at" : "2024-01-03T17:15:12Z"
  }
}