fix(contacts): sanitize company website href to block stored XSS #136
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/mapps-149-sanitize-website-href"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The company detail page rendered the user-supplied
websitevalue straight into an anchorhref, so a value likejavascript:alert(1)executed attacker-controlled script in the authenticated origin when clicked (stored XSS, token theft via sessionStorage). React-style text escaping does not cover URL values placed inhref.Add
safe_hreftoutils::url: it allowlists URL schemes (http,https,mailto) and rejectsjavascript:,data:,vbscript:and any other explicit scheme, ignoring case and embedded whitespace/control bytes that browsers strip before resolving the scheme. The company website now renders a live link only when the value passessafe_href, falling back to plain text otherwise, and thetarget="_blank"anchor gainsrel="noopener noreferrer"to close the reverse-tabnabbing gap.Unit tests cover the dangerous schemes, case/whitespace evasion, safe schemes, blank input, and scheme-less relative references.
#MAPPS-149