Skip to content
RCE Write-up Advanced

Blog: CVE-2023-4634 - Tricky Unauthenticated RCE on Wordpress Media Library Assistant Plugin using a good old Imagick

The WordPress Media Library Assistant plugin exposed an unauthenticated image-streaming endpoint that passed a user-controlled file path to Ghostscript and then to the Imagick library. An attacker could host a crafted SVG on their own FTP server, have the plugin fetch and render it, and use ImageMagick formatters to read local files or write a malicious MSL file, leading to remote code execution.

Florent Follow

Published on patrowl.io

As discussed in many of our articles, you already know that WordPress and related plugins are taking up a large space in the global attack surface we are monitoring for our customers.

Florent (@Pepito_oh), on patrowl.io

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 plugin passed an unauthenticated, user-supplied path into Imagick without restricting which ImageMagick formatters or delegates could be used, so SVG references could invoke text: and msl: handlers.

Impact

An unauthenticated attacker could read local files such as wp-config.php and, by chaining the temporary-file behaviour, could achieve remote code execution, though the write-up notes the MSL path still needed several bypasses.

What the attacker needed

No login needed; attacker-controlled FTP server; Imagick installed with default policy; victim runs the vulnerable plugin

The fix

The plugin should block direct access to the stream handler and restrict Imagick formatters and delegates through a security policy, and the text says the issue was assigned CVE-2023-4634.

How it was found

  1. Find the stand-alone mla-stream-image.php file that is reachable without authentication
  2. Host a file on an FTP server so the is_file() check passes, since FTP supports stat()
  3. Request the endpoint with the FTP path so Ghostscript fails and Imagick reads the remote file
  4. Serve an SVG that references a text: formatter to read local files such as wp-config.php
  5. Use a polyglot SVG/MSL file to get an MSL script written into the /tmp folder
  6. Reference the leftover temporary file with an msl: formatter to execute commands

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.

A WordPress plugin had a web address anyone could call without logging in. It took a filename from the visitor and asked an image library (Imagick, which turns pictures into other formats) to open it. Because that library can also read text files and run its own little scripts, a crafted picture could make the server reveal files or even run attacker code.

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 Florent

View all

1 more disclosed report, 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.