Repository navigation
fix(security): restrict Posts Grid and Atomic Wind to publicly viewable post types - #3194
Conversation
… Wind Posts Grid passed its `postTypes` attribute, and the Atomic Wind box passed its `queryPostType` attribute, straight into WP_Query without checking that the post type is public. A Contributor could point either block at a non-public post type whose entries use the `publish` status (a contact-form inbox, store coupons) and read their titles and excerpts in the preview. - Posts Grid: keep only `is_post_type_viewable()` types; an explicit list of only non-public types returns nothing instead of falling back to posts. - Atomic Wind box: skip the query loop when `queryPostType` is not viewable. - Atomic Wind custom field: skip protected (`_`-prefixed) meta keys, so a Contributor cannot print a submitter's stored contact data either. This extends the `is_post_type_viewable()` check added for the `/otter/v1/dynamic` REST routes to these two block renderers. Reported-by: Deus Rex research team <research@deusrex.ai>
Bundle Size Diff
|
|
Plugin build for 047cdc4 is ready 🛎️!
|
E2E TestsPlaywright Test Status: See serial and parallel matrix jobs Performance ResultsserverResponse: {"q25":270.95,"q50":288.12,"q75":299.58,"cnt":10}, firstPaint: {"q25":1022.1,"q50":1076.64,"q75":1193.17,"cnt":10}, domContentLoaded: {"q25":2756.86,"q50":2803.14,"q75":2867.3,"cnt":10}, loaded: {"q25":2759.93,"q50":2806.3,"q75":2870.53,"cnt":10}, firstContentfulPaint: {"q25":1836.45,"q50":2194.25,"q75":2270.33,"cnt":10}, firstBlock: {"q25":12676.66,"q50":12999.87,"q75":13246.34,"cnt":10}, type: {"q25":23.02,"q50":26.35,"q75":32.37,"cnt":10}, typeWithoutInspector: {"q25":19.86,"q50":23.04,"q75":23.95,"cnt":10}, typeWithTopToolbar: {"q25":27.9,"q50":31.96,"q75":34.31,"cnt":10}, typeContainer: {"q25":12.94,"q50":13.52,"q75":15.37,"cnt":10}, focus: {"q25":111.69,"q50":114.94,"q75":115.44,"cnt":10}, inserterOpen: {"q25":33.42,"q50":34.33,"q75":37.6,"cnt":10}, inserterSearch: {"q25":23.23,"q50":23.42,"q75":24.43,"cnt":10}, inserterHover: {"q25":5.13,"q50":5.48,"q75":5.8,"cnt":20}, loadPatterns: {"q25":1502.6,"q50":1525.87,"q75":1573.28,"cnt":10}, listViewOpen: {"q25":176.64,"q50":182.34,"q75":185.27,"cnt":10} |
There was a problem hiding this comment.
🟡 Changes requested
The post-type filters hold. Protected meta is still readable through ACF field keys and Pro dynamic tags, so the fix is incomplete.
plugins/otter-pro/inc/plugins/class-dynamic-content.php:760—securityThe fix blocks protected meta only in the Atomic Windcustom_field. With Pro active, a Contributor can still read protected meta of looped posts in a draft preview. A dynamic tag withtype=acf,context=query,metaKey=_purchase_noteprints it throughget_acf()(lines 248-249, 285-289). A dynamic image withtype=postMeta,meta=_purchase_noteprints it intosrc(lines 680-691, 754-760). ApostMetablock condition withif_containsreveals it (class-block-conditions.php:128-163). Reject protected keys withis_protected_meta_key()in each getter and the condition, and check the resolved ACF field name too. Add cases totests/test-dynamic-content.phpandtests/test-block-conditions.php. This assumes licensed Otter Pro is active, and ACF for theacfpath.
Validation details
- Files reviewed: 4/4 changed files. The row "consumer: Atomic_Wind_Blocks::render_query_loop() return changed" was read but not run.
- PHPUnit 9.6.5 on PHP 8.3 ran the six added tests at HEAD. All passed
cd /repo && set -o pipefail; timeout 200 vendor/bin/phpunit --do-not-cache-result --filter 'TestAtomicWindBlocks::test_(…(run R4, exit 0). - On the base tree, the three negative tests failed, so they detect the change.
- Existing
test_renderfailures are the same on base. Build assets are missingcd /repo && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Post_Grid_Block::' 2>&1…(run R3, exit 0).
Questions for the author
- Can a site filter on
is_protected_metaunprotect a sensitive_key? The new gate uses that filterable core check.
Untested areas
- Render_query_loop return consumer row: consumers were read, not run.
- Posts Grid editor lists
publictypes, not viewable ones. No real mismatching type was found. - Pro search
o_post_typealso accepts non-viewable types. It is outside this change. - No site or browser run.
- The variant pass did not settle these places, where the fixed cause may still reach:
plugins/otter-pro/inc/server/class-live-search-server.php:50-77,191-216— unverified: Main search accepts arbitrary ?s=…&o_post_type=flamingo_inbound without classification. REST live search and review discovery classify by public, not viewability. Explore whether i…plugins/otter-pro/inc/server/class-filter-blocks-server.php:88-118— unverified: Main search accepts arbitrary ?s=…&o_post_type=flamingo_inbound without classification. REST live search and review discovery classify by public, not viewability. Explore whether i…plugins/otter-pro/inc/plugins/class-posts-acf-integration.php:44-67— unverified: ACF text, media and Posts Grid custom-field paths lack a protected-key gate. Whether registered protected fields or alternate selectors expose their values requires the installed A…
🤖 Automated review · run code-review-agent_6b0070cde8a2c6.82507308.
🤖 Review agent — review posted ✅ on 81bc2617 · changes requested · 3 findings · 32 min
Run code-review-agent_6b0070cde8a2c6.82507308 · trail
…field The custom field gate checked the selector, not the meta key ACF reads. When ACF is active, an ACF field key (e.g. `field_abc123`) passes is_protected_meta(), but ACF resolves it to the field's name, which can be a `_`-prefixed protected key holding a form submitter's data. - Resolve the field with get_field_object() and run is_protected_meta() on the field name too, before reading the value. - Add tests with a field key whose field name is protected (skipped) and public (read), backed by minimal ACF stubs. - Posts Grid: assert an all-non-viewable list renders nothing, instead of falling back to posts (covers the early return).
There was a problem hiding this comment.
🟡 Changes requested
The ACF field-key gap and the Posts Grid test gap are fixed. Protected meta is still readable through Pro dynamic tags, media and conditions.
plugins/otter-pro/inc/plugins/class-dynamic-content.php:760—securityProtected meta of looped posts is still readable with Pro active. A Contributor's draft preview can print it three ways. A dynamic tag withtype=acf,context=query,metaKey=_purchase_noteprints it throughget_acf()(lines 248-249, 285-289). A dynamic image withtype=postMeta,meta=_purchase_noteputs it intosrc(lines 680-691, 754-760). ApostMetablock condition withif_containsreveals it (class-block-conditions.php:128-163). Reject protected keys withis_protected_meta()in each getter and the condition, and check the resolved ACF field name too. Add cases totests/test-dynamic-content.phpandtests/test-block-conditions.php. This assumes licensed Otter Pro is active, and ACF for theacfpath.
Validation details
- Files reviewed: 3/3 files changed since the prior review. The row "consumer: Atomic_Wind_Blocks::render_query_loop() return changed" was read in the prior run but not executed.
- PHPUnit 9.6.5 on PHP 8.3.36 ran the custom field tests at HEAD.
cd /repo; echo $WP_TESTS_DIR; set -o pipefail; timeout 600 vendor/bin/phpunit --do-not-cache-result --filter 'TestAtomic…printedOK (4 tests, 7 assertions)(run R1) - With the prior
class-atomic-wind-blocks.php, the new ACF test fails.cd /workspace/checks/C1/c-prior; set -o pipefail; timeout 600 vendor/bin/phpunit --do-not-cache-result --filter 'TestAto…(run R7, exit 0) - Without the early return in
retrieve_posts, the new Posts Grid assertion fails.cd /workspace/checks/C1/d-mutant; set -o pipefail; timeout 600 vendor/bin/phpunit --do-not-cache-result --filter 'Test_P…(run R8, exit 0) - ACF 6.8.12 reads the same meta name that
get_field_object()returns. This was checked in the ACF source.
Untested areas
- The variant pass was not rerun. The prior run's pass is reused.
- The render_query_loop return consumers were read, not executed.
- No site or browser run was done. The Pro paths are checked in source only.
🤖 Automated review · run code-review-agent_6b00835276e2f8.08223861.
🤖 Review agent — review posted ✅ on 3449d087 · changes requested · 1 finding · 11 min
Run code-review-agent_6b00835276e2f8.08223861 · trail
Move the protected custom-field meta hardening out of this PR. That guard was the issue's out-of-scope note, and extending it correctly (Atomic Wind plus the Otter Pro dynamic-content and block-conditions paths, at the permission layer so front-end meta display is unaffected) is a separate security issue. This PR now only restricts Posts Grid and the Atomic Wind box query loop to publicly viewable post types, which is the reported bug.
There was a problem hiding this comment.
🟡 Changes requested
The two block gates hold, but Otter Pro search still lets anonymous visitors query non-public post types through o_post_type.
plugins/otter-pro/inc/server/class-live-search-server.php:81—securityThe same non-public post type leak stays open in Otter Pro search.parse_query()copies?o_post_type=into the main search query without a visibility check. An anonymous visitor can open/?s=a&o_post_type=flamingo_inboundand read stored message titles and excerpts. WordPress queries an explicit post type list with public statuses only, and these entries arepublish. The server boots on every Pro install, without a license or module gate. Filter the exploded types throughis_post_type_viewable()and skip the override when none remain. Add a case totests/test-live-search.phpwith a non-viewable type that has a published post. This assumes an active plugin registers such a type with published entries, and the theme prints search results.
Validation details
- Files reviewed: 2/2 files changed since the prior review. The row "consumer: Atomic_Wind_Blocks::render_query_loop() return changed" was read in an earlier run but not executed.
- The new commit restores the custom field code to its base form. The earlier protected meta finding is now out of scope. The PR body says a separate security issue tracks it.
- The Posts Grid and Atomic Wind gates are unchanged. Their PHPUnit runs from run code-review-agent_6b00835276e2f8.08223861 are reused, not rerun.
- WordPress 6.8.3
class-wp-query.phpqueries an explicit post type list with public statuses and no visibility check.
Untested areas
- REST live search for a public type that is not publicly queryable was not verified.
- Editor previews through core REST were not verified.
- No site or browser run was done. The search finding is checked in source only.
- The variant pass did not settle these places, where the fixed cause may still reach:
src/blocks/blocks/posts/edit.js:155-161,201-219— unverified: Editor previews still pass attribute-controlled types to core entity REST queries. Missing fact: version-matched REST registration and record-permission checks for non-viewable typ…src/atomic-wind/query/use-query-preview.js:21-40— unverified: Editor previews still pass attribute-controlled types to core entity REST queries. Missing fact: version-matched REST registration and record-permission checks for non-viewable typ…
🤖 Automated review · run code-review-agent_6b00b92314cf01.50258550.
🤖 Review agent — review posted ✅ on 80e14bfb · changes requested · 1 finding · 12 min
Run code-review-agent_6b00b92314cf01.50258550 · trail
Otter Pro live search copied `?o_post_type=` straight into the main search query, so an anonymous visitor could query a non-public post type whose entries are `publish` (e.g. a contact-form inbox) and read their titles and excerpts. The REST `prepare_search_query()` path already filters these; the main-query `parse_query()` path did not. Filter the requested types through `is_post_type_viewable()` and skip the override when none remain.
|
Review responses (round)
|
There was a problem hiding this comment.
🟢 Approved
The PR passes: Otter Pro search now drops non-viewable post types from ?o_post_type=, which fixes the earlier search finding.
Validation details
- Files reviewed: 2/2 files changed since the prior review. The row "consumer: Atomic_Wind_Blocks::render_query_loop() return changed" was read in earlier runs but not executed.
- The two new live search tests pass at HEAD:
cd /repo; grep -n "function test_" tests/test-live-search.php; cd /repo; set -o pipefail; timeout 280 vendor/bin/phpunit…printedOK (2 tests, 2 assertions)(run R2) - On the base tree, both new tests fail on their assertions. The helper run kept no run record.
- The Posts Grid and Atomic Wind gates are unchanged. Their results from run code-review-agent_6b00b92314cf01.50258550 are reused, not rerun.
Untested areas
- The REST live search allows public types that are not publicly queryable. No plugin was found that stores private data in such a type.
- Editor previews through core REST were not verified.
- No site or browser run was done.
- The variant pass did not settle these places, where the fixed cause may still reach:
plugins/otter-pro/inc/server/class-live-search-server.php:120-129,142-171,196-221— unverified: /otter/v1/live-search still uses public=true and exclude_from_search=false, not viewability. A custom type with those flags but publicly_queryable=false is the remaining candidate.…src/blocks/blocks/posts/edit.js:155-161,201-219— unverified: Carried forward unchanged; core REST registration and record-permission behavior for non-viewable types remains unverified, as assigned.src/atomic-wind/query/use-query-preview.js:21-40— unverified: Carried forward unchanged; the same core REST dependency fact remains missing.
🤖 Automated review · run code-review-agent_6b00c1e03ab428.12322009.
🤖 Review agent — review posted ✅ on 047cdc42 · approved · 0 findings · 13 min
Run code-review-agent_6b00c1e03ab428.12322009 · trail
|
🎉 This PR is included in version 3.2.12 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Posts Grid passed its
postTypesattribute, and the Atomic Wind Box passed itsqueryPostTypeattribute, straight intoWP_Querywithout checking the post type is public. A Contributor could add either block to a draft, point it at a non-public post type whose entries use thepublishstatus (for example a contact-form inbox or store coupons), and read their titles and excerpts in the preview. This extends theis_post_type_viewable()check already used for the/otter/v1/dynamicREST routes to these two block renderers.What changed
Posts Grid (
retrieve_posts) — the queried post types are filtered throughis_post_type_viewable(). An explicit list of only non-public types returns nothing, instead of falling back to posts. A list with no types keeps the previous default.Atomic Wind Box (
render_query_loop) — thequeryPostTypevalue is sanitized and checked withis_post_type_viewable(). A non-public type renders nothing instead of looping its records.Note
Public post types (posts, pages, products) still render in both blocks.
Scope
The report's side note about a protected custom-field meta read is handled separately: that exposure also reaches the Otter Pro dynamic-content and block-conditions paths, and the correct fix is at the permission layer (so front-end display of
_-prefixed meta is unaffected). It is tracked in Codeinwp/otter-internals#320. This PR is limited to the reported non-public post type bug.QA
Activate a plugin that registers a non-public post type with published entries (for example Flamingo with a stored Contact Form 7 message). As an Administrator note one entry's title.
Log in as a Contributor. Create a draft and switch to the Code editor.
Add the Posts Grid block pointed at that non-public type:
<!-- wp:themeisle-blocks/posts-grid {"postTypes":["flamingo_inbound"]} /-->Save the draft and open the preview.
Expect: the grid is empty; no stored message title or excerpt appears.
Add an Atomic Wind Box with
queryPostTypeset to the same non-public type, with a Text child whosepostFieldistitle. Save and preview.Expect: the box renders nothing for that type.
Set the Posts Grid
postTypesto["post"]. Preview.Expect: published posts render as before.
Reported-by: Deus Rex research team research@deusrex.ai
Tracked internally in Codeinwp/otter-internals#319 (target branch is
development, not the default, so this does not auto-close — link it through the Development sidebar).