You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A stored Cross-Site Scripting (XSS) vulnerability exists in the Markdown-to-HTML conversion process used in the Bookmark Description field in Shaarli. An authenticated user can inject a malicious javascript: URI inside a Markdown link. The payload is converted to HTML without proper sanitization and executed when a user clicks the rendered link on the homepage.
Details
The vulnerability originates in the filterProtocols method within BookmarkMarkdownFormatter.php.
This method attempts to sanitize Markdown links by filtering dangerous protocols (such as javascript:) before rendering. It uses the following regular expression: (#]\((.*?)\)#is). This regex is designed to detect inline Markdown links.
However, it fails to detect Markdown reference-style links, Because reference-style links are resolved by the Markdown parser after preprocessing, the filterProtocols method never inspects the actual URL used in these references. As a result, an attacker can supply a javascript: URI inside a reference definition. When the Markdown parser converts this to HTML, it generates a valid <a> tag with a malicious href attribute:
PoC
xss.in.shaarli.-.03.mp4
Steps to reproduce:
Log in to Shaarli.
Add a new link (Shaare).
Set any valid URL.
Set the Description field to:
[Click Me for XSS][1][1]: javascript:alert('XSS_MARKDOWN')
Save the bookmark.
Navigate to the homepage.
Click the "Click Me for XSS" link.
Observe that the JavaScript payload executes immediately.
Impact
Impacted Users:
Any user viewing bookmarks containing malicious Markdown descriptions
Administrators and privileged users are also affected
Potential Consequences:
Session hijacking
Account takeover
CSRF token theft
Unauthorized actions performed on behalf of the victim
Delivery of additional malicious client-side payloads
Because the vulnerability is stored and requires only a user click, it poses a significant risk in multi-user environments or shared instances.
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Learn more on MITRE.
Summary
A stored Cross-Site Scripting (XSS) vulnerability exists in the Markdown-to-HTML conversion process used in the Bookmark Description field in Shaarli. An authenticated user can inject a malicious
javascript:URI inside a Markdown link. The payload is converted to HTML without proper sanitization and executed when a user clicks the rendered link on the homepage.Details
The vulnerability originates in the
filterProtocolsmethod withinBookmarkMarkdownFormatter.php.This method attempts to sanitize Markdown links by filtering dangerous protocols (such as
javascript:) before rendering. It uses the following regular expression: (#]\((.*?)\)#is). This regex is designed to detect inline Markdown links.However, it fails to detect Markdown reference-style links, Because reference-style links are resolved by the Markdown parser after preprocessing, the
filterProtocolsmethod never inspects the actual URL used in these references. As a result, an attacker can supply ajavascript:URI inside a reference definition. When the Markdown parser converts this to HTML, it generates a valid<a>tag with a malicioushrefattribute:PoC
xss.in.shaarli.-.03.mp4
Steps to reproduce:
Impact
Impacted Users:
Potential Consequences:
Because the vulnerability is stored and requires only a user click, it poses a significant risk in multi-user environments or shared instances.