Skip to content
XSS Write-up Advanced

Playing Dominos with Moodle's Security (2/2)

A self-XSS in Moodle's WYSIWYG editor could be turned into a stored XSS via the autosave feature, and when OAuth authentication is enabled, an attacker could craft a link that logs a victim into the attacker's account and then executes the stored payload, leading to account takeover.

Yaniv Nizry Follow

Published on sonarsource.com

In our endeavor to enhance the security of the open-source realm and gain a deeper understanding of real-world vulnerabilities, we are constantly conducting audits of open-source projects, and the outcomes of this are presented in our two articles on Moodle security. This is the second blog covering another critical…

Yaniv Nizry (@YNizry), 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

Likely the combination of an autosave feature that stored unsanitised editor content and an OAuth confirmation endpoint that logged users in without checking for an existing session, allowing a stored self-XSS to be triggered in a victim's browser.

Impact

On Moodle instances with OAuth enabled, an attacker could take over a victim's account with a single click, and if the victim is an admin, achieve code execution on the server.

What the attacker needed

Moodle with OAuth authentication enabled; Attacker has an account with email matching OAuth provider; Victim clicks a crafted link

How it was found

  1. The attacker has an account with a controlled email same as the OAuth provider.
  2. The attacker's account shouldn't be linked to OAuth.
  3. Attacker creates a self-XSS payload that logs in using the current browser's OAuth using an iframe.
  4. An attacker account adds the self-XSS payload to a WYSIWYG input and waits for the autosave.
  5. Attacker logs out.
  6. The attacker logs in with OAuth, receives a confirmation URL by email, and adds a redirect parameter pointing to the self-XSS page.

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.

Self-XSS is a bug where you can run your own JavaScript in your own browser, but it normally only affects you. Here, Moodle's editor saved that JavaScript on the server, so it would run again later. By abusing a login link that automatically signs someone into an account, an attacker could make a victim run that saved JavaScript and then take over the victim's account.

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 Yaniv Nizry

View all

7 more disclosed reports, best first.

More from Moodle

View all

The newest disclosed reports for this program.

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.