fix(wp-admin gate): exempt the WordPress install screens (setup-config.php, install.php) #21

Merged
jknapp merged 2 commits from fix/wpadmin-gate-install-exempt into main 2026-11-20 02:20:41 +00:00
Owner

Problem

A fresh WordPress with no wp-config.php redirects every request to /wp-admin/setup-config.php. The edge wp-admin gate (cookieless /wp-admin/* -> /wp-login.php?redirect_to=<path>, 302) bounced a manual installer to a login form that can never succeed, and that URL then tripped CRS 930120 (config.php in ARGS:redirect_to) so the visitor saw the WAF block page (whp03, whichmodelwhere.com, ref 0b9a5687).

Change

  • New ACL wp_admin_install: path_end /wp-admin/setup-config.php /wp-admin/install.php (exact, case-sensitive, on the normalised path), added as !wp_admin_install on the redirect rule only. The encoded-separator and unsafe-path denies are untouched.
  • upgrade.php is NOT exempt (WordPress only sends logged-in users there, who carry the cookie). maint/repair.php untouched.
  • Assets the screens need (css/js/images, load-styles.php, load-scripts.php) were already allowed.
  • Comment block rewritten: the old text said install.php was deliberately gated.

Safety / residual risk

WordPress refuses both pages on a healthy installed site (setup-config.php: "wp-config.php already exists"; install.php: "Already Installed"). Real residual risks of exempting them (accepted tradeoff, requested by Josh): (1) WordPress files present but no wp-config.php (half upload, deletion, mid-restore/transfer) lets any visitor supply their own DB and take over the site; (2) a half-installed site (wp-config.php, no tables / wrong $table_prefix) lets any visitor finish install.php?step=2. The old gate only stopped cookieless scanners (has_wp_logged_in checks the cookie name only). Note: path-info forms like /x.php/wp-admin/install.php pass the exemption exactly as they already do for admin-ajax.php (pre-existing class, nothing new).

Tests

  • scripts/test-wpadmin-gate.py (31 OK): the old "install.php is NOT allowlisted" pin is replaced by pins for the new ACL (exactly two anchored entries, not in the ajax allowlist) and the new exclusion on the redirect rule.
  • New scripts/test-wpadmin-gate-behaviour.py: extracts the real gate lines from the rendered template and runs them in the REAL haproxy (3.2.26), raw requests. 27 cases: exempt (incl. ?step=-1, ?step=2, subdirectory, /wp-admin/css/../setup-config.php, %2E, //), still gated (/wp-admin/, upgrade.php, .php.php, .phpx, Setup-Config.php, Install.php, /WP-ADMIN/, path info, trailing slash, inserted dir, dotdot off the page), %2F still 403, cookie passes. Mutation-checked: dropping !wp_admin_install fails the 9 exempt cases. Wired into the Dockerfile build gate.
  • VERSION 2026.11.7.

Rollout

Merging to main publishes :latest and :2026.11.7; every UNPINNED host picks it up the next time anything recreates the edge (including the watchdog's fallback), so merge only when ready to roll. Hosts pinned with whp edge image set stay on their pin until whp edge image set <repo>:2026.11.7 (or the pin is cleared) and the container is recreated; haproxy.cfg is regenerated from the image's templates at start. Test host first.

An rc build of this commit was pushed to release/wpadmin-install-exempt (publishes only :2026.11.7-rc and the sha tag).

Companion WHP PR: WAF backstop 991900196.

Co-Authored-By: Claude Sonnet 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6

🤖 Generated with Claude Code

https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6

## Problem A fresh WordPress with no wp-config.php redirects every request to `/wp-admin/setup-config.php`. The edge wp-admin gate (cookieless `/wp-admin/*` -> `/wp-login.php?redirect_to=<path>`, 302) bounced a manual installer to a login form that can never succeed, and that URL then tripped CRS 930120 (`config.php` in `ARGS:redirect_to`) so the visitor saw the WAF block page (whp03, whichmodelwhere.com, ref 0b9a5687). ## Change - New ACL `wp_admin_install`: `path_end /wp-admin/setup-config.php /wp-admin/install.php` (exact, case-sensitive, on the normalised path), added as `!wp_admin_install` on the redirect rule only. The encoded-separator and unsafe-path denies are untouched. - `upgrade.php` is NOT exempt (WordPress only sends logged-in users there, who carry the cookie). `maint/repair.php` untouched. - Assets the screens need (css/js/images, load-styles.php, load-scripts.php) were already allowed. - Comment block rewritten: the old text said install.php was deliberately gated. ## Safety / residual risk WordPress refuses both pages on a healthy installed site (`setup-config.php`: "wp-config.php already exists"; `install.php`: "Already Installed"). Real residual risks of exempting them (accepted tradeoff, requested by Josh): (1) WordPress files present but no wp-config.php (half upload, deletion, mid-restore/transfer) lets any visitor supply their own DB and take over the site; (2) a half-installed site (wp-config.php, no tables / wrong `$table_prefix`) lets any visitor finish `install.php?step=2`. The old gate only stopped cookieless scanners (`has_wp_logged_in` checks the cookie name only). Note: path-info forms like `/x.php/wp-admin/install.php` pass the exemption exactly as they already do for `admin-ajax.php` (pre-existing class, nothing new). ## Tests - `scripts/test-wpadmin-gate.py` (31 OK): the old "install.php is NOT allowlisted" pin is replaced by pins for the new ACL (exactly two anchored entries, not in the ajax allowlist) and the new exclusion on the redirect rule. - New `scripts/test-wpadmin-gate-behaviour.py`: extracts the real gate lines from the rendered template and runs them in the REAL haproxy (3.2.26), raw requests. 27 cases: exempt (incl. `?step=-1`, `?step=2`, subdirectory, `/wp-admin/css/../setup-config.php`, `%2E`, `//`), still gated (`/wp-admin/`, `upgrade.php`, `.php.php`, `.phpx`, `Setup-Config.php`, `Install.php`, `/WP-ADMIN/`, path info, trailing slash, inserted dir, dotdot off the page), `%2F` still 403, cookie passes. Mutation-checked: dropping `!wp_admin_install` fails the 9 exempt cases. Wired into the Dockerfile build gate. - VERSION 2026.11.7. ## Rollout Merging to main publishes `:latest` and `:2026.11.7`; every UNPINNED host picks it up the next time anything recreates the edge (including the watchdog's fallback), so merge only when ready to roll. Hosts pinned with `whp edge image set` stay on their pin until `whp edge image set <repo>:2026.11.7` (or the pin is cleared) and the container is recreated; haproxy.cfg is regenerated from the image's templates at start. Test host first. An rc build of this commit was pushed to `release/wpadmin-install-exempt` (publishes only `:2026.11.7-rc` and the sha tag). Companion WHP PR: WAF backstop 991900196. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
jknapp added 1 commit 2026-11-20 00:39:48 +00:00
fix(wp-admin gate): exempt the WordPress install screens (setup-config.php, install.php)
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 16m35s
c91187aa85
A fresh WordPress with no wp-config.php redirects every request to
/wp-admin/setup-config.php. The edge wp-admin gate bounced that cookieless
request to wp-login.php?redirect_to=/wp-admin/setup-config.php, which then
tripped CRS 930120 ("config.php" in ARGS:redirect_to) and showed the WAF
block page: manual installers never saw WordPress's setup screen.

New ACL wp_admin_install (path_end, exact /wp-admin/setup-config.php and
/wp-admin/install.php on the normalised path, case-sensitive) added as a
negated exclusion on the redirect rule. upgrade.php stays gated (only
logged-in users are sent there). Variants (.php.php, .phpx, case, path info,
inserted directory, dotdot/encoded escapes) stay gated; encoded separators
still deny.

Tests: the structural suite now pins the new ACL; new
test-wpadmin-gate-behaviour.py runs the real gate rules in the real haproxy
and sends raw requests (run by the image build). VERSION 2026.11.7.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
jknapp added 1 commit 2026-11-20 00:47:18 +00:00
wp-admin gate: state the real residual risks of exempting the install screens
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 10m50s
3eee8e6023
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
jknapp merged commit 3ce1dc8662 into main 2026-11-20 02:20:41 +00:00
jknapp deleted branch fix/wpadmin-gate-install-exempt 2026-11-20 02:20:46 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cloud-hosting-platform/haproxy-manager-base#21