Skip to content
XSS Write-up Advanced

Who are you? The Importance of Verifying Message Origins

Squidex's editor-sdk.js event listener did not verify the origin of postMessage events, allowing a malicious site to send a crafted message that triggered XSS. Combined with an authenticated arbitrary file write via backup restore, an attacker could achieve remote code execution.

Stefan Schiller Follow

Published on sonarsource.com

In our continuous effort to help secure open-source projects and improve our Code Quality solution, we regularly scan open-source projects via SonarQube Cloud and evaluate the findings. When scanning the popular C# Content Management System Squidex, we were faced with the following finding reported by SonarQube Cloud:

Stefan Schiller (@scryh_), on sonarsource.com

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

The event listener checked event.source but not event.origin, and the backup restore used an attacker-controlled asset ID as a filename without sanitising path traversal.

Impact

An attacker could fully take over a vulnerable Squidex instance by tricking a user into clicking a malicious link, leading to remote code execution.

What the attacker needed

Victim clicks a malicious link; attacker has squidex.admin.restore permission

The fix

The XSS was fixed by adding origin verification with a dynamic configuration, and the file write was fixed by adding a path traversal check in FilePathHelper.

How it was found

  1. Include the Squidex editor page in an iframe on a malicious site.
  2. Send a postMessage with type valueChanged and a malicious value to the iframe.
  3. The event listener processes the message and calls editor.render with the attacker-controlled value, triggering XSS.
  4. Use the XSS to perform an authenticated backup restore with a crafted asset ID containing path traversal.
  5. Set fileVersion to -1 to omit the version and control the written filename.
  6. Overwrite a DLL such as dotnet-gcdump.dll and trigger it via the diagnostics endpoint to execute code.

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.

A web page can receive messages from other windows, but it must check who sent them. Squidex forgot this check, so a bad website could send a message that made Squidex run harmful code. Separately, an admin feature allowed writing files anywhere, and together these let an attacker run commands on the server.

What is XSS?

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

More by Stefan Schiller

View all

10 more disclosed reports, best first.

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.