Skip to content

GHSA-w74x-v6f9-j3xg CVE-2026-110306

fast-uri vulnerable to URI scheme spoofing via percent-encoded scheme decoding

Medium npm
Severity
6.1 / 10
Medium · CVSS 3.1
Exploit chance (EPSS)
0.25%
Chance of exploitation in the next 30 days. Higher than 16.36% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-172 Encoding Error
CWE-180 Incorrect Behavior Order: Validate Before Canonicalize
Fix
2.4.8
Upgrade fast-uri to this version or later

Description

Impact

fast-uri percent-decodes the scheme component with the legacy global unescape() before validating it, so an input whose decoded scheme is a valid but dangerous token is emitted as a live scheme. RFC 3986 section 3.1 does not allow percent-encoding in a scheme, so no RFC or WHATWG parser treats such input as having that scheme, but fast-uri does.

For example, normalize('%6Aavascript:alert(1)') returns javascript:alert(1), resolve('https://a.example/', '%6Aavascript:alert(1)') returns javascript:alert(1), and parse('%6Aavascript:alert(1)').scheme returns javascript. The %uXXXX form (%u006Aavascript:) produces the same result, and equal('%68ttp://a/', 'http://a/') returns true.

An application that screens dangerous schemes on the raw input and then stores or renders normalize(input) or resolve(base, input) turns an inert string into an executable javascript:, data:, or vbscript: URL, a stored or reflected cross-site scripting vector in the consuming application. equal() also treats an encoded and a plain scheme as the same, which can bypass equality-based allowlists.

Patches

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

Workarounds

Reject input whose scheme part (before the first :, and before any /, ?, or #) contains %. Alternatively, check parse(x).scheme against an allowlist after normalization and use that same parsed result rather than the raw string.

Affected versions

npm

PackageVulnerableFixed in
fast-uri
< 2.4.8
2.4.8
fast-uri
>= 3.0.0, < 3.1.9
3.1.9
fast-uri
>= 4.0.0, < 4.2.3
4.2.3
fast-uri
< 2.4.8
2.4.8
fast-uri
>= 3.0.0, < 3.1.9
3.1.9
fast-uri
>= 4.0.0, < 4.2.3
4.2.3

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

fast-uri npm → 2.4.8

npm
npm install fast-uri@2.4.8
yarn
yarn add fast-uri@2.4.8
pnpm
pnpm add fast-uri@2.4.8

Severity breakdown

CVSS 3.1 6.1

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

Weakness

CWE-172: Encoding Error

The product does not properly encode or decode the data, resulting in unexpected values.

How to prevent it
  • Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
  • Implementation: While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).
  • Implementation: Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.

CWE-180: Incorrect Behavior Order: Validate Before Canonicalize

The product validates input before it is canonicalized, which prevents the product from detecting data that becomes invalid after the canonicalization step.

How to prevent it
  • Implementation: Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-333x-w4r6-6crp
fast-uri vulnerable to scheme injection via an unescaped first-segment colon in suffix references
Low Also affects fast-uri
GHSA-wjr9-j795-jxcr
fast-uri vulnerable to host confusion via unchecked WHATWG host canonicalization
Medium Also affects fast-uri
GHSA-xhq7-xmqj-769h
fast-uri vulnerable to improper path equivalence in relative reference normalization
Low Also affects fast-uri
GHSA-jvvf-x445-j334
fast-uri vulnerable to mailto header injection via percent-encoded field-name desynchronization
Medium Also affects fast-uri
GHSA-hrr3-gc8f-f4qj
fast-uri vulnerable to inconsistent host case normalization via percent-encoded octets
Medium Also affects fast-uri
GHSA-58mr-gqgx-xq4g
fast-uri vulnerable to host confusion via an unclosed bracket in the URI authority
High Also affects fast-uri
GHSA-qw65-cvwx-89v3
fast-uri vulnerable to authority injection via an unvalidated port in serialize
High Also affects fast-uri
GHSA-jqff-g426-hqxp
fast-uri vulnerable to host confusion via percent-encoded scheme normalization
High Also affects fast-uri

Credits: UlisesGascon, mcollina

Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor