Sane security defaults for native PHP runtime#3405
Merged
Conversation
…691-sane-security-defaults
This reverts commit ffe41e7.
…691-sane-security-defaults
…nescaping' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…691-sane-security-defaults
Base automatically changed from
f26d/native-php-improved-mu-plugins-writing
to
trunk
May 13, 2026 13:41
Collaborator
📊 Performance Test ResultsComparing cc9e560 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
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.
Related issues
How AI was used in this PR
Claude was used to verify the list of disabled PHP functions and to review the implementation as a whole, through several iterations.
Proposed Changes
Running code from third parties on your local machine is inherently risky. There's no sandbox with our native PHP runtime, so machines could be compromised in any number of ways (extracting secrets, running malicious code, etc). This PR applies some sane security defaults that reduce risk. We aim to strike a good balance between relatively secure defaults and still allowing most typical WordPress sites to function perfectly normally.
getDefaultPhpArgswhen invoking the PHP binaries.memory_limitto 512 MB. This has nothing to do with security, but I noticed that the default is 128 MB, which isn't enough for a site with a few plugins installed.open_basedirrestriction to the PHP binary. See docs. This is applied to the web server that runs the website.open_basedirlist is the most complex piece of logic in this PR, because we want symlinked plugins and themes to just work. To do this, we resolve any symlinks contained in the site directory and watch thewp-contentdirectory for new symlinks added while the site is running. The symlink watcher triggers a PHP process restart.disable_functionsrestriction to the PHP binary that prevents PHP from doing a bunch of things that malicious plugins could use to compromise the current machine.Testing Instructions
STUDIO_RUNTIME=native-php npm startruntime: native-php, create a new onenode apps/cli/dist/cli/main.mjs wp core versionand ensure it works (do this before testing wp-admin)Pre-merge Checklist