fast-uri@4.0.1

Dependency-free RFC 3986 URI toolbox

  • latest version

    4.2.3

  • latest non vulnerable version

  • first published

    4 years ago

  • latest version published

    18 days ago

  • licenses detected

  • Direct Vulnerabilities

    Known vulnerabilities in the fast-uri package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • M
    Path Equivalence

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Path Equivalence via the serialize() / normalize() functions, which incorrectly applied RFC 3986 remove_dot_segments to relative-path references. That algorithm is defined only for merged target paths, not for relative references themselves, so normalizing a relative path such as a/../b produced /b (root-relative), x/.. produced /, and ../x produced x. An attacker who can supply a relative URI reference can cause it to resolve to a different resource than intended after normalization, enabling path-traversal-style target substitution.

    How to fix Path Equivalence?

    Upgrade fast-uri to version 2.4.8, 3.1.9, 4.2.3 or higher.

    <2.4.8>=3.0.0 <3.1.9>=4.0.0 <4.2.3
    • M
    Improper Validation of Specified Quantity in Input

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Improper Validation of Specified Quantity in Input via canonicalizeHost(), which passes the host directly to new URL('http://' + host) without verifying that the WHATWG parser consumed the entire input as a host. Because the RFC 3986 parser permits @ in the host component, and the WHATWG parser silently strips TAB, LF, and CR, an attacker can supply a URI whose authority is rewritten by the second parser with no error. This allows host spoofing across parse(), normalize(), equal(), and resolve() - for example, parse('http://a@b@evil.com/').host returns 'evil.com' and normalize('http://ev\til.com/p') returns 'http://evil.com/p'.

    How to fix Improper Validation of Specified Quantity in Input?

    Upgrade fast-uri to version 2.4.8, 3.1.9, 4.2.3 or higher.

    >=2.4.2 <2.4.8>=3.1.3 <3.1.9>=4.0.1 <4.2.3
    • M
    Encoding Error

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Encoding Error via the decodeValidScheme function, which decoded percent-encoded URI schemes using the deprecated unescape() global (including the JavaScript-only %uXXXX form) before validating them. An attacker can supply a percent-encoded scheme such as %6Aavascript:alert(1) or %u006Aavascript:alert(1), causing normalize() to return a live javascript: URI, resolve() to produce a javascript: URL, and equal() to treat the encoded form as equivalent to the decoded scheme. This enables scheme-confusion attacks, most notably cross-site scripting when the resulting URI is used in a browser navigation or href context.

    How to fix Encoding Error?

    Upgrade fast-uri to version 2.4.8, 3.1.9, 4.2.3 or higher.

    <2.4.8>=3.0.0 <3.1.9>=4.0.0 <4.2.3
    • M
    Path Equivalence

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Path Equivalence via the serialize(), normalize(), and resolve() functions when called with the non-default option reference: 'suffix' on a reference that has no authority. A bare colon in the first path segment of the emitted relative reference is not escaped, violating RFC 3986 section 3.3/4.2, which causes the output to reparse as an absolute URI with a scheme rather than a relative reference. An attacker who can influence the URI being serialized can exploit this to inject an unintended scheme into the output.

    Note: This is only exploitable when the non-default reference: 'suffix' option is explicitly passed to serialize(), normalize(), or resolve().

    How to fix Path Equivalence?

    Upgrade fast-uri to version 2.4.8, 3.1.9, 4.2.3 or higher.

    <2.4.8>=3.0.0 <3.1.9>=4.0.0 <4.2.3
    • M
    Improper Handling of Case Sensitivity

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Improper Handling of Case Sensitivity due to inconsistent normalization in the host component. An attacker can gain unauthorized access to restricted resources or services by submitting a specially crafted URI containing percent-encoded uppercase characters, which may bypass host allowlists or denylists in applications relying on case-sensitive host validation.

    How to fix Improper Handling of Case Sensitivity?

    Upgrade fast-uri to version 2.4.7, 3.1.8, 4.1.5 or higher.

    <2.4.7>=3.0.0 <3.1.8>=4.0.0 <4.1.5
    • H
    Improper Encoding or Escaping of Output

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Improper Encoding or Escaping of Output that enables authority injection in the recomposeAuthority function, which escapes the userinfo and host components but concatenates the port field verbatim, so non-digit characters in the port introduce authority delimiters. An attacker can restructure the URI to redirect requests to a server they control by supplying a port value such as @127.0.0.1:8124, which demotes the legitimate host to userinfo and yields http://trusted.example:@127.0.0.1:8124/app. This requires the application to build URIs from separate components and assign untrusted data directly to the port field of an object passed to serialize(), normalize(), or equal(), and ports obtained via parse() are unaffected because parsing validates digit-only values.

    How to fix Improper Encoding or Escaping of Output?

    Upgrade fast-uri to version 2.4.6, 3.1.7, 4.1.4 or higher.

    <2.4.6>=3.0.0 <3.1.7>=4.0.0 <4.1.4
    • H
    Double Decoding of the Same Data

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Double Decoding of the Same Data through hostname normalization in normalize() and resolve() and the authority recomposition logic in index.js and lib/utils.js. An attacker can redirect an application to an unintended host by supplying a URI whose hostname contains nested percent-encoded bytes, such as an encoded loopback or metadata address. The parser decodes the hostname once during normalization and then decodes it again when rebuilding the authority, so %25 sequences can turn into live host delimiters or dot characters during processing. Applications that normalize or resolve untrusted URIs before SSRF checks, redirect validation, or host allowlisting can be steered to internal destinations like localhost or a cloud metadata endpoint.

    Workarounds

    • Reject untrusted URIs whose host component contains an encoded percent sign (%25) before passing them to normalize() or resolve(). This prevents nested percent-encoded hostnames from being decoded into live internal destinations such as loopback or metadata addresses.

    How to fix Double Decoding of the Same Data?

    Upgrade fast-uri to version 2.4.5, 3.1.6, 4.1.3 or higher.

    >=2.4.1 <2.4.5>=3.1.2 <3.1.6>=4.0.0 <4.1.3
    • H
    Improper Validation of Syntactic Correctness of Input

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Improper Validation of Syntactic Correctness of Input through the normalizeIPv6() and parseWithStatus() host-processing paths in lib/utils.js and index.js. An attacker can route an application to a local or private address by supplying a malformed bracketed IPv6 literal such as http://[::not-valid]/private before the URL is normalized or checked. The parser accepts the malformed host without an error and silently rewrites it into a different valid IPv6 address, so downstream redirect handling, outbound requests, or host allowlist checks operate on the wrong destination. This can send traffic to loopback, unique-local, or link-local targets and expose internal services to unintended requests.

    Workarounds

    • Reject untrusted URLs whose host is a bracketed IPv6 literal before passing them to fast-uri; this prevents malformed IPv6 text from being normalized into a different valid local or private address.
    • Route outbound requests against an explicit allowlist of addresses instead of trusting the normalized host; this limits the impact if a malformed bracketed IPv6 literal is supplied.

    How to fix Improper Validation of Syntactic Correctness of Input?

    Upgrade fast-uri to version 2.4.5, 3.1.6, 4.1.3 or higher.

    >=2.3.1 <2.4.5>=3.0.0 <3.1.6>=4.0.0 <4.1.3
    • H
    Improper Handling of URL Encoding (Hex Encoding)

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Improper Handling of URL Encoding (Hex Encoding) through the parseWithStatus, normalizeStringWithStatus, normalizeComparableURI, and resolve paths in index.js. An attacker can steer a URL normalizer or resolver to an attacker-chosen host by supplying a URI whose scheme decodes into reserved delimiter characters, such as %2f%2fevil.example:/pwn, causing normalize() or resolve() to emit a string that reparses with a different authority. This lets untrusted input bypass host-based redirect checks, allowlists, or outbound request decisions when applications trust the normalized result. A scheme containing encoded CRLF can also be serialized back as raw line breaks, which can corrupt a URI placed into a response header.

    How to fix Improper Handling of URL Encoding (Hex Encoding)?

    Upgrade fast-uri to version 2.4.5, 3.1.6, 4.1.3 or higher.

    >=2.3.1 <2.4.5>=3.0.0 <3.1.6>=4.0.0 <4.1.3
    • H
    Interpretation Conflict

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Interpretation Conflict in resolve() through the resolve() process in index.js. An attacker can make an application resolve a scheme-relative reference such as //host/ against a scheme-bearing base and receive a host string that does not match the host produced when the result is parsed again. This lets policy checks or routing decisions operate on one host while the resolved URI actually points at another, which can bypass host allowlists and send the user to an unexpected destination.

    Workarounds

    • Resolve scheme-relative references against a base URI that already includes a scheme before any host-policy or origin check, so the host is evaluated in its final scheme context and cannot be checked under one interpretation and used under another.

    How to fix Interpretation Conflict?

    Upgrade fast-uri to version 2.4.5, 3.1.6, 4.1.3 or higher.

    >=2.4.2 <2.4.5>=3.1.3 <3.1.6>=4.0.1 <4.1.3
    • H
    Interpretation Conflict

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Interpretation Conflict due to malformed authority introducer handling in parseWithStatus() and resolve() in index.js. An attacker can bypass host-based URL checks and steer requests to an unintended host by supplying a URI that uses \\, /\\, or \\/ in place of // after the scheme. The parser folds those sequences into the path instead of recognizing an authority, while Node’s WHATWG URL treats them as a real authority on special schemes such as http, https, ws, wss, ftp, and file. Applications that validate a URL with fast-uri and then pass the same input to fetch(), undici, or Node’s HTTP clients can be sent to an attacker-controlled destination, enabling SSRF, redirect bypass, or outbound routing abuse.

    How to fix Interpretation Conflict?

    Upgrade fast-uri to version 2.4.4, 3.1.5, 4.1.2 or higher.

    <2.4.4>=3.0.0 <3.1.5>=4.0.0 <4.1.2
    • H
    Interpretation Conflict

    fast-uri is a Dependency-free RFC 3986 URI toolbox

    Affected versions of this package are vulnerable to Interpretation Conflict via literal backslash handling in parseWithStatus in index.js. An attacker can bypass host-based validation by supplying a URI such as http://evil.com\@allowed.com, causing fast-uri to treat the input as an allowed host while Node’s WHATWG URL parser resolves it to a different destination. This breaks SSRF, redirect, and origin allowlist checks, letting requests be steered to unintended internal, loopback, or metadata endpoints.

    Notes

    • The mismatch matters anywhere the same URI string is parsed by fast-uri for policy and then handed to Node consumers that use WHATWG parsing, including fetch(), undici, and Node http/https clients.

    How to fix Interpretation Conflict?

    Upgrade fast-uri to version 2.4.3, 3.1.4, 4.1.1 or higher.

    >=2.3.1 <2.4.3>=3.0.0 <3.1.4>=4.0.0 <4.1.1