6.5medium
Integer overflow in URI leading to potential host spoofing
- Severity
- 6.5medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.60% (higher than 50% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-r6r4-5pr8-gjcp
Description
Vapor is an HTTP web framework for Swift. Prior to version 4.90.0, 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 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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| vapor vapor | < 4.90.0, before 4.90.0, from pkg:swift/github.com/vapor/vapor@0 before pkg:swift/github.com/vapor/vapor@4.90.0 | CVE List, NVD |
| github.com/vapor/vapor (SwiftURL) | before 4.90.0 | GitHub Advisory Database |
All scores
| GitHub_M | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N |
| GitHub | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N |
| NVD | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N |
Classification
What each source says
CVE List
Vapor is an HTTP web framework for Swift. Prior to version 4.90.0, 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 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.
GitHub Advisory Database
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.
NVD (es)
Vapor es un framework web HTTP para Swift. Antes de la versión 4.90.0, la función `vapor_urlparser_parse` de Vapor utiliza índices `uint16_t` al analizar los componentes de un URI, lo que puede causar desbordamientos de enteros al analizar entradas que no son de confianza. Esta vulnerabilidad no afecta a Vapor directamente, pero podría afectar a las aplicaciones que dependen del tipo de URI para validar la entrada del usuario. El tipo URI se utiliza en varios lugares de Vapor. Un desarrollador puede decidir utilizar URI para representar una URL en su aplicación (especialmente si esa URL luego se pasa al Cliente HTTP) y confiar en sus propiedades y métodos públicos. Sin embargo, es posible que el URI no pueda analizar correctamente una URL válida (aunque anormalmente larga), debido a que los rangos de cadenas se convierten a enteros de 16 bits. Un atacante puede utilizar este comportamiento para engañar a la aplicación para que acepte una URL a un destino que no es de confianza. Al rellenar el número de puerto con ceros, un atacante puede provocar un desbordamiento de enteros cuando se analiza la autoridad de la URL y, como resultado, falsificar el host. La versión 4.90.0 contiene un parche para este problema. Como workaround, valide la entrada del usuario antes de analizarla como URI o, si es posible, utilice las utilidades `URL` y `URLComponents` de Foundation.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-21631 changed 2024-09-18 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-r6r4-5pr8-gjcp changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2024-21631 changed 2026-06-17 | Public domain |