Skip to content
RCE Write-up Intermediate

Mongo Express Mayhem How Cve 2020 24391 Opens The Door To Remote Code Execution

Mongo-Express versions before 1.0.0 used the safer-eval package to validate user-supplied JavaScript, but its sandbox could be bypassed. An attacker could inject and execute arbitrary JavaScript on the server, leading to remote code execution in the Node.js process.

Abhishek Kollur Follow

Published on systemweakness.com

In the fast-paced world of web development, Mongo-Express is a handy tool that developers often use to manage their MongoDB databases. It provides a sleek web interface to interact with your MongoDB, making it easier to manage your data.

Abhishek Kollur, on systemweakness.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 safer-eval package's sandboxing was insufficient, allowing bypass and arbitrary JavaScript execution.

Impact

An attacker could execute arbitrary JavaScript on the server, leading to remote code execution in the Node.js process.

What the attacker needed

Mongo-Express version before 1.0.0; Network access to the instance

The fix

Upgrade Mongo-Express to version 1.0.0 or later, which is patched against this vulnerability.

How it was found

  1. Use a Shodan search query to find Mongo-Express instances.
  2. Verify vulnerability using Nuclei with a custom template for CVE-2020-24391.
  3. Exploit using public exploits in a controlled environment to execute arbitrary 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.

Mongo-Express is a web tool for managing MongoDB databases. It used a library called safer-eval to run small pieces of JavaScript safely, but that library could be tricked into running harmful code. This meant an attacker could run their own commands on the server, not just view the database.

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 Abhishek Kollur

View all

20 more disclosed reports, best first.

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.