Skip to content
XSS Write-up Advanced

Type confusion attacks in ProseMirror editors

A type confusion flaw in ProseMirror's rendering allowed a node attribute intended to be a string to be supplied as an array, causing the editor to create a script element. An authenticated user could store a malicious document that executes JavaScript in other users' browsers when viewed.

Pham Van Khanh Follow

Published on blog.calif.io

Calif was recently engaged to audit the open source knowledge base management package Outline. Aside from server side components, we focused on the rather complicated Outline’s editor that is based on the ProseMirror library.

Khanh, on blog.calif.io

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 toDOM function copied a node attribute directly into the output without checking its type, so an array was interpreted as an element specification instead of text.

Impact

An authenticated attacker could execute arbitrary JavaScript in the context of the Outline application for any user who viewed the malicious comment, though the site's CSP blocked external scripts and had to be bypassed by hosting the payload as an attachment.

What the attacker needed

An authenticated account; victim views the malicious comment

The fix

The issue was fixed by updating Outline and ProseMirror, and the report recommends validating all node attributes in toDOM functions and sandboxing the editor.

How it was found

  1. Create a new comment on a document.
  2. Send an update request that replaces the comment's mention label with an array describing a script element.
  3. Because of CSP, host the JavaScript file as an attachment and reference it via the attachment redirect link.
  4. When another user views the comment, the script executes in the Outline origin.

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.

When a web page shows user content, it must treat that content as data, not as instructions. Here, the editor expected a simple text label but accepted a structured value that told the browser to create a script element. That let an attacker run their own code in the victim's browser session.

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.