Skip to content
File upload Write-up Intermediate

What is the Contact Form 7 Plugin ?

The Contact Form 7 plugin before 5.3.2 allowed unrestricted file upload because it did not remove special characters from filenames, so an attacker could upload a file with a double extension and potentially execute it as PHP. A commenter found that in a default WordPress setup, multiple obstacles (htaccess, file removal, filename sanitisation) prevented the exploit from working.

blog.wpsec.com

Published on blog.wpsec.com

A high-severity Unrestricted File Upload vulnerability, tracked as CVE-2020–35489, was discovered in a popular WordPress plugin called Contact Form 7, currently installed on 5 Million+ websitesmaking them vulnerable to attacks like phishing, complete site take-over, data-breach, phishing and credit card frauds.

Jonas Lejon, on blog.wpsec.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 plugin did not sanitise special characters in uploaded filenames, causing the server to treat a file with a double extension as an executable script.

Impact

An attacker could upload and execute arbitrary files, leading to complete website takeover, malware injection, or data theft, but a commenter found that default WordPress protections (htaccess, file removal, filename sanitisation) prevented the exploit in a test setup.

What the attacker needed

WordPress with Contact Form 7 < 5.3.2; ability to submit a file upload form

The fix

The vulnerability was fixed in version 5.3.2; users should update the plugin and also disable PHP execution in the uploads folder.

How it was found

  1. Install and activate the vulnerable Contact Form 7 plugin (version 5.3.1).
  2. Create a new contact form with a file upload field.
  3. Add the form to a page and publish it.
  4. Submit the form with a file whose name contains a special character between two extensions.
  5. The file is uploaded and saved with only the first extension, making it executable.

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 file upload feature should only allow safe file types like images. Here, the plugin failed to clean up the filename, so a file named like 'picture.php .jpg' could be saved as 'picture.php' and then run as code on the server. That would let an attacker take over the website. However, a reader found that in a normal WordPress install, other protections stopped this from actually working.

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.