feat(checker): add advisory check for public export of post content - #1433
Open
faisalahammad wants to merge 1 commit into
Open
feat(checker): add advisory check for public export of post content#1433faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Adds a new security check that flags when post content is written to a file or exposed through an alternative public surface without an apparent access-control guard. Patterns like file_put_contents(), fwrite(), and fputs() on data sourced from the_content(), get_the_content(), get_the_excerpt(), or $post->post_content trigger the warning, along with apply_filters() calls using content filters and get_post_field() with the post_content field. The check is advisory (warning, not error) because access control from third-party plugins cannot be known statically. It prompts manual review rather than asserting a vulnerability. Suppression: the warning is skipped when a guard such as post_password_required(), current_user_can(), is_post_type_viewable(), or is_user_logged_in() appears in the same function scope. Includes the PHPCS sniff, the check wrapper, repository registration, docs row, and unit tests covering both error and clean fixtures.
faisalahammad
force-pushed
the
fix/1427-public-content-export
branch
from
August 8, 2026 17:45
96b507e to
2d82c4f
Compare
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.
What?
Closes #1427
Adds a new advisory (warning-level) security check that flags when post content is written to a file or exposed through an alternative public surface without an apparent access-control guard. This covers static exports, Markdown endpoints, feeds, and REST-like routes that can bypass the access controls of the normal front end.
Why?
Plugins that publish post content through alternative public surfaces can leak password-protected content, membership or LMS-restricted content, and post types with no public URL. Because access control from third-party plugins is not statically knowable, this is a warning, not an error. It highlights risky patterns and prompts manual review rather than asserting a vulnerability.
How?
Added
PublicContentExportSniff, a PHPCS sniff extendingAbstractFunctionParameterSniff. It inspects the content parameter of export functions (file_put_contents,fwrite,fputs) and detects post-content sources:get_the_content(),the_content(),get_the_excerpt(),the_excerpt(),$post->post_content,get_post_field('post_content'), andapply_filters()calls using content filters. It also traces variables back to the assignment that sourced post content.The warning is suppressed when an access-control guard appears in the same function scope:
post_password_required(),current_user_can(),is_post_type_viewable(), oris_user_logged_in().New files:
phpcs-sniffs/PluginCheck/Sniffs/Security/PublicContentExportSniff.phpincludes/Checker/Checks/Security/Public_Content_Export_Check.phpDefault_Check_Repository.phpandruleset.xml, docs row indocs/checks.mdTesting Instructions
npm run test-php(uses wp-env).composer run-tests.composer lintandcomposer phpstan.tests/phpunit/testdata/plugins/test-plugin-public-content-export-*/to see warning and clean cases.Result: all tests pass, lint and static analysis are clean. The with-errors fixture produces 6 warnings, all advisory (never errors).
AI Usage Disclosure
If AI tools were used, please describe how they were used:
Used Claude Code (an AI coding assistant) to help implement the PHPCS sniff, the check wrapper, tests, and fixtures. The implementation was reviewed and adjusted manually, and all quality gates (PHPUnit, PHPCS lint, PHPStan) were run and passed before submission.
Screenshots or screencast
Not applicable, no UI changes.