Packages / fast-uri / Security
fast-uri vulnerable to scheme injection via an unescaped first-segment colon in suffix references
Affected releases · fast-uri
- 4.x4.0.0 – 4.2.2Fixed in 4.2.3
- 3.x3.0.0 – 3.1.8Fixed in 3.1.9
- 2.x2.0.0 – 2.4.7Fixed in 2.4.8
- 1.x and older0.0.1 – 1.0.1No fix, no longer updated
On 4.x, the newest line:
npm install fast-uri@4.2.3Every release on a timeline
Affected
4.0.0 – 4.2.2
11 releases
Fixed
4.2.3
1 release, latest
Affected
3.0.0 – 3.1.8
16 releases
Fixed
3.1.9
1 release
Affected
2.0.0 – 2.4.7
13 releases
Fixed
2.4.8
1 release
Affected
1.0.0 – 1.0.1
2 releases
Affected
0.0.1 – 0.0.2
2 releases
What happens
Impact
fast-uri's serialize(), normalize(), and resolve(), when called with the non-default option reference: 'suffix' on a reference that has no authority, emit a relative reference whose first path segment contains a bare colon without escaping it. RFC 3986 section 3.3 requires the first segment of a path-noscheme reference not to contain a colon, precisely because a bare colon makes the string reparse as an absolute URI with a scheme. fast-uri's default serialization escapes that colon, but the suffix path does not.
For example, normalize('javascript:alert(1)', { reference: 'suffix' }) returns javascript:alert(1), which reparses as a live javascript: scheme; data: and vbscript: behave the same.
Applications that serialize or normalize a relative reference with reference: 'suffix' and then treat the result as a URI can turn inert input into a live javascript:, data:, or vbscript: URL (a cross-site scripting vector), and equal() can conflate a scheme-bearing reference with a relative one. Exposure is limited to applications that use the non-default reference: 'suffix' option.
Patches
Upgrade to fast-uri 2.4.8, 3.1.9, or 4.2.3.
Workarounds
Do not use the reference: 'suffix' option on untrusted input. If suffix output is required, percent-encode a colon in the first path segment of the result before treating it as a URI.
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.