Add opt-in WordPress runtime hardening controls#1649
Merged
Conversation
retlehs
added a commit
to roots/docs
that referenced
this pull request
Mar 6, 2026
Add documentation for the opt-in runtime hardening feature from roots/trellis#1649, covering PHP-FPM identity separation, writable path allowlisting, and per-site configuration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
swalkinshaw
reviewed
Mar 8, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
swalkinshaw
approved these changes
Mar 10, 2026
retlehs
added a commit
to roots/docs
that referenced
this pull request
Mar 11, 2026
Add documentation for the opt-in runtime hardening feature from roots/trellis#1649, covering PHP-FPM identity separation, writable path allowlisting, and per-site configuration. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an opt-in hardening mode for WordPress runtime file permissions in Trellis (related to #368), while preserving current behavior by default.
When enabled, PHP-FPM can run as a separate runtime identity and writable paths are explicitly allowlisted.
What Changed
1. New hardening variables (
roles/wordpress-setup/defaults/main.yml)Added:
2. PHP-FPM runtime identity is conditional (
roles/wordpress-setup/templates/php-fpm-pool-wordpress.conf.j2)Pool user/group now switch based on hardening mode:
hardened = false->web_user/web_group(existing behavior)hardened = true->wordpress_runtime_user/wordpress_runtime_groupAlso added a clarifying comment that socket owner/group remain
www-dataso Nginx can connect to PHP-FPM.3. Hardened-mode validation + writable path ownership (
roles/wordpress-setup/tasks/main.yml+runtime-writable-paths.yml)When
wordpress_runtime_hardened: true:getent group)getent passwd)0775)Per-site writable path override is supported:
wordpress_sites.<site>.runtime_writable_pathswordpress_runtime_writable_paths4. Optional cron user alignment (
roles/wordpress-setup/tasks/main.yml)WP cron can run as runtime user when both are true:
wordpress_runtime_hardened: truewordpress_runtime_cron_as_runtime_user: trueOtherwise cron continues to run as
web_user(backward compatible).Example Configuration
In
group_vars/production/main.yml(orgroup_vars/all/main.yml):Per-site override:
Backward Compatibility
Custom Runtime User/Group Note
wordpress_runtime_user/wordpress_runtime_groupmust exist on target hosts when hardening is enabled.php-app), provision that OS user/group first.group_vars/all/users.yml) so the account exists before enabling hardening:getentchecks if the configured user/group are missing.www-data), but runtime/deploy identity separation may be reduced depending on your existingweb_usersetup.Close #368
Docs updates: roots/docs#566