GHSA-w74x-v6f9-j3xg: Medium severity npm/fast-uri vulnerability
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 Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/fast-urito a version that resolves this vulnerability.Fixed in 4.2.3 - Upgrade
Upgrade
npm/fast-urito a version that resolves this vulnerability.Fixed in 3.1.9 - Upgrade
Upgrade
npm/fast-urito a version that resolves this vulnerability.Fixed in 2.4.8 - Upgrade
Upgrade
fast-urito a version that resolves this vulnerability.Fixed in 2.4.8 - Compensating control
Reject input whose scheme portion—before the first ':', and before any '/', '?' or '#'—contains '%'.
Event History
Frequently Asked Questions
Which applications are realistically exposed to cross-site scripting from this issue?
Applications are exposed when they validate or block dangerous URL schemes on raw input, then store or render the output of fast-uri normalize() or resolve(). In that flow, an encoded scheme can become a live javascript:, data:, or vbscript: URL.
What input forms can trigger the scheme-validation bypass?
Percent-encoded scheme characters such as %6Aavascript: can be decoded into javascript:. The legacy %uXXXX form, such as %u006Aavascript:, has the same effect.
Can this bypass allowlists that compare URLs for equality?
Yes. fast-uri equal() can treat an encoded scheme and its plain equivalent as equal, as shown by %68ttp://a/ comparing equal to http://a/. Equality-based scheme or URL allowlists may therefore be bypassed.
What should be done to remediate the issue?
Upgrade fast-uri to version 2.4.8, 3.1.9, or 4.2.3.