In markdown, parsing things like @danlec and #46072 after links is unsafe
Markdown parsing adds links for user mentions and submission references after the initial markdown is processed, so these links can be injected inside the attribute values of existing links. This produces malformed HTML with unexpected attributes, though the author has not worked out an actual exploit.
- Triaged in 26 hours
- Fixed in 6 days
- Disclosed after 5 months
(Let me preface this by saying that I haven't worked out an actual exploit for this, and there may not be one, but when #46072 is disclosed, folks will probably be taking a closer look at HackerOne's markdown parsing and may find a way to turn this bug into something)
It looks like the links for things like @danlec and #46072 are being added to the HTML after the initial markdown is processed; this leads to situations where links end up malformed because link markup is being added in an unexpected place (inside the attribute values of existing links)
For example:
[text](http://danlec.com " @danlec ")
renders as
i.e.
<p><a title=" <a href=" danlec"="">@danlec</a> " href="http://danlec.com">text</p>
As you can see, there's an unexpected danlec" attribute on the link tag.
The same kind of issue exists for references to other submissions, e.g.
[text](http://danlec.com " #46072 ")
renders as
<p><a title=" <a href=" reports="" 46072"="">#46072</a> " href="http://danlec.com">text</p>
… with an unexpected reports and 46072" attribute
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 mention and reference linkification runs as a post-processing step on already-rendered HTML rather than during markdown parsing, so it inserts markup inside existing attribute values.
Impact
The output HTML is malformed with unexpected attributes, and the author suggests it may be possible to turn this into something more serious, but no exploit is demonstrated.
What the attacker needed
Ability to post markdown content
How it was found
- Write markdown containing a link whose title contains a mention or submission reference.
- Render the markdown on the site.
- Observe the resulting HTML has unexpected attributes inside the link tag.
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.
When a website shows text written by users, it converts a simple formatting language called markdown into HTML, the code browsers display. Here the site adds links for mentions and issue numbers after that conversion, so the new link code can land inside an existing link's settings and break the page structure. The author suspects this could be abused but has not shown how.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.