-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The schema said logged_in. One handler read the flag. The other did not.\n\nThe 1.5.4 plugin ships a function `get_settings()` in `includes/class-bp-restrict.php` that returns the default restriction list. Each restriction is an associative array with a name, a human title, and a `condition` that is a PHP expression string. Five restrictions ship by default. Three of them carry an additional key, `logged_in => true`:\n\n```php\n// includes/class-bp-restrict.php, get_settings() in 1.5.4\n\n$settings[] = array(\n 'title' => __( 'Restrict viewing other profiles', 'bp-restrict' ),\n 'name' => 'view_profiles',\n 'condition' => 'bp_is_user() && ! bp_is_my_profile()',\n);\n\n// ... groups_dir, view_groups, show_activity ...\n\n$settings[] = array(\n 'title' => __( 'Sending private messages restriction', 'bp-restrict' ),\n 'name' => 'pm',\n 'logged_in' => true,\n 'condition' => 'preg_match(\"/\\/' . $members_slug . '\\/\" . bp_get_loggedin_user_username() . \"\\/messages\\/compose\\/?/\", %current_url% )',\n);\n// pm_view and add_media follow the same shape, each with logged_in => true\n// and %current_url% inside the condition.\n```\n\nThe three with `logged_in => true` are exactly the three whose conditions contain the token `%current_url%`. The two without the flag have conditions that call BuddyPress helpers and never reference the current URL at all. The flag's name is documentation of intent: these rules only apply when a logged-in user is on the matching URL, because the regex is anchored by `bp_get_loggedin_user_username()`, which returns an empty string for guests.\n\nTwo separate handlers iterate that list. Both are registered on the `template_redirect` action, which fires on every front-end request. The handler in `admin/class-bp-restrict-admin.php` reads the flag:\n\n```php\n// admin/class-bp-restrict-admin.php, restrict_rules() in 1.5.4\n\nforeach ( $all_restrictions as $restriction ) {\n if ( isset( $restriction['logged_in'] ) && $restriction['logged_in'] ) {\n continue;\n }\n $v = str_replace( '%current_url%', '\"'. $uri . '\"', $restriction['condition'] );\n\n $check = false;\n eval( '$check = ' . $v . ';' );\n if ( $check ) {\n $this->check_access( $restriction['name'] );\n }\n}\n```\n\nThe handler in `admin/class-bp-restrict-pmpro.php` does not:\n\n```php\n// admin/class-bp-restrict-pmpro.php, restrict_rules() in 1.5.4\n\nforeach ( $all_restrictions as $restriction ) {\n $v = str_replace( '%current_url%', '\"' . $uri . '\"', $restriction['condition'] );\n\n $check = false;\n eval( '$check = ' . $v . ';' );\n if ( $check ) {\n $this->check_access( $restriction['name'] );\n }\n}\n```\n\nTwo loops, one contract. The Pmpro class's loop is a line-for-line copy of the Admin class's loop with the `if ( $restriction['logged_in'] )` branch removed. Every other line is the same substitution, same `eval`, same `check_access`.\n\nThe Pmpro class is instantiated when the PMPro plugin is active, from `load_dependencies` in the Admin class, and its constructor registers the `template_redirect` hook. Its own `restrict_rules` short-circuits only on `is_super_admin()`, `function_exists( 'pmpro_url' )`, and `function_exists( 'bp_is_active' )`. There is no logged-in check. Guests reach the loop. The loop processes all five restrictions. Three of those five contain `%current_url%`. The attacker's request URI is substituted into the `eval` argument for each of them.\n\n## The eval argument is a double-quoted PHP string literal\n\nThe substitution replaces the literal token `%current_url%` with the characters `\"` then `$uri` then `\"`. The result is a PHP expression where the URI appears inside double quotes. For the `pm` rule, with an empty logged-in username, the expression that reaches `eval` looks like this:\n\n```php\n$check = preg_match(\"/\\/members\\/\" . \"\" . \"\\/messages\\/compose\\/?/\", \"https://victim.example/\" );\n```\n\nThe regex half of that expression collapses to a pattern that never matches a well-formed URI. The function that eventually runs, `preg_match`, returns `0`. `$check` is `false`. The restriction does not fire. From the plugin's point of view, the loop did nothing.\n\nThat is the second half of what `eval` did. The first half was parsing the argument. A double-quoted string literal in PHP is not an inert byte sequence. It is a mini-language with its own expression grammar, the complex (curly) syntax. Inside `\"...\"`, the sequence `{${expr}}` names a variable whose identifier is the value of `expr`. To resolve that name, PHP evaluates `expr` first. Whatever `expr` is, a function call, a chained expression, a call to `system`, runs during string interpolation, before the string's value is handed to the caller that `preg_match` would have received.\n\nThe `get_full_url()` helper builds the URI it hands to the substitution directly from the request:\n\n```php\n// includes/class-bp-restrict.php, get_full_url() in 1.5.4\n$uri = $protocol . \"://\" . $_SERVER['HTTP_HOST'] . $port . $_SERVER['REQUEST_URI'];\n```\n\nNo filter, no canonicalization, no escape. A request whose path contains the three bytes `{$` is a request whose REQUEST_URI contains those three bytes. A request whose path contains `{${system('id')}}` is a request whose REQUEST_URI contains that expression, which arrives inside the double-quoted string literal `eval` parses, which triggers the complex-syntax branch, which calls `system`, which runs `id` and writes the output to the response body before the `preg_match` the author wrote has started.\n\nA working request:\n\n```bash\ncurl --path-as-is \"https://victim.example/{\\${system('id')}}\"\n```\n\nThe response contains `uid=33(www-data) gid=33(www-data) groups=33(www-data)` spliced into the page body. The regex that follows sees a URI with the already-executed payload, fails to match, returns 0. The plugin's own event flow logs nothing unusual. WordPress does not log request bodies; access logs record a GET for a path containing `{$` characters that returned a normal 200.\n\nThe author of the loop reached for `'\"' . $uri . '\"'` as a substitution. They were trying to produce a well-formed PHP string literal around an untrusted value. Wrapping an untrusted value in `\"...\"` and feeding the result to `eval` is the sink the double-quoted string literal exists to serve: the `\"...\"` is not a container, it is a parser that runs user-supplied expressions. This is also why the canonical LLCForge PoC README names the wrong file for the sink. The mechanism it describes, double-quote interpolation inside `eval`, is correct. The code block it prints is an invented stand-in; the actual expression lives in `admin/class-bp-restrict-pmpro.php` and in the parallel-but-gated copy in `admin/class-bp-restrict-admin.php`.\n\n## The 1.5.5 diff: two fixes, one admission\n\nThe 1.5.5 release went live on 18 November 2026, three days before CVE assignment. The plugin reports 300+ active installations. The changelog's security entry reads, in full:\n\n> **Security fix:** Fixed unauthenticated PHP code injection via the request URI in restriction condition evaluation. Request data is no longer part of evaluated code; logged-in-only restrictions are skipped for guests.\n\nTwo sentences, two separate fixes. The first fix moves the URI out of the `eval` text entirely. A new helper, `evaluate_condition`, binds the URI as a local variable `$current_url` before the eval, and `%current_url%` is replaced with the literal five characters `$current_url` rather than the URI's value:\n\n```php\n// includes/class-bp-restrict.php, 1.5.5\npublic function evaluate_condition( $condition, $uri ) {\n $current_url = (string) $uri; // bound value, used by the eval'd expression below\n $expression = str_replace( '%current_url%', '$current_url', (string) $condition );\n $check = false;\n\n // phpcs:ignore Squiz.PHP.Eval.Discouraged -- fixed, plugin/filter-authored expression; request data is bound, not interpolated.\n eval( '$check = ' . $expression . ';' );\n\n return (bool) $check;\n}\n```\n\nThe eval still runs. The attacker's URI still flows into the function. The URI is now the value of a variable the eval'd code reads by name, not a substring inside the code's text. PHP's string-literal interpolation does not re-tokenize a variable's value when it is referenced as `$current_url` inside a `preg_match` argument, and the primitive is gone.\n\nThe second fix is the one the pattern turns on. The Pmpro handler is rewritten to add the check the Admin handler had all along:\n\n```diff\n foreach ( $all_restrictions as $restriction ) {\n- $v = str_replace( '%current_url%', '\"' . $uri . '\"', $restriction['condition'] );\n+ // logged_in restrictions can never apply to anonymous visitors\n+ if ( ! empty( $restriction['logged_in'] ) && ! is_user_logged_in() ) {\n+ continue;\n+ }\n\n- $check = false;\n- eval( '$check = ' . $v . ';' );\n- if ( $check ) {\n+ if ( bp_restrict()->evaluate_condition( $restriction['condition'], $uri ) ) {\n $this->check_access( $restriction['name'] );\n }\n }\n```\n\nThe variable-binding fix closes the demonstrated primitive on its own. The logged-in check is additional. Adding the second fix is the author's admission that the handler was processing rules it was never supposed to process. The restrictions marked `logged_in => true` were iterated for callers who were not logged in on every request, from the point the Pmpro integration file was forked from the Admin loop. The fix committed alongside the primitive closure is the comment `logged_in restrictions can never apply to anonymous visitors`, a sentence the plugin's schema has asserted in flag form since the project began.\n\n## This is a parallel-implementation-gap\n\nThe Admin class's `restrict_rules` and the Pmpro class's `restrict_rules` are the same function. They iterate the same restriction list produced by the same `get_settings()` helper. They read the same `get_full_url()` helper. They register against the same WordPress action. The difference between them is four lines at the top of the loop, the `if ( isset( $restriction['logged_in'] ) ) continue;` branch. That branch lives in the canonical file. The Pmpro integration was written as a parallel implementation and the branch was not copied.\n\nThe Pmpro loop is loaded only when PMPro is active, which is the precondition the CVE description names. Sites with PMPro installed are sites where both handlers run on every request, and only the Pmpro handler is the CVE. The other handler, running in the same process, in the same plugin, on the same action, never has this bug.\n\nThe restrictions the plugin marked `logged_in => true` are the restrictions the Pmpro handler ran for callers who were not logged in. The mechanism is the double-quote interpolation that `eval` performs on its argument. The CVE exists because a second loop was shipped against the same restriction-processing contract as a first loop, and the flag that scoped the contract was documentation rather than enforcement. The 1.5.5 patch's first fix neutralises the sink; its second fix finally promotes the `logged_in` flag from a comment-shaped convention into an actual gate.\n\nPoC: [LLCForge/CVE-2026-120539](https://github.com/LLCForge/CVE-2026-120539)","closing_line":"Two handlers, one contract. The gated one is not the CVE.","hook_md":"Three of the five default restrictions in Restrictions for BuddyPress carry a `logged_in` flag set to `true`. The flag's name is its documentation: these rules are supposed to apply only to callers who are already logged in. The 1.5.4 plugin has two handlers that iterate the same restriction list on every `template_redirect`; the handler in the Admin class reads the flag and skips the rule for guests, and the handler in the Pmpro integration class is a parallel copy of that loop with the flag check removed. For every unauthenticated request to a site running BuddyPress and Paid Memberships Pro, the Pmpro handler reaches into the three rules marked logged-in-only, substitutes the attacker's request URI into a double-quoted PHP string literal, and feeds the result to `eval`.","post_id":888,"slug":"bp-restrict-logged-in-only-ran-for-guests","title":"CVE-2026-120539: Restrictions for BuddyPress Marked Three Rules Logged-In-Only. The Pmpro Handler Ran Them For Guests.","type":"initial","unreadable_sentence":"The restrictions the plugin marked `logged_in => true` are the restrictions the Pmpro handler ran for callers who were not logged in."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCawH0FgAKCRDeZjl4jgkQ JqdYAQCt5ZfaMuhC1MXTCHQsk2WOEh6FUc9SIYNF6oyOYUlvggD/QE85L++a5AWj phEDQwClEgaPFZTuLzm4P2ilFeyh8wA= =mNy5 -----END PGP SIGNATURE-----