Skip to content
File upload Write-up Intermediate

MiniBlog Remote Code Execution

The MiniBlog application saved embedded data URLs from post content to disk without validating the file extension, allowing an attacker to upload an ASPX shell and execute arbitrary code on the server. An authenticated user could craft a post containing a data URL with a MIME type ending in 'aspx' to achieve remote code execution.

rastating.github.io

Published on rastating.github.io

During a review of the MiniBlog project, a Windows based blogging package, I observed an interesting piece of functionality. With most WYSIWYG editors that support images, it’s common to see the images embedded in the markup that is generated, rather than uploaded to the web server.

The author, on rastating.github.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

What the attacker needed

Authenticated user account; ability to create or edit posts

The fix

The vulnerability was fixed by adding validation to the SaveFilesToDisk method to restrict file extensions to allowed image types.

How it was found

  1. Create a new post and switch the editor to markup mode.
  2. Include an img element with a data URL whose MIME type ends in aspx and whose base64 content is an ASPX shell.
  3. Publish the post, which triggers the server to decode the data URL and save it as an ASPX file.
  4. The browser redirects to the new post, and the path to the uploaded ASPX file is disclosed in the src attribute of the img element.
  5. Request the uploaded ASPX file to execute the shell and gain a reverse shell.

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.

When you paste an image into a blog post, the editor may store it as a special text string called a data URL. MiniBlog took that string, decoded it, and saved it as a file on the server, but it used the file type from the string to decide the file extension. Because it did not check that the file was really an image, an attacker could make it save a malicious script file that the server would later run, giving the attacker control of the server.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.