Every input sent in a server request should be inspected, sanitized, and validated before processing it in your code. WordPress plugins are great for adding features to your site for both administrators and users, but you put the trust of your site’s cybersecurity into the hands of an unknown developer. Even plugins with thousands of downloads can be vulnerable to various exploits. The WP Social Ninja plugin adds social media posts to your content, which is a great feature. Unfortunately, a vulnerability of unsanitized input was found. 

In CVE-2025-13380, the developer for WP Social Ninja version 4.0.1 and older  failed to sanitize input for server requests handling administrative settings. This attack falls under a failure to check for authorization before allowing code to process GET requests. The two functions vulnerable to unauthorized access in WP Social Ninja are saveAdvanceSettings() and getAdvanceSettings(). Because the plugin does not ensure the user is authorized to run these functions and fails to sanitize input, attackers could save settings with malicious content or retrieve a site owner’s personalized settings for their social feeds.

PHP Vulnerable Code without Input Sanitization

The WP Social Ninja WordPress plugin has several routes, and it’s a fairly large codebase. Common PHP vulnerabilities always involve unsanitized input, which makes WordPress the perfect target for exploits. Here is the vulnerable code snippet from version 4.0.1 of the plugin:

public function saveAdvanceSettings(Request $request, DataProtector $protector)
{
$advanceSettings = $request->get('advance_settings');
$settings = get_option('wpsr_global_settings', []);

//.....snip for brevity

$settings['global_settings']['advance_settings'] = $advanceSettings;

//......snip for brevity

// Only encrypt if the API key is provided and not empty
if (!empty($advanceSettings['ai_api_key'])) {
   $settings['global_settings']['advance_settings']['ai_api_key']
          = $protector->maybe_encrypt($advanceSettings['ai_api_key']);
}

$globalSettings = (new GlobalSettings())->formatGlobalSettings($settings);
update_option('wpsr_global_settings', $globalSettings);

//........snip return for brevity
}

As you can see from the highlighted code above, settings stored in the $request variable sent in  querystring variables are retrieved without ensuring that what was sent was valid. Without sanitizing input or checking for authorization, an attacker could inject malicious code. Any malicious code rendered later in a browser could steal data, sessions, or send users to a phishing site. 

Another possibility is that the attacker could inject settings into a site owner’s WP Social Ninja plugin feed to show a different social feed or deface the site with their own social media posts. Attackers will often make changes to site content to hide hidden links that point to malware sites or pharmaceutical companies. Hidden links could also host phishing content. Because these links are hidden, a site owner would have no idea that they are helping scammers. Google also penalizes sites for these types of malicious links.

Changes in WP Social Ninja to Sanitize Input

Developers for WP Social Ninja updated their code to remediate the code vulnerability. Here is the new code change in version 4.0.2:

$advanceSettings = $request->get('advance_settings');

if (is_string($advanceSettings)) {
   $advanceSettings = wp_unslash($advanceSettings);
   $decoded = json_decode($advanceSettings, true);
   $advanceSettings = is_array($decoded) ? $decoded : [];
}

$qrCodeEntryMap = [
    'id'           => 'intval',
    'name'         => 'sanitize_text_field',
    'url'          => 'esc_url_raw',
    'custom_url'   => 'esc_url_raw',
    'qrcode_url'   => 'esc_url_raw',
    'scan_counter' => 'intval',
];

$sanitizeMap = [
    'has_gdpr'  => 'wpsr_sanitize_boolean',
    'optimize_image_format'  => 'sanitize_text_field',
    'review_optimized_images'  => 'wpsr_sanitize_boolean',
    'preserve_plugin_data'  => 'wpsr_sanitize_boolean',
    'ai_review_summarizer_enabled'  => 'wpsr_sanitize_boolean',
    'ai_platform'  => 'sanitize_text_field',
    'ai_api_key'  => 'sanitize_text_field',
    'selected_model'  => 'sanitize_text_field',
    'email_report.status' => 'wpsr_sanitize_boolean',
    'email_report.sending_day' => 'sanitize_text_field',
    'email_report.recipients' => 'wpsr_sanitize_recipients',
];

$advanceSettings = wpsr_backend_sanitizer($advanceSettings, $sanitizeMap);

Notice the new if clause that runs the $request variable information through a new function named wpsr_backend_sanitizer(). This function validates data sent from a user to protect from unauthorized access and potential data disclosure. This single function call remediates what could be a malicious defacing of your website or hidden links to malware. Google scans sites for hidden links or hosting of phishing and malware. The result could be your site added to filters where users get a red warning screen before opening your site. It’s a frustrating experience that you should want to avoid.

This code vulnerability is a good example for software developers. Any type of input from querystrings (or POST requests that are open to the public) should be run through a sanitization function. For WordPress developers, PHP has several internal functions to sanitize data. A few functions to check out:

  • filter_var(): Removes special characters including malicious input like <script> from querystrings
  • htmlspecialchars(): Converts special characters to encoded HTML so they won’t function like conversion of < to &lt;
  • strip_tags(): Removes HTML and PHP code from input

Upgrade WP Social Ninja WordPres Plugin to Keep Your Site Safe

To protect your site, upgrade WP Social Ninja plugin to the latest version, which is currently 4.0.2. If you are a developer and want to look at the old code, go to the “Development”  tab and scroll down to the version dropdown box. Choose 4.0.1 and download the older version of the plugin to review the code. The older version code can show you mistakes in secure coding to help you build more secure applications in the future.

Join Our Newsletter
get weekly access to the latest hacks, tricks, and updates