Skip to content
RCE Write-up Advanced

Pre-auth Remote Code Execution Vulnerability in Metasploit

Metasploit's Web UI used a static, publicly known secret_key_base and hybrid cookie serialization, allowing an unauthenticated attacker to craft a signed cookie that triggers deserialization of arbitrary Ruby objects and remote code execution.

github.com

Published on github.com

History

The author, on github.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 a static, publicly discoverable secret_key_base and the use of hybrid cookie serialization, which permits deserialization of Marshal-serialized objects.

Impact

A remote unauthenticated attacker could execute arbitrary code as the daemon user, leading to full compromise of the Metasploit instance.

What the attacker needed

Metasploit 4.12.0-2016061501 to 4.12.0-2016083001; Network access to the Web UI

The fix

Rapid7 fixed the issue in Metasploit 4.12.0-2016091401 by changing the cookie serializer to :json and regenerating the secret_key_base if a known static value was in use.

How it was found

  1. The attacker identifies a target running an affected Metasploit version.
  2. The attacker uses the known static secret_key_base value to sign a malicious cookie.
  3. The attacker sends the crafted cookie to the Metasploit Web UI.
  4. The application deserializes the cookie, executing arbitrary code as the daemon user.

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.

The web interface used a secret key to sign cookies, but that key was the same for every installation and publicly known. Because the software also accepted a dangerous cookie format, an attacker could create a malicious cookie that, when processed, ran their code on the server without needing to log in.

What is RCE?

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

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.