Skip to content
RCE Write-up Intermediate

Discoure themes OS Command Injection

A theme's compatibility file was parsed and its version value was passed unsanitised into a shell command, so a malicious theme repository could run arbitrary OS commands on the server. An attacker who could get a theme imported or updated could execute commands as the Discourse user.

Joern Schneeweisz Follow

Published on 0day.click

Discourse offers the possibility to install themes from remote Git repositories. Before this commit it was possible to inject OS commands via a maliciously crafted theme which is pulled via Git.

joernchen (@joernchen), on 0day.click

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 version string read from the theme's compatibility file was interpolated directly into a shell command without sanitisation.

Impact

An attacker could run arbitrary OS commands on the server as the user running Discourse when the malicious theme was imported or updated.

What the attacker needed

Ability to supply a theme Git repository; theme import or update on affected version

The fix

The issue was fixed in a commit that stopped the unsanitised version value from reaching the shell command.

How it was found

  1. Create a Git repository containing a theme and a compatibility file that maps a Discourse version to a crafted version value.
  2. Have the theme imported or updated on a Discourse instance running that version.
  3. The crafted value is placed into the git command and the injected shell command runs.

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.

Discourse lets administrators install themes from Git repositories. The theme can include a small settings file that names a version to check out, and the server built a shell command using that version text without cleaning it. Because the shell treats certain characters as instructions, a crafted version string could make the server run extra commands chosen by the attacker.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Joern Schneeweisz

View all

4 more disclosed reports, best first.

More from Discourse

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.