Search by

concept-image / wp-fortress

concept-image

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

Package info

gitlab.com/concept-image-public/wp-fortress

Issues

pkg:composer/concept-image/wp-fortress

Statistics

Installs: 29

Dependents: 1

Suggesters: 1

Stars: 0

0.2.0 2026-11-26 14:04 UTC

This package is auto-updated.

Last update: 2026-11-26 13:04:37 UTC


README

WP Fortress

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 .htaccess security 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 .htaccess rules
  • ext-zip for fortress: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).

ModuleWhat it doesSteps aside for SecuPress
SecurityHeadersnosniff, 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).
TrustedHosts400 when the Host isn't the WP_HOME / WP_SITEURL host or a listed one (production, staging)
RestrictPathsByIpwp-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.
NoIndexOutsideProductionX-Robots-Tag: noindex, nofollow outside production
NoDebugDisplaydisplay_errors off outside development, whatever WP_DEBUG_DISPLAY says
SafeUploadsRefuses 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
SvgUploadsSVG uploads only for uploads.svg.capability (default unfiltered_html: administrators and editors), checked by content and always sanitized (enshrined/svg-sanitize)
RestApi401 for anonymous REST requests, except rest.public_routes (WooCommerce Store API, oEmbed) and the CSP report route
GravityFormsUploadsGravity Forms uploads downloadable by logged-in users only
SecurityMaintenanceCheckWP-Cron check every 15 minutes that ends the security maintenance (see below)
DisableXmlRpcXML-RPC off, no pingbacks, no X-Pingback, no RSD linksensitive-data/xmlrpc
PreventUserEnumerationFor 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
HideWordPressVersionNo generator tagdiscloses/wp-version
GenericLoginErrorsOne message for an unknown user and a wrong password (login.error_message)discloses/login-errors-disclose
DisableApplicationPasswordsNo 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 as Content-Security-Policy-Report-Only until FORTRESS_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/csp to 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.

RuleDefaultContent
SendSecurityHeadersonThe security headers and baseline CSP on static files; no ETag
SandboxSvgonSVG files served with a sandboxing CSP and nosniff
DenySensitiveFileson.env*, .ht*, composer.json/lock, *.log (debug.log) and *.sql (archived too), backup and editor files
DenyPhpInUploadsonNo PHP execution in the uploads directory (app/uploads on Bedrock)
DenyThemeSourcesonTheme sources not served (views, config, app, vendor, node_modules, manifests): only public/, style.css and the screenshot
DenyPrivatePathsonDotfiles and dot-directories (except .well-known), node_modules
ServeDocumentsAsDownloadsonOffice and ODF documents downloaded, never rendered
DenyXmlRpconxmlrpc.php refused by Apache (SecuPress: sensitive-data/xmlrpc)
DisableDirectoryListingonOptions -Indexes (SecuPress: sensitive-data/directory-listing)
HideDocumentationFilesonreadme, changelog and license files return 404, including WordPress' readme.html (SecuPress: discloses/readmes)
DenyDataExportsoff.csv / .tsv refused (off: downloads are legitimate on WordPress sites)
BlockCrawlersFORTRESS_BLOCK_CRAWLERSCrawlers, AI agents and link previews get 403 (non-public sites)
Firewall8GoffPerishable Press 8G firewall
BlockAiBotsoffPerishable Press Ultimate AI Block List (SecuPress: firewall/block-ai)

Sub-directory .htaccess files. A sub-directory .htaccess that turns RewriteEngine on (for example web/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>, FilesMatch and RedirectMatch, which merge into sub-directories. Firewall8G, BlockAiBots and BlockCrawlers need mod_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/.htaccess is saved as .htaccess.bak and replaced by .htaccess.maintenance. Apache answers 503 with maintenance.html, and no PHP runs.
  • The SecurityMaintenanceCheck module 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-fortressWhy not here
ForceHttpsWP_HOME is https; SecuPress has an ssl module
IgnoreForeignRefererWordPress validates redirects (wp_validate_redirect)
AuthenticateSessions, SecureSessionCookieWordPress session tokens; auth cookies are already Secure and HttpOnly, SameSite can't be set
SafeMailLinksWordPress builds reset links from siteurl, not the Host header
PasswordDefaults, RequirePasswordChange, RequireTwoFactor, ThrottleRoutesSecuPress (strong passwords, password expiration, OTP 2FA, login attempts)
SameOriginRequestsWordPress uses nonces
SafeLivewireUploadsReplaced 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/: the wp-fortress skill (tasks, configuration, CSP, modules, .htaccess rules);
  • .claude/rules/wp-fortress/: rules loaded by path (wp-fortress.md always; the others for the theme's config/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 (FakeResponseHeaders in tests), and ending a request (400, 404) through Contracts\Terminator (FakeTerminator throws TerminatedRequest in 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