Skip to content
Path traversal Write-up Intermediate

Unpatched WordPress vulnerability allows code execution for authors

An unpatched WordPress vulnerability allowed users with Author privileges to delete arbitrary files on the server by manipulating the thumbnail metadata of an attachment. This could lead to code execution by deleting wp-config.php and reinstalling WordPress with attacker-chosen credentials.

blog.ripstech.com

Published on blog.ripstech.com

According to w3tech, WordPress is used by approximately 30% of all websites1. This wide adoption makes it an interesting target for cyber criminals.

The author, on blog.ripstech.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 thumbnail filename from user input was saved to the database without sanitisation and later used in an unlink() call without validation, allowing path traversal.

Impact

An attacker could delete any file the PHP process can delete, potentially leading to code execution by deleting wp-config.php and reinstalling WordPress, though a user account is required.

What the attacker needed

Author-level account or equivalent privileges

The fix

The vulnerability was fixed in WordPress 4.9.7; a temporary hotfix was also provided that sanitises the thumb value using basename().

How it was found

  1. Gain privileges to edit and delete media files (e.g., as an Author).
  2. Edit an attachment and set the thumb parameter to a path of a file to delete.
  3. Delete the attachment, causing the file to be deleted.

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.

WordPress lets users with the Author role upload and manage media files. A flaw in how it handled the thumbnail name for an image meant an attacker could make WordPress delete any file on the server, not just the thumbnail. By deleting the configuration file, the attacker could reinstall WordPress and take control of the site.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.