Skip to content

fix(security): block protected post meta in dynamic content, conditions and Atomic Wind - #3195

Merged
vytisbulkevicius merged 11 commits into
developmentfrom
fix/320-protected-meta
Nov 23, 2026
Merged

vytisbulkevicius merged 11 commits into
developmentfrom
fix/320-protected-meta

Conversation

@vytisbulkevicius

Copy link
Copy Markdown
Contributor

Several Otter paths read post meta by a request-supplied key and surface the value, without the protected-key check the text, author and user-meta dynamic-content getters already apply (is_protected_meta_key()). A Contributor can read a protected _-prefixed key of a published post — e.g. a product's _purchase_note, or _-meta that holds tokens or internal data — through an editor preview. Found while reviewing #3194 (the non-public post type fix).

What changed

  • Dynamic content (get_acf, evaluate_content_media_server, evaluate_content_media_content) — guarded with is_protected_meta_key(), matching the existing text/author/user-meta getters. A new is_protected_acf_field() rejects an ACF field key that resolves to a protected field name.

  • Block conditions (has_meta) — a protected key is never read, so its value cannot leak through the comparison result (the if_contains oracle).

  • Atomic Wind custom_field — skips protected keys, including the ACF-resolved field name.

Note

This completes an existing protection pattern; the dynamic-content text, author and user-meta getters already reject protected keys, so blocking _-prefixed keys here is consistent, not new behavior. Front-end rendering is unaffected (public keys still render).

QA

  1. As an Administrator, add a published post (or WooCommerce product) and give it a protected meta key, e.g. _secret = sensitive.

  2. Log in as a Contributor. In a draft, use an ACF dynamic tag / a dynamic image / an Atomic Wind custom field pointed at that post's _secret (and a block condition on it). Open the preview.

    Expect: no _secret value appears, the image src is not set from it, and the condition does not reveal it. A non-protected key still renders.

Reported-by: Deus Rex research team research@deusrex.ai

Tracked internally in Codeinwp/otter-internals#320 (target branch is development, not the default, so this does not auto-close — link it through the Development sidebar).

…mic Wind

The dynamic-content `acf` tag, the `postMeta`/`acf` dynamic image, the
`postMeta` block condition and the Atomic Wind `custom_field` read post meta
by a request-supplied key and surface the value, without the protected-key
check the text, author and user-meta getters already apply. A Contributor
could read a protected `_`-prefixed key of a published post (e.g. a product's
`_purchase_note`, or `_`-meta holding tokens) through an editor preview.

- Dynamic_Content: guard `get_acf()`, `evaluate_content_media_server()` and
  `evaluate_content_media_content()` with `is_protected_meta_key()`, and add
  `is_protected_acf_field()` so an ACF field key that resolves to a protected
  name is rejected too.
- Block_Conditions::has_meta(): never read a protected key, so its value cannot
  leak through the comparison result.
- Atomic Wind `custom_field`: skip protected keys, including the ACF-resolved
  field name.
- Tests for each path; the shared ACF test fixture also stubs get_field/
  get_field_object.
@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 ee8616d is ready 🛎️!

@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

Two read paths still return protected ACF values, so the fix is incomplete. Three changed guards also need tests.

  • plugins/otter-pro/inc/plugins/class-posts-acf-integration.php:79 — security The Posts Grid ACF meta still prints protected fields. This assumes licensed Otter Pro, active ACF, and a populated field whose name is protected. The PR blocks ACF fields whose name is protected in dynamic content and Atomic Wind. The Posts Grid filter calls get_field_object( $custom_meta_field['field'], $id ) and prints its value with no protected check. A Contributor can set customMetas[].field to a field key whose name is _secret and see that value of every listed post in preview. Skip the field when Dynamic_Content::is_protected_meta_key() is true for the selector or the resolved name (and its parents, per F1). Add a PHPUnit case under tests/ that expects no value for such a field.
Validation details
  • Files reviewed: 7/7 changed files. One history question stays unchecked: "A new check on a request or attribute value must tolerate null, a missing key or a non-string."
  • The seven added tests pass at HEAD. Six of them fail on pr-base at the changed assertion. The A/B helper saved no run record.
  • `mkdir -p /workspace/checks/C7 && cat > /workspace/checks/C7/C7ParentLeakTest.php <<'EOF'
Untested areas - The real ACF plugin was not installed. ACF behavior comes from ACF 6.8.12 source and repository stubs. - No browser preview was run. - It is unclear whether `test_custom_field_renders_a_public_meta_key` duplicates `test_post_field_custom_field`. The base run loaded HEAD code through the autoloader. - The null or non-string meta key question was not settled. It applies to `is_protected_meta_key()` in block conditions and the media endpoint.
🤖 Automated review · run code-review-agent_6b00bbc1aab994.42524117. --- **🤖 Review agent** — review posted ✅ on `51bd6cee` · [changes requested · 3 findings](https://github.com//pull/3195#pullrequestreview-5999883268) · 22 min Run `code-review-agent_6b00bbc1aab994.42524117` · [trail](https://agents.vertistudio.com/admin/trails/github-pr/Codeinwp-otter-blocks-3195)

- is_protected_acf_field(): walk the ACF parent chain, so a sub-field under a
  protected repeater (reached through the repeater fallback) is rejected too.
- Posts_ACF_Integration::render_acf_fields(): skip a protected field selector
  or resolved field name, matching the dynamic-content guards.
- Tests: a sub-field under a `_secret` repeater returns the default; the Posts
  Grid ACF field prints nothing for a protected field; the dynamic image
  blocks a protected postMeta.
@vytisbulkevicius

Copy link
Copy Markdown
Contributor Author

F2 (Posts Grid ACF, class-posts-acf-integration.php): fixed in a0cb17e. render_acf_fields() now skips the field when Dynamic_Content::is_protected_meta_key() or is_protected_acf_field() (which walks the parent chain) is true for the selector. Added test_posts_acf_integration_blocks_a_protected_field.

@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":333.38,"q50":361.67,"q75":368.58,"cnt":10}, firstPaint: {"q25":1247.46,"q50":1282.97,"q75":1291.66,"cnt":10}, domContentLoaded: {"q25":3446.26,"q50":3478.83,"q75":3536.42,"cnt":10}, loaded: {"q25":3449.26,"q50":3482.03,"q75":3539.58,"cnt":10}, firstContentfulPaint: {"q25":2113.95,"q50":2458.4,"q75":2617.88,"cnt":10}, firstBlock: {"q25":15960.91,"q50":16225.99,"q75":16407.92,"cnt":10}, type: {"q25":29.66,"q50":34.43,"q75":37.9,"cnt":10}, typeWithoutInspector: {"q25":25.2,"q50":29.17,"q75":30.94,"cnt":10}, typeWithTopToolbar: {"q25":32.85,"q50":38.62,"q75":41.99,"cnt":10}, typeContainer: {"q25":13.76,"q50":15.4,"q75":17.04,"cnt":10}, focus: {"q25":128.23,"q50":131.34,"q75":142.15,"cnt":10}, inserterOpen: {"q25":42.05,"q50":43.88,"q75":45.66,"cnt":10}, inserterSearch: {"q25":27.63,"q50":29.05,"q75":30.4,"cnt":10}, inserterHover: {"q25":4.9,"q50":5.22,"q75":5.73,"cnt":20}, loadPatterns: {"q25":1777.47,"q50":1804.1,"q75":1853.87,"cnt":10}, listViewOpen: {"q25":214.53,"q50":231.34,"q75":237.25,"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 two leak fixes work, but the two ACF image guards still have no test. Add the test stub described in the open thread.

Validation details
  • Files reviewed: 4/4 files changed since the prior review.
  • The Posts Grid ACF leak from the prior review body is fixed. Its new test passes at HEAD and prints the value on pr-base.
  • The sub-field test fails with the previous class file: D=/tmp/opencode/C1-51bd; rm -rf $D; mkdir -p $D; cd /repo && git ls-files -z | tar --null -T - -cf - | tar -x -C $D && c… printed ACF Secret (run R6)
  • An ACF media test with a stub ACF class fails on pr-base: cd /tmp/opencode && rm -rf C5-base && cp -a C5-git C5-base && cd C5-base && for f in $(git -C /tmp/opencode/C5-git diff … printed evil.example (run R14)
  • test_posts_grid_category_names_remain_literal_in_nested_blocks fails on pr-base and HEAD alike. This PR does not cause it.
Untested areas
  • The real ACF and ACF Pro plugins were not installed. Only the repository stubs ran.
  • Flexible-content and clone parent links in ACF Pro were not checked.
  • Atomic Wind with a sub-field under a protected ACF parent was not run.
  • No browser preview was run.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • inc/plugins/class-atomic-wind-blocks.php:1393-1428 — unverified: Direct and resolved field names are checked with is_protected_meta() before output-producing reads, but ancestors are not checked and neither shared helper is called. Whether an or…
    • plugins/otter-pro/inc/plugins/class-dynamic-content.php:199-208 — unverified: The shared classifier checks empty keys, prefixes and three sensitive names, but never calls is_protected_meta(). Whether another non-prefixed key is classified protected in the s…

🤖 Automated review · run code-review-agent_6b00c2ea0d7d05.54494153.


🤖 Review agent — review posted ✅ on a0cb17ec · changes requested · 1 finding · 18 min

Run code-review-agent_6b00c2ea0d7d05.54494153 · trail

Comment thread tests/test-dynamic-content.php Resolved
- Add a guarded `ACF` stub class to the shared fixture so the
  `class_exists( 'ACF' )`-gated image branches run under tests.
- Test the ACF branch of evaluate_content_media_server() and
  evaluate_content_media_content() blocks a field resolving to a protected
  name.
- Test is_protected_acf_field() returns false on a cyclic parent chain
  (and terminates), so the cycle guard is covered.

@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 new tests fix both earlier threads. The shared protected-key check still ignores the is_protected_meta filter.

Validation details
  • Files reviewed: 3/3 files changed since the prior review. The non-test code is unchanged since a0cb17e.
  • The three new tests pass at HEAD: mkdir -p /workspace/checks/R1; cd /repo; set -o pipefail; timeout 300 vendor/bin/phpunit --do-not-cache-result --filter … printed OK (3 tests, 3 assertions) (run R1)
  • Both ACF image tests fail with the pr-base code: cd /tmp/opencode/R1-prbase && set -o pipefail; vendor/bin/phpunit --do-not-cache-result --filter test_media_server_block… printed does not contain "evil.example" (run R12) and cd /tmp/opencode/R1-prbase && set -o pipefail; vendor/bin/phpunit --do-not-cache-result --filter test_media_content_bloc… printed does not contain "evil.example" (run R13)
  • The cycle test hangs without the guard cd /tmp/opencode/R1-nobreak; set -o pipefail; timeout 30 vendor/bin/phpunit --do-not-cache-result --filter 'TestDynamicC… (run R3, exit 0) and passes with it cd /tmp/opencode/R1-nobreak; cp /repo/plugins/otter-pro/inc/plugins/class-dynamic-content.php plugins/otter-pro/inc/plug… (run R4, exit 0).
  • The ACF stub changes no other test result in the full suite cd /workspace/checks/R1; cat > /tmp/opencode/junit2tsv.py <<'EOF' import sys, xml.etree.ElementTree as ET t = ET.parse(s… (run R7, exit 0).
  • Atomic Wind cannot read a protected ACF parent. ACF 6.8.6 reads only the selected field name.
Untested areas
  • The real ACF and ACF Pro plugins were not installed. Only the repository stubs ran.
  • No browser preview was run.
  • The variant pass was not run again. The non-test code did not change since the prior review.

🤖 Automated review · run code-review-agent_6b00c90d1e6a74.05746851.


🤖 Review agent — review posted ✅ on cb09d219 · changes requested · 1 finding · 20 min

Run code-review-agent_6b00c90d1e6a74.05746851 · trail

…heck

is_protected_meta_key() only matched a `_` prefix and three named keys, so a
key another plugin protects through the `is_protected_meta` filter without a
`_` prefix (e.g. NextScripts SNAP's keys) still leaked through get_acf(),
has_meta() and the postMeta/acf getters. Fall back to is_protected_meta() so
those are caught too, matching the Atomic Wind custom field.

Add a test that filters a non-prefixed key as protected and expects the
fallback.

@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 filter fix works for post meta. Author meta still ignores an is_protected_meta filter that protects a key only for user meta.

Validation details
  • Files reviewed: 2/2 files changed since the prior review.
  • The four consumer test classes pass at HEAD: cd /repo && set -o pipefail; timeout 300 vendor/bin/phpunit --do-not-cache-result --filter 'TestDynamicContent::' 2>&1 |… printed OK (162 tests, 1062 assertions) (run R16), cd /repo && set -o pipefail; timeout 300 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Dynamic_Content_Server:… printed OK (7 tests, 14 assertions) (run R17), cd /repo && set -o pipefail; timeout 300 vendor/bin/phpunit --do-not-cache-result --filter 'TestBlockConditions::' 2>&1 … printed OK (31 tests, 36 assertions) (run R18), cd /repo && set -o pipefail; timeout 300 vendor/bin/phpunit --do-not-cache-result --filter 'TestAtomicWindBlocks::' 2>&1… printed OK (164 tests, 363 assertions) (run R19).
  • The new filter test fails with the cb09d21 helper: cd /tmp/opencode/prior-head; set -o pipefail; timeout 200 vendor/bin/phpunit --do-not-cache-result --filter 'TestDynamic… (run R6, exit 0) exits with code 1.
  • The author-meta leak was reproduced with a scratch test: cd /tmp/opencode/R1b/repo && python3 - <<'EOF' import re p='tests/test-r1b-scratch.php' s=open(p).read() s=s.replace("ad… (run R21, exit 0).
Untested areas
  • The pr-base run of the new test has only saved logs, not a run record.
  • Real ACF, ACF Pro and NextScripts SNAP were not installed.
  • No browser preview was run.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • plugins/otter-pro/inc/plugins/class-block-conditions.php:137-148 — unverified: Author/current-user getters and user conditions classify keys as post metadata. A non-prefixed key protected only for 'user' may remain readable. Missing: installed WordPress filte…

🤖 Automated review · run code-review-agent_6b00cf4c47a4c7.76351478.


🤖 Review agent — review posted ✅ on 02d81e68 · changes requested · 1 finding · 21 min

Run code-review-agent_6b00cf4c47a4c7.76351478 · trail

…meta

is_protected_meta_key() always passed 'post' to is_protected_meta(), so a key
a plugin protects only for 'user' meta leaked through get_author_meta(),
get_loggedin_meta() and the user branch of has_meta(). Add a $meta_type
parameter and pass 'user' from those callers.

@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 user-only filter fix works. Author meta still returns the password hash through the pass alias, so normalize core aliases first.

Validation details
  • Files reviewed: 3/3 files changed since the prior review.
  • HEAD passes TestDynamicContent: cd /repo; set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'TestDynamicContent::' 2>&1 | t… printed OK (163 tests, 1064 assertions) (run R2)
  • HEAD passes TestBlockConditions: cd /repo; set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'TestBlockConditions::' 2>&1 | … printed OK (31 tests, 36 assertions) (run R3)
  • The new author-meta test fails on the 02d81e6 helper: set -o pipefail; D=/workspace/checks/R1/prior-head; rm -rf $D; mkdir -p $D; cd /repo; tar --exclude=./node_modules --exc… printed Failed asserting that two strings are identical. (run R4)
  • A scratch test returned the user_pass hash for pass at HEAD R=/workspace/checks/R2; python3 - <<'EOF' p='/workspace/checks/R2/test-r2-author-alias.php' s=open(p).read() s=s.replace… (run R8, exit 0) and at pr-base R=/workspace/checks/R2; cd $R/base && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'Te… (run R9, exit 0).
Untested areas
  • Real ACF and ACF Pro were not installed.
  • No browser preview was run. The preview path for pass was traced from source only.
  • The pr-base run of the new test printed no run record.

🤖 Automated review · run code-review-agent_6b01508fef9576.59666397.


🤖 Review agent — review posted ✅ on 034bf182 · changes requested · 2 findings · 15 min

Run code-review-agent_6b01508fef9576.59666397 · trail

…e hash

get_the_author_meta() maps aliases like `pass` and `activation_key` to
`user_pass`/`user_activation_key`, but is_protected_meta_key() matched only the
full names, so metaKey `pass` returned the author's password hash. Normalize
the user-field aliases to their `user_*` form before the check.

Add tests: author meta blocks `pass`/`activation_key`; and user-only
is_protected_meta filters are honored for get_loggedin_meta() and the
loggedInUserMeta block condition.

@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

Both earlier findings are fixed. The new alias rewrite hides some user meta keys from the is_protected_meta filter, and back-compat author keys still bypass it.

Validation details
  • Files reviewed: 3/3 files changed since the prior review.
  • The new dynamic-content tests pass at HEAD: cd /repo && set -o pipefail; vendor/bin/phpunit --do-not-cache-result --filter 'TestDynamicContent::test_(author_meta_bl… printed OK (2 tests, 3 assertions) (run R5)
  • The new condition test passes at HEAD: cd /repo && vendor/bin/phpunit --do-not-cache-result --filter 'TestBlockConditions::test_logged_in_user_meta_ignores_use… printed OK (1 test, 1 assertion) (run R17)
  • The new tests fail on pr-base: cd /workspace/checks/R1/wt/prbase && vendor/bin/phpunit --do-not-cache-result --filter 'TestDynamicContent::test_(author… printed Tests: 2, Assertions: 2, Failures: 2. (run R14) and cd /workspace/checks/R1/wt/prbase && vendor/bin/phpunit --do-not-cache-result --filter 'TestBlockConditions::test_logged… printed Failed asserting that true is false. (run R15)
  • A user-only filter on email is bypassed at HEAD: cd /workspace/checks/R1 && python3 - <<'EOF' p='/workspace/checks/R1/scratch-test.php' s=open(p).read() s=s.replace(" $… printed get_loggedin_meta(email)='secret' filter_saw=user_email|user (run R12)
  • The same filter worked at 034bf18: cd /workspace/checks/R1/wt/c034 && rm -f /workspace/checks/R1/d-c034.txt && R1_OUT=/workspace/checks/R1/d-c034.txt vendo… printed get_loggedin_meta(email)='DEF' filter_saw=email|user (run R13)
Untested areas
  • The getters check the raw key but read esc_html() of it. No plugin is known to protect an entity-named key, so this was not reported.
  • Real ACF and ACF Pro were not installed.
  • No browser preview was run.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • plugins/otter-pro/inc/plugins/class-posts-acf-integration.php:58-60 — unverified: Pro ACF text/link, media, repeater fallbacks, and grid paths check selector/name/ancestor names. Sanitization precedes both check and read in get_acf. However, whether context-sens…
    • inc/plugins/class-atomic-wind-blocks.php:1393-1414 — unverified: Atomic custom fields sanitize before checking and use get_field_object() with the same selector/post to check a resolved name before output. Whether that name covers every key subs…

🤖 Automated review · run code-review-agent_6b01572d7fc622.16623792.


🤖 Review agent — review posted ✅ on d5fdf561 · changes requested · 3 findings · 27 min

Run code-review-agent_6b01572d7fc622.16623792 · trail

Comment thread tests/test-dynamic-content.php Resolved
$meta = '';

if ( isset( $data['metaKey'] ) && ! self::is_protected_meta_key( $data['metaKey'] ) ) {
if ( isset( $data['metaKey'] ) && ! self::is_protected_meta_key( $data['metaKey'], 'user' ) ) {

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.

security The author getter still misses the WordPress back-compat user keys. This assumes a plugin protects a user meta key such as first_name with an is_protected_meta filter. get_the_author_meta() reads $authordata->user_firstname, and WP_User::__get() maps it to first_name (class-wp-user.php:137-144,298-302). The same holds for user_lastname, user_description and user_level. Line 539 checks only user_firstname, so the protected value is returned. Resolve these keys to their real meta keys before the check. Treat the key as protected when the raw or the resolved key is protected. Add an author-meta test with a filter on first_name that expects the default.

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.

This is still open at 697b6ae, and now reproduced. It assumes a site protects populated first_name user meta through is_protected_meta. With such a filter, get_author_meta() with metaKey user_firstname returned 'secret-first'. The filter saw only user_firstname|user (R4). Map user_firstname, user_lastname, user_description and user_level to their real meta keys before the check. Treat the key as protected when the raw or mapped key is protected. Add the first_name filter test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 0a4ffcc. is_protected_meta_key() now resolves the WP_User back-compat fields (user_firstname→first_name, user_lastname→last_name, user_description→description) to their real meta keys before the check, so a filter on first_name is honored for metaKey=user_firstname. Added test_author_meta_blocks_a_filter_protected_back_compat_field.

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.

The user_firstname case is fixed. With the 697b6ae helper, the new test fails with +'secret-first' (R4). user_level is still open, though the original comment named it. This assumes a site protects that populated user meta target through is_protected_meta. WordPress maps user_level to $wpdb->prefix . 'user_level' (class-wp-user.php:141). It also maps {prefix}usersettings and {prefix}usersettingstime (:142-143). A filter protected wptests_user_level. get_author_meta() with user_level still returned '10' (R7). Add these three keys to the map, built with $wpdb->prefix. Add a user_level filter test that expects the default.

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.

This is still open in part at cf11b5e. The user_level case now returns the default. The new test fails with the 0a4ffcc helper (-'DEF' +'10', R3). The two settings aliases from my last reply are still missing. A filter protected wptests_user-settings. get_author_meta() with wptests_usersettings still returned 'secret-settings' (R4). Resolve {prefix}usersettings and {prefix}usersettingstime to their real keys with $wpdb->prefix before the check. Add a filter test for one of them.

The alias rewrite replaced the key before the is_protected_meta filter ran, so
a plugin protecting a raw user meta key named like a core alias (e.g. `email`)
was missed on the get_user_meta paths. Check the raw key verbatim first, then
also the resolved `user_*` alias for the get_the_author_meta mapping.

Add tests: a filter on the raw `email` user key is honored by get_loggedin_meta()
and the loggedInUserMeta condition.

@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 raw-key filter fix works, but two earlier findings remain open in their threads: the activation key test and the back-compat author keys.

Validation details
  • Files reviewed: 3/3 files changed since the prior review.
  • The new email tests pass at HEAD: cd /repo && ls phpunit.xml* && grep -n "testsuite\|directory" phpunit.xml* | head; set -o pipefail; timeout 280 vendor/b… printed OK (1 test, 1 assertion) (run R1) and cd /repo && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'TestBlockConditions::test_lo… printed OK (1 test, 1 assertion) (run R2)
  • They fail with the code of d5fdf56: cd /workspace/checks/R1 && rm -rf d5 pb && cp -a head d5 && rm -f d5/tests/test-r1-probe.php && (cd /repo && git show d5… printed Failed asserting that true is false. (run R6)
  • The activation key test passes without its alias: cd /workspace/checks/R1/mut && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'TestDynam… printed OK (1 test, 2 assertions) (run R3)
  • A first_name filter is bypassed by user_firstname: cd /workspace/checks/R1 && rm -rf head && mkdir head && (cd /repo && tar --exclude=./node_modules --exclude=./.git -cf -… printed 'secret-first' (run R4)
Untested areas
  • The getters check the raw key but read esc_html() of it. No plugin is known to protect such a key.
  • ACF context-dependent field resolution was not verified. Real ACF and ACF Pro were not installed.
  • No browser preview was run.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • plugins/otter-pro/inc/plugins/class-dynamic-content.php:287-288,556-557,579-580 — unverified: Text/link post, author and logged-in-user getters check the raw key but read esc_html($key). Protection of the transformed key remains unchecked. Missing: runtime-matched escaping …
    • plugins/otter-pro/inc/plugins/class-dynamic-content.php:251-270,313-321,367-397,464-498,777-783,846-852 — unverified: Pro ACF text/link, media and repeater paths check selector/name/ancestors without the read’s post context. Installed ACF declarations distinguish context-aware resolution (vendor/p…
    • plugins/otter-pro/inc/plugins/class-posts-acf-integration.php:58-68 — unverified: Grid checks the selector through the same context-free helper, then returns context-resolved get_field_object() values. Same missing ACF resolution evidence.
    • inc/plugins/class-atomic-wind-blocks.php:1393-1416 — unverified: Atomic checks sanitized selector and context-resolved field name before output. Missing: ACF implementation proving that this name covers every key subsequently consumed by get_fie…

🤖 Automated review · run code-review-agent_6b015e58d7f2d8.52309522.


🤖 Review agent — review posted ✅ on 697b6aea · changes requested · 0 findings · 8 min

Run code-review-agent_6b015e58d7f2d8.52309522 · trail

… check

get_the_author_meta() reads user_firstname/user_lastname/user_description via
WP_User::__get, which maps them to the first_name/last_name/description meta
keys. is_protected_meta_key() checked only the raw name, so a filter on
first_name was missed. Resolve those back-compat fields to their real meta key.

Also seed user_activation_key in the alias test so the activation_key case
fails without the fix, and add a first_name back-compat author-meta test.

@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 activation key test is fixed. Author meta still bypasses the filter through user_level, as the open thread explains.

Validation details
  • Files reviewed: 2/2 files changed since the prior review.
  • Both changed tests pass at HEAD with vendor/bin/phpunit --filter on the two author-meta tests: OK (2 tests, 4 assertions) (run R1).
  • The new back-compat test fails with the 697b6ae helper: -'DEF' +'secret-first' (run R4).
  • The alias test fails without activation_key: -'DEF' +'secret-key' (run R5).
  • A filter on wptests_user_level is bypassed: FILTER get_author_meta='10' (run R7).
Untested areas
  • The getters check the raw key but read esc_html() of it. This was carried from the prior run and not rechecked.
  • ACF context-dependent field resolution was not verified. Real ACF was not installed.
  • No browser preview was run.

🤖 Automated review · run code-review-agent_6b0163d70f8165.54794721.


🤖 Review agent — review posted ✅ on 0a4ffcc9 · changes requested · 0 findings · 9 min

Run code-review-agent_6b0163d70f8165.54794721 · trail

@pirate-bot
pirate-bot removed their request for review November 21, 2026 10:27
@pirate-bot
pirate-bot removed their request for review November 22, 2026 06:47
get_the_author_meta('user_level') returns the author's capability level (0-10)
via WP_User, and user_level is neither underscore-prefixed nor a core alias, so
is_protected_meta_key() let it through. Add it to the protected list so dynamic
content, block conditions and Atomic Wind cannot expose it.

Add a test: author meta blocks user_level for an administrator author.
…nders

The previous commit added user_level to the shared protected-name list, which
also blocked post and ACF meta. A public post field literally named user_level
(e.g. a course level) stopped rendering. Move the guard to the user-meta branch
of is_protected_meta_key, so only author and logged-in user reads are blocked.

Add a test: a post field named user_level is still returned.

@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 new user_level block also hides raw user_level user meta, and two settings aliases still bypass the filter in the open thread.

Validation details
  • Files reviewed: 2/2 files changed since the prior review.
  • The new author-meta test passes at HEAD: mkdir -p /workspace/checks/R-A; cd /repo && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filt… printed OK (2 tests, 2 assertions) (run R2)
  • It fails with the 0a4ffcc helper, so it detects the change: cd /repo && git cat-file -t 0a4ffcc90e3454bb24034f58d40d41b7b48dfb99 && git checkout 0a4ffcc90e3454bb24034f58d40d41b7b48… printed Failures: 1 (run R3)
  • Raw user_level meta returns the default at HEAD: `mkdir -p /workspace/checks/R-A && cat > /workspace/checks/R-A/RawUserLevelProbe.php <<'EOF'
Untested areas - The getters check the raw key but read `esc_html()` of it. No stored, filter-protected key with an HTML special character was found. - ACF context-dependent field resolution was not verified. Real ACF was not installed. - No browser preview was run. - The variant pass did not settle these places, where the fixed cause may still reach: - `plugins/otter-pro/inc/plugins/class-posts-acf-integration.php:58-68` — unverified: Grid checks omit the $id used by get_field_object; whether that context changes the resolved stored key remains unestablished without matching ACF source. - `inc/plugins/class-atomic-wind-blocks.php:1393-1416` — unverified: Atomic checks the supplied selector and context-resolved field name, but matching ACF evidence is still needed to establish that these cover every key consumed by get_field.
🤖 Automated review · run code-review-agent_6b0429f0c3d272.11995593. --- **🤖 Review agent** — review posted ✅ on `cf11b5e1` · [changes requested · 1 finding](https://github.com//pull/3195#pullrequestreview-6021564440) · 20 min Run `code-review-agent_6b0429f0c3d272.11995593` · [trail](https://agents.vertistudio.com/admin/trails/github-pr/Codeinwp-otter-blocks-3195)

Comment on lines +212 to +215
// Legacy capability level; user-only, so a post field named user_level stays allowed.
if ( 'user_level' === $lower ) {
return true;
}

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.

correctness ✓ Verified in the sandbox The new user_level block also hides raw user meta named user_level. This assumes a site runs a plugin that stores that raw key, such as VIPer (viper.php:111-125). get_loggedin_meta() (line 598) and the loggedInUserMeta condition (class-block-conditions.php:137) read get_user_meta() with the raw key. WordPress does not map that key to {prefix}user_level there. So a subscriber's own user_level = gold now renders the default, and the condition is false. Before this commit it rendered gold and matched. Block user_level only in get_author_meta(), which reads through WP_User::__get(). Add tests for get_loggedin_meta() and the condition with raw user_level meta.

…ted-meta

# Conflicts:
#	tests/test-atomic-wind-blocks.php
@vytisbulkevicius
vytisbulkevicius merged commit b1f01b8 into development Nov 23, 2026
15 checks passed
@vytisbulkevicius
vytisbulkevicius deleted the fix/320-protected-meta branch November 23, 2026 13:50
@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