Skip to content
RCE Advisory Intermediate CVE-2021-32827

GHSL-2021-059: Arbitrary code execution in MockServer - CVE-2021-32827

MockServer has an overly permissive default CORS configuration and evaluates user-supplied JavaScript or Velocity templates without sandboxing, allowing an attacker to execute arbitrary code on the machine running MockServer if a victim visits a malicious website while MockServer is running locally.

Alvaro Muñoz Follow

Originally disclosed on GitHub Security Lab

An attacker that can trick a victim into visiting a malicious site while running MockServer locally, will be able to run arbitrary code on the MockServer machine.

pwntester, on GitHub Security Lab

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 report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the combination of a default CORS policy that allows any origin to send requests and the use of unsandboxed script engines (Nashorn for JavaScript and Velocity) to evaluate user-supplied templates.

Impact

An attacker could execute arbitrary code on the machine running MockServer, but only if the victim visits a malicious site while MockServer is running locally.

What the attacker needed

Victim runs MockServer locally; victim visits a malicious website

How it was found

  1. The attacker hosts a malicious web page.
  2. The victim, who is running MockServer locally, visits the malicious page.
  3. The page sends a request to MockServer's REST API to create an expectation with a malicious template.
  4. The page then triggers the expectation, causing the template to execute arbitrary code on the victim's machine.

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 report has not been written yet. The Original tab links to the source.

MockServer is a tool developers run on their own computer to test web services. It has two problems: it lets any website send it commands, and it runs code that those commands contain without checking if that is safe. So a malicious website can make the developer's own computer run harmful commands.

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 Alvaro Muñoz

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

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.