Moderate severity vulnerability that affects league/commonmark
Published 17 Sept 2019 · Updated 16 Feb 2024
Affected package
- Affected
- <0.18.3
- Fixed in
- 0.18.3
composer require league/commonmark:^0.18.3Details
CVE-2019-10010
Impact
In league/commonmark 0.18.2 and below, malicious users can insert double-encoded HTML entities into their Markdown like this:
[XSS](javascript&colon;alert%28'XSS'%29)
This library would (correctly) unescape the & entity to & during the parsing step. However, the renderer step would fail to properly re-escape the resulting : string, thus producing the following malicious HTML output:
<p><a href="javascript:alert('XSS')">XSS</a></p>Browsers would interpret : as a : character and allow the JS to be executed when the link is clicked.
This vulnerability was present in the upstream library this project was forked from and therefore exists in all prior versions of league/commonmark.
Solution
The new 0.18.3 release mirrors the fix made upstream - we no longer attempt to preserve entities when rendering HTML attributes like href, src, title, etc.
The $preserveEntities parameter of Xml::escape() is therefore no longer used internally, so it has been deprecated and marked for removal in the next major release (0.19.0).
Credits
- Mohit Fawaz for identifying the issue
- Sebastiaan Knijnenburg and Ross Tuck for responsibly disclosing/relaying the issue
- John MacFarlane for investigating it and implementing the upstream fix we mirrored here
References
- https://nvd.nist.gov/vuln/detail/CVE-2019-10010
- https://github.com/thephpleague/commonmark/releases/tag/0.18.3
- https://github.com/thephpleague/commonmark/issues/353
- https://github.com/FriendsOfPHP/security-advisories/blob/master/league/commonmark/CVE-2019-10010.yaml
Is GHSA-3v43-877x-qgmq in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected league/commonmark, and gives you the command that fixes it.
References
- Linkgithub.com/thephpleague/commonmark/security/advisories/GHSA-3v43-877x-qgmq
- Advisorynvd.nist.gov/vuln/detail/CVE-2019-10010
- Linkgithub.com/thephpleague/commonmark/issues/353
- Linkgithub.com/FriendsOfPHP/security-advisories/blob/master/league/commonmark/CVE-2019-10010.yaml
- Advisorygithub.com/advisories/GHSA-3v43-877x-qgmq
- Linkgithub.com/thephpleague/commonmark
- Linkgithub.com/thephpleague/commonmark/releases/tag/0.18.3
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.