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

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
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-19 16:34:52 -08:00
1 parent 193d39e109
commit c91187aa85
5 files changed
+269 -10

No files matched your search

+16 -3
View File
@@ -59,7 +59,7 @@ import haproxy_manager # noqa: E402
ALLOWLIST = ('/admin-ajax.php', '/admin-post.php',
'/load-styles.php', '/load-scripts.php')
EXCLUSIONS = ('!wp_admin_allowed', '!wp_admin_asset', '!has_wp_logged_in',
EXCLUSIONS = ('!wp_admin_allowed', '!wp_admin_install', '!wp_admin_asset', '!has_wp_logged_in',
'!wp_gate_exempt', '!is_local', '!is_trusted_ip', '!is_whitelisted')
# The normalizer set, in the order it MUST render. Decoding has to precede the
@@ -220,10 +220,23 @@ class WpAdminGate(unittest.TestCase):
line = require_rule(self.cfg, 'acl wp_admin_asset', 'wp_admin_asset ACL')
self.assertRegex(line, r'path_reg.*\(css\|js\|images\)')
def test_install_php_is_NOT_allowlisted(self):
"""install.php is deliberately gated -- a takeover vector on abandoned installs."""
def test_install_php_is_not_in_the_ajax_allowlist(self):
"""install.php / setup-config.php live in their OWN ACL (wp_admin_install),
not in wp_admin_allowed, so the admin-ajax/asset allowlist stays minimal."""
line = require_rule(self.cfg, 'acl wp_admin_allowed', 'wp_admin_allowed ACL')
self.assertNotIn('install.php', line)
self.assertNotIn('setup-config.php', line)
def test_install_screens_exempt_exactly_two_anchored_paths(self):
"""A fresh WordPress redirects every request to /wp-admin/setup-config.php
and a manual installer has no cookie. Exactly these two pages are exempt,
each anchored to /wp-admin/<file> (path_end, no regex, no wildcard).
upgrade.php is deliberately NOT exempt (logged-in only)."""
line = require_rule(self.cfg, 'acl wp_admin_install', 'wp_admin_install ACL')
self.assertEqual(line.split(None, 3)[2], 'path_end')
entries = line.split()[3:]
self.assertEqual(sorted(entries),
['/wp-admin/install.php', '/wp-admin/setup-config.php'])
def test_redirect_rule_has_all_exclusions(self):
rule = require_rule_by_predicate(