Skip to content
XSS Write-up Advanced

From Markdown to remote code execution in Atom

Atom's Markdown preview and settings view allowed arbitrary HTML, and a bundled HTML file with a DOM XSS could be loaded via an iframe to execute JavaScript. An attacker could then use Node.js integration to run local code, and a malicious package README could trigger this remotely when viewed.

statuscode.ch

Published on statuscode.ch

Recently I took a look at Atom, a text editor by GitHub. With a little bit of work, I was able to chain multiple vulnerabilities in Atom into an actual Remote Code Execution.

The author, on statuscode.ch

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the Markdown renderers allowed arbitrary HTML and the sanitisation was incomplete, while a bundled test HTML file used eval on the URL query string and Electron exposed Node.js APIs to the page.

Impact

An attacker could execute arbitrary local code when a victim opens a malicious Markdown document and its preview, or merely views a malicious package's README in Atom's settings; the text does not state any defence that blocked this.

What the attacker needed

Victim opens a malicious Markdown file; victim opens the preview pane; or victim views a malicious package README

The fix

The issue was fixed by removing the unnecessary HTML files from the bundle and sanitising Markdown with DOMPurify.

How it was found

  1. Create a Markdown file containing an iframe that points to the bundled test HTML file with a script in the query string.
  2. Open the Markdown file in Atom and open its preview pane.
  3. The iframe loads the local HTML file, which evaluates the query string as JavaScript.
  4. The script accesses window.top.require to run a local program.

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 write-up has not been written yet. The Original tab links to the source.

Atom is a text editor built with web technology, so a script injection (cross-site scripting, or XSS) can run code on your computer. The author found that Atom's Markdown preview allowed embedding a local file that itself ran any script given in its address, and that script could then start programs. Because package descriptions are also shown as Markdown, merely viewing a malicious package's page could trigger it.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.