Leading white space bypasses protocol validation
The URI.js library does not strip leading whitespace from URLs before parsing, so protocol validation can be bypassed. An attacker could supply a URL with leading whitespace to evade checks that rely on the parsed protocol.
medialize/URI.js
Originally disclosed on huntr
Impact
Whitespace characters are not removed from the beginning of the protocol, so URLs are not parsed properly and protocol validation mechanisms may fail.
Patches
Patched in 1.19.9
Workarounds
Remove leading whitespace from values before passing them to URI.parse (e.g. via .href(value) or new URI(value)), e.g. by using
function remove_whitespace(url){
const whitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
url = url.replace(whitespace, '')
return url
}
References
For more information
If you have any questions or comments about this advisory:
- Open an issue in medialize/URI.js
From the GitHub Advisory Database (GHSA-gmv4-r438-p67f, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the parser does not trim leading whitespace characters before extracting the protocol, so the protocol is misidentified.
Impact
Protocol validation mechanisms may fail, potentially allowing bypass of security checks that rely on the parsed protocol.
What the attacker needed
Attacker can supply a URL with leading whitespace
The fix
The issue was fixed in version 1.19.9; as a workaround, remove leading whitespace from values before passing them to URI.parse.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A URL parser is supposed to clean up a web address before reading its parts. This library forgot to remove spaces at the start, so a check that looks at the protocol (like 'http' or 'javascript') can be fooled. That means a security filter might let through a dangerous link.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.