Packages / fast-uri / Security
fast-uri vulnerable to host confusion via percent-encoded scheme normalization
Affected releases · fast-uri
- 4.x4.0.0 – 4.1.2Fixed in 4.1.3
- 3.x3.0.0 – 3.1.5Fixed in 3.1.6
- 2.x2.3.1 – 2.4.4Fixed in 2.4.5
On 4.x, the newest line:
npm install fast-uri@4.1.3Every release on a timeline
Affected
4.0.0 – 4.1.2
5 releases
Fixed
4.1.3 – 4.2.3
7 releases, latest
Affected
3.0.0 – 3.1.5
13 releases
Fixed
3.1.6 – 3.1.9
4 releases
Not affected
2.0.0 – 2.3.0
4 releases
Affected
2.3.1 – 2.4.4
6 releases
Fixed
2.4.5 – 2.4.8
4 releases
What happens
Impact
fast-uri decodes percent-encoded characters in the scheme component with the legacy global unescape() and serializes the result back as raw characters, without re-escaping it or validating it as a scheme. A scheme that decodes to characters outside the RFC 3986 scheme grammar can therefore introduce structure the original input did not contain.
For example, %2f%2fevil.example:/pwn parses with no authority (parse().host is undefined), but resolve() and normalize() return //evil.example:/pwn, which reparses with host evil.example. The %uXXXX form (%u002f%u002fevil.example:/pwn) produces the same result, and a scheme containing %0d%0a reaches the output as a raw CR LF.
Applications that normalize or resolve untrusted URLs before a redirect check, host allowlist, or outbound request decision, especially ones that treat a missing authority as same-origin, can be steered to an attacker-chosen authority, and a normalized URI placed in a response header can carry an injected CR LF.
Patches
Upgrade to fast-uri >= 4.1.3, or >= 3.1.6 in the v3.x release line, or >= 2.4.5 in the v2.x release line.
Workarounds
None. Upgrade to the patched version.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.