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.
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:
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
- Include the Squidex editor page in an iframe on a malicious site.
- Send a postMessage with type valueChanged and a malicious value to the iframe.
- The event listener processes the message and calls editor.render with the attacker-controlled value, triggering XSS.
- Use the XSS to perform an authenticated backup restore with a crafted asset ID containing path traversal.
- Set fileVersion to -1 to omit the version and control the written filename.
- 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.