Skip to content

fix(security): restrict Posts Grid and Atomic Wind to publicly viewable post types - #3194

Merged
vytisbulkevicius merged 4 commits into
developmentfrom
fix/319-nonpublic-post-types
Nov 23, 2026
Merged

vytisbulkevicius merged 4 commits into
developmentfrom
fix/319-nonpublic-post-types

Conversation

@vytisbulkevicius

@vytisbulkevicius vytisbulkevicius commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Posts Grid passed its postTypes attribute, and the Atomic Wind Box passed its queryPostType attribute, straight into WP_Query without 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 the publish status (for example a contact-form inbox or store coupons), and read their titles and excerpts in the preview. This extends the is_post_type_viewable() check already used for the /otter/v1/dynamic REST routes to these two block renderers.

What changed

  • Posts Grid (retrieve_posts) — the queried post types are filtered through is_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) — the queryPostType value is sanitized and checked with is_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

  1. 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.

  2. Log in as a Contributor. Create a draft and switch to the Code editor.

  3. 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.

  4. Add an Atomic Wind Box with queryPostType set to the same non-public type, with a Text child whose postField is title. Save and preview.

    Expect: the box renders nothing for that type.

  5. Set the Posts Grid postTypes to ["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).

… 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>
@pirate-bot

Copy link
Copy Markdown
Contributor

Bundle Size Diff

Package Old Size New Size Diff
Animations 178.5 KB 178.5 KB 0 B (0.00%)
Blocks 1.65 MB 1.65 MB 0 B (0.00%)
CSS 7.83 KB 7.83 KB 0 B (0.00%)
Dashboard 174.07 KB 174.07 KB 0 B (0.00%)
Onboarding 68.14 KB 68.14 KB 0 B (0.00%)
Export Import 4.73 KB 4.73 KB 0 B (0.00%)
Pro 440.37 KB 440.37 KB 0 B (0.00%)

@pirate-bot

pirate-bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Plugin build for 047cdc4 is ready 🛎️!

@pirate-bot

pirate-bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

E2E Tests

Playwright Test Status: See serial and parallel matrix jobs

Performance Results serverResponse: {"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}

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 — security The fix blocks protected meta only in the Atomic Wind custom_field. With Pro active, a Contributor can still read protected meta of looped posts in a draft preview. A dynamic tag with type=acf, context=query, metaKey=_purchase_note prints it through get_acf() (lines 248-249, 285-289). A dynamic image with type=postMeta, meta=_purchase_note prints it into src (lines 680-691, 754-760). A postMeta block condition with if_contains reveals it (class-block-conditions.php:128-163). Reject protected keys with is_protected_meta_key() in each getter and the condition, and check the resolved ACF field name too. Add cases to tests/test-dynamic-content.php and tests/test-block-conditions.php. This assumes licensed Otter Pro is active, and ACF for the acf path.
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_render failures are the same on base. Build assets are missing cd /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_meta unprotect 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 public types, not viewable ones. No real mismatching type was found.
  • Pro search o_post_type also 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

Comment thread tests/test-post-grid-block.php Resolved
…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).

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 — security Protected meta of looped posts is still readable with Pro active. A Contributor's draft preview can print it three ways. A dynamic tag with type=acf, context=query, metaKey=_purchase_note prints it through get_acf() (lines 248-249, 285-289). A dynamic image with type=postMeta, meta=_purchase_note puts it into src (lines 680-691, 754-760). A postMeta block condition with if_contains reveals it (class-block-conditions.php:128-163). Reject protected keys with is_protected_meta() in each getter and the condition, and check the resolved ACF field name too. Add cases to tests/test-dynamic-content.php and tests/test-block-conditions.php. This assumes licensed Otter Pro is active, and ACF for the acf path.
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… printed OK (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.

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 — security The 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_inbound and read stored message titles and excerpts. WordPress queries an explicit post type list with public statuses only, and these entries are publish. The server boots on every Pro install, without a license or module gate. Filter the exploded types through is_post_type_viewable() and skip the override when none remain. Add a case to tests/test-live-search.php with 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.php queries 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.
@vytisbulkevicius

Copy link
Copy Markdown
Contributor Author

Review responses (round)

  • F6 (live search o_post_type): fixed in 047cdc4. Live_Search_Server::parse_query() now filters the requested types through is_post_type_viewable() and skips the override when none remain, so an anonymous /?s=a&o_post_type=flamingo_inbound cannot query a non-public type. Added test_o_post_type_skips_non_viewable_type and test_o_post_type_keeps_only_viewable_types. (prepare_search_query(), the REST path, already filtered.)
  • Variant editor-preview paths (posts/edit.js, use-query-preview.js): these call core's entity REST, which enforces its own per-type show_in_rest + record permissions; a non-public type without REST exposure returns nothing there. Not a leak through these blocks; left unchanged.

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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… printed OK (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

@vytisbulkevicius
vytisbulkevicius merged commit aa2d9f2 into development Nov 23, 2026
15 checks passed
@vytisbulkevicius
vytisbulkevicius deleted the fix/319-nonpublic-post-types branch November 23, 2026 12:16
@pirate-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.2.12 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Indicate that an issue has been resolved and released in a particular version of the product.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants