CVE-2018-20583 - XSS Vulnerability #669
Locked
colinodell
announced in
Announcements
Replies: 1 comment
-
This issue has been fixed in version 0.18.1. All users should upgrade to version 0.18.1 immediately. Please refer to the revised description above (#337) for a full description of this issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
An XSS vulnerability (CVE-2018-20583) has been identified in the following versions of this library:
It allows unsafe URLs to be added to links.
The issue has been fixed in version 0.18.1. All users should upgrade to version 0.18.1 immediately. Additionally, if your application caches the resulting HTML, please purge and/or regenerate those caches.
Summary
Malicious users can bypass the "unsafe links" restrictions by inserting an encoded newline character (
%0A
) into the URL's protocol like so:Certain versions of this library would decode, then fail to re-encode, that newline, resulting in the following HTML:
Browsers ignore the newline and see
javascript:
instead ofjavascri
+\n
+pt
, thus allowing the JS to execute when the link is clicked.Impact
Specially-crafted Markdown links can be created which, when clicked, would execute JavaScript in the browser.
Setting the
allow_unsafe_links
option tofalse
, as recommended in the security documentation, would not have prevented this behavior in the affected versions.Details
The URL normalization process basically runs
rawurlencode(rawurldecode($url))
to make sure that everything that everything is properly encoded. When we implemented #287 (via commit 7d91ca0), the regex on line 85 would fail to match newline characters because thes
regex modifier was missing. As a result, if you fed it a URL containing%0a
, it basically:%0a
to a newline character (\n
) during thedecode()
step%0a
during theencode()
stephref
attribute with the\n
newline in the middle of itAdding the
s
modifier to that regular expression fixes step 2 and ensures that all newlines in a URL are always properly encoded.Credits
A huge thank you to Austin H. for finding the issue and working with @GrahamCampbell to responsibly disclose it!
Beta Was this translation helpful? Give feedback.
All reactions