concept-image / wp-fortress
WP Fortress: switchable security modules for WordPress on Bedrock + Acorn (security headers and CSP, trusted hosts, safe and sanitized uploads, REST and user enumeration hardening), modular .htaccess security rules with the Perishable Press firewall, and a security maintenance killswitch. Defers to
Requires
- php: >=8.3
- concept-image/wp-hook-attributes: ^0.1
- enshrined/svg-sanitize: ^1.1
- illuminate/process: ^12.0|^13.0
- roots/acorn: ^6.1
Requires (Dev)
- brain/monkey: ^2.6
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0|^5.0
- pestphp/pest-plugin-arch: ^4.0|^5.0
- szepeviktor/phpstan-wordpress: ^2.0
Suggests
- ext-zip: Required by fortress:firewall-update to read the 8G firewall archive.
Provides
None
Conflicts
None
Replaces
None
README
Security defaults for Bedrock and Acorn WordPress sites
The WordPress counterpart of concept-image/laravel-fortress. It provides:
- switchable security modules: security headers and CSP, trusted hosts, IP-restricted admin and login, safe and sanitized uploads, REST API and user enumeration hardening, XML-RPC off…
- modular
.htaccesssecurity rules, with the Perishable Press 8G firewall and AI bot block list; - a security maintenance killswitch.
It works alongside SecuPress Pro. Login throttling, 2FA, password policy, captcha, malware scans and backups
stay with SecuPress. The modules and rules SecuPress also covers step aside while the matching SecuPress submodule
is active. SecuPress only counts when the plugin is loaded: Bedrock's DISABLED_PLUGINS turns it off outside
production, where Fortress keeps covering everything.
Requirements
- PHP 8.3+
- WordPress 6.5+ on Bedrock, Roots Acorn 6.1+
- Apache 2.4 for the
.htaccessrules ext-zipforfortress:firewall-update
concept-image/wp-starter-theme requires it: Concept Image themes get it automatically.
Installation
composer require concept-image/wp-fortress # in the theme directory
wp acorn fortress:install # config, maintenance files, Claude Code files, .htaccess rules
fortress:install publishes config/fortress.php into the theme, publishes web/.htaccess.maintenance and
web/maintenance.html, publishes the Claude Code skill and rules at the Bedrock root (see below), and writes the
rules into web/.htaccess. Run wp acorn fortress:htaccess again after
changing the rules or the configuration. In CI or a deployment, wp acorn fortress:htaccess --check fails when
the file is out of date.
Modules
Enabled in config/fortress.php → modules (Class => bool).
| Module | What it does | Steps aside for SecuPress |
|---|---|---|
SecurityHeaders | nosniff, X-Frame-Options: SAMEORIGIN, Referrer-Policy, Permissions-Policy, baseline CSP, HSTS (HTTPS, listed environments), no X-Powered-By; front-end, admin and login. Strict nonce CSP on the front-end (see below). | |
TrustedHosts | 400 when the Host isn't the WP_HOME / WP_SITEURL host or a listed one (production, staging) | |
RestrictPathsByIp | wp-admin (except admin-ajax.php / admin-post.php) and wp-login.php limited to IPs or CIDRs: FORTRESS_ADMIN_IPS, FORTRESS_LOGIN_IPS. Others get a 404. | |
NoIndexOutsideProduction | X-Robots-Tag: noindex, nofollow outside production | |
NoDebugDisplay | display_errors off outside development, whatever WP_DEBUG_DISPLAY says | |
SafeUploads | Refuses uploads a server or browser could run: scripts (even shell.php.jpg), .htaccess / .user.ini, HTML or JS disguised as images, <?php anywhere in the file | |
SvgUploads | SVG uploads only for uploads.svg.capability (default unfiltered_html: administrators and editors), checked by content and always sanitized (enshrined/svg-sanitize) | |
RestApi | 401 for anonymous REST requests, except rest.public_routes (WooCommerce Store API, oEmbed) and the CSP report route | |
GravityFormsUploads | Gravity Forms uploads downloadable by logged-in users only | |
SecurityMaintenanceCheck | WP-Cron check every 15 minutes that ends the security maintenance (see below) | |
DisableXmlRpc | XML-RPC off, no pingbacks, no X-Pingback, no RSD link | sensitive-data/xmlrpc |
PreventUserEnumeration | For guests: ?author=N and author archives return 404, no REST users routes, no users sitemap, no oEmbed author. Logged-in users keep the REST users routes (block editor). | users-login/stop-user-enumeration |
HideWordPressVersion | No generator tag | discloses/wp-version |
GenericLoginErrors | One message for an unknown user and a wrong password (login.error_message) | discloses/login-errors-disclose |
DisableApplicationPasswords | No application passwords (turn the module off for REST integrations) | users-login/disable-application-passwords |
Content-Security-Policy
- The baseline policy (
upgrade-insecure-requests; frame-ancestors 'self') is always enforced. - The strict policy (
security_headers.csp.directives) is sent on the front-end asContent-Security-Policy-Report-OnlyuntilFORTRESS_CSP_MODE=enforce. 'nonce'becomes the request nonce, added to every script tag WordPress prints: enqueued scripts, script modules and inline scripts.- Scripts echoed without
wp_print_script_tag()/wp_print_inline_script_tag()(some plugins, raw<script>in templates) have no nonce. Read the reports before enforcing. 'unsafe-eval'is on by default (csp.unsafe_eval), because Alpine.js' standard build needs it. Switch to@alpinejs/cspto drop it.- Browsers post violations to
POST /wp-json/fortress/v1/csp-report. They're logged in Acorn's log (csp.report_log_channel), limited to 60 per IP and minute. - The Vite dev server is allowed while it runs.
- The admin and login pages only get the baseline: WordPress and plugins print inline scripts there.
.htaccess rules
wp acorn fortress:htaccess writes the enabled rules of htaccess.rules into web/.htaccess (htaccess.path).
Each rule gets its own # BEGIN Fortress: <key> … # END Fortress: <key> section, placed before WordPress' block.
Content outside these sections, including the WordPress and SecuPress blocks, is never touched. Disabled rules, and
rules an active SecuPress submodule covers, are removed. Use --dry-run to print the result, --check to verify.
| Rule | Default | Content |
|---|---|---|
SendSecurityHeaders | on | The security headers and baseline CSP on static files; no ETag |
SandboxSvg | on | SVG files served with a sandboxing CSP and nosniff |
DenySensitiveFiles | on | .env*, .ht*, composer.json/lock, *.log (debug.log) and *.sql (archived too), backup and editor files |
DenyPhpInUploads | on | No PHP execution in the uploads directory (app/uploads on Bedrock) |
DenyThemeSources | on | Theme sources not served (views, config, app, vendor, node_modules, manifests): only public/, style.css and the screenshot |
DenyPrivatePaths | on | Dotfiles and dot-directories (except .well-known), node_modules |
ServeDocumentsAsDownloads | on | Office and ODF documents downloaded, never rendered |
DenyXmlRpc | on | xmlrpc.php refused by Apache (SecuPress: sensitive-data/xmlrpc) |
DisableDirectoryListing | on | Options -Indexes (SecuPress: sensitive-data/directory-listing) |
HideDocumentationFiles | on | readme, changelog and license files return 404, including WordPress' readme.html (SecuPress: discloses/readmes) |
DenyDataExports | off | .csv / .tsv refused (off: downloads are legitimate on WordPress sites) |
BlockCrawlers | FORTRESS_BLOCK_CRAWLERS | Crawlers, AI agents and link previews get 403 (non-public sites) |
Firewall8G | off | Perishable Press 8G firewall |
BlockAiBots | off | Perishable Press Ultimate AI Block List (SecuPress: firewall/block-ai) |
Sub-directory
.htaccessfiles. A sub-directory.htaccessthat turnsRewriteEngineon (for exampleweb/app/.htaccess, written by image converters such as WebP Converter for Media) replaces the parent's rewrite rules for every path below it. For that reason the WordPress rules (DenyPhpInUploads,DenyThemeSources,DenyPrivatePaths,HideDocumentationFiles) use<If>,FilesMatchandRedirectMatch, which merge into sub-directories.Firewall8G,BlockAiBotsandBlockCrawlersneedmod_rewrite: they don't cover static files under such a directory. Pages and PHP entry points are still covered.
Firewall
wp acorn fortress:firewall-update downloads the 8G firewall and the AI block list from Perishable Press. It
removes the user agents of firewall.excluded_user_agents (search engines and AI search assistants by default),
then writes both lists into the .htaccess. Nothing else is stored. Enable Firewall8G / BlockAiBots first,
and run the command again to update the lists.
Security maintenance
When a PHP vulnerability is announced and the patched version isn't installed yet, switch the site to a static 503 page:
wp acorn fortress:security-maintenance on --php=8.5.13 # until the server runs PHP 8.5.13
wp acorn fortress:security-maintenance status
wp acorn fortress:security-maintenance off
- The live
web/.htaccessis saved as.htaccess.bakand replaced by.htaccess.maintenance. Apache answers 503 withmaintenance.html, and no PHP runs. - The
SecurityMaintenanceCheckmodule switches the maintenance off once the server runs the patched version, checking every 15 minutes through WP-Cron. - While the maintenance is on, pages don't run PHP, so page-triggered WP-Cron can't fire. The site needs a system
cron running
wp cron event run --due-now. - When the CLI PHP isn't the web server's, set
security_maintenance.php_version_command(['php-fpm8.5', '-v']).
Not ported from laravel-fortress
| laravel-fortress | Why not here |
|---|---|
ForceHttps | WP_HOME is https; SecuPress has an ssl module |
IgnoreForeignReferer | WordPress validates redirects (wp_validate_redirect) |
AuthenticateSessions, SecureSessionCookie | WordPress session tokens; auth cookies are already Secure and HttpOnly, SameSite can't be set |
SafeMailLinks | WordPress builds reset links from siteurl, not the Host header |
PasswordDefaults, RequirePasswordChange, RequireTwoFactor, ThrottleRoutes | SecuPress (strong passwords, password expiration, OTP 2FA, login attempts) |
SameOriginRequests | WordPress uses nonces |
SafeLivewireUploads | Replaced by SafeUploads on WordPress' upload filters |
Migrating from the cinit "security-hardening" add-on
Fortress replaces the add-on. Remove web/app/mu-plugins/addon-security-hardening.php (REST users, author
archives, XML-RPC) and the # Hardening block plus the *.log|sql FilesMatch from web/.htaccess. Then run
wp acorn fortress:install.
Claude Code
Bedrock projects have no Laravel Boost, so the package publishes its AI guidance straight into the Bedrock root, where Claude Code loads it on its own. An agent then knows where each setting lives ("allow https://example.test in the CSP", "restrict wp-admin to our IP"…) without reading the package:
.claude/skills/wp-fortress/: thewp-fortressskill (tasks, configuration, CSP, modules,.htaccessrules);.claude/rules/wp-fortress/: rules loaded by path (wp-fortress.mdalways; the others for the theme'sconfig/fortress.php,web/.htaccess, the theme's views and code).
fortress:install publishes them once, keeping existing files. After a package update, refresh them:
wp acorn vendor:publish --tag=wp-fortress-ai --force # skill and rules
wp acorn vendor:publish --tag=wp-fortress-skill --force # skill only (wp-fortress-rules: rules only)
Testing
composer ci # Pint, Larastan (level max, WordPress stubs), Pest (Testbench + Brain Monkey)
Without PHP's dom/xml/mbstring extensions on the host:
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD":/app -w /app composer:2 composer ci.
- Header output goes through
Contracts\ResponseHeaders(FakeResponseHeadersin tests), and ending a request (400, 404) throughContracts\Terminator(FakeTerminatorthrowsTerminatedRequestin tests). - SecuPress detection goes through
Contracts\SecuPress(secupressActive([...])in tests). - WordPress functions are stubbed with Brain Monkey, and the TestCase provides an install at
https://example.test.
Changelog
Please refer to CHANGELOG for more information.
License
Please refer to LICENSE for more information.
Credits
- Ported from
concept-image/laravel-fortress. - Firewall lists: Perishable Press (8G firewall, Ultimate AI Block List).
- Banner icon: Architecture and city icons created by Magnific - Flaticon