Easy Modal <= 2.1.0 - Authenticated (Contributor+) Stored Cross-Site Scripting
Description
The Easy Modal plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 2.1.0 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with contributor-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page.
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:NTechnical Details
<=2.1.0## Vulnerability Summary The **Easy Modal** plugin (versions <= 2.1.0) is vulnerable to **Stored Cross-Site Scripting (XSS)**. This occurs because the plugin allows users with **Contributor-level** permissions and above to create or edit modals without properly sanitizing input fields (such as the m…
Show full research plan
Vulnerability Summary
The Easy Modal plugin (versions <= 2.1.0) is vulnerable to Stored Cross-Site Scripting (XSS). This occurs because the plugin allows users with Contributor-level permissions and above to create or edit modals without properly sanitizing input fields (such as the modal title or content) and subsequently fails to escape this data when it is rendered on the front end or in the admin dashboard.
In WordPress, contributors typically have the edit_posts capability. If "Easy Modal" treats modals as a Custom Post Type (CPT) or provides a custom interface accessible to contributors, an attacker can inject malicious <script> tags into the modal's settings. When an administrator or any other user views a page containing that modal (via shortcode) or views the modal list in the admin panel, the script executes in their browser context.
Attack Vector Analysis
- Endpoint:
wp-admin/post.php(if using CPT) or an AJAX handler likewp_ajax_em_save_modal(inferred). - Vulnerable Parameter:
post_title,content, or specific meta fields likeem_modal_settings[title]orem_modal_settings[css_class](inferred). - Authentication: Authenticated, Contributor role or higher.
- Preconditions: The plugin must be active, and the attacker must have access to the modal editor.
Code Flow (Inferred)
- Entry Point: The user submits a request to save a modal. This is handled either by the standard
save_posthook for theeasy_modalCPT or a custom AJAX action. - Processing: The plugin receives the input (e.g.,
$_POST['post_title']or$_POST['em_settings']). It likely usesupdate_post_meta()orwp_insert_post()without sufficient sanitization (likewp_ksesorsanitize_text_field). - Storage: The raw XSS payload is stored in the
wp_poststable orwp_postmetatable. - Sink: When a page containing the
[easy-modal id="..."]shortcode is loaded, the plugin retrieves the modal data. - Rendering: The plugin echoes the title or content directly:
echo $modal->post_title;(inferred) without usingesc_html()oresc_attr().
Nonce Acquisition Strategy
Since source files are not provided, we will assume the plugin follows the standard WordPress Custom Post Type (CPT) pattern for modal management.
- Identify the Modal Post Type: We will check if
easy_modalorem_modalis a registered post type. - Create a Page for Discovery: A contributor will navigate to the "Add New Modal" page.
- Extract Nonce:
- Use
browser_navigateto go towp-admin/post-new.php?post_type=easy_modal. - Use
browser_evalto extract the_wpnoncefrom the form. browser_eval("document.querySelector('#_wpnonce').value")
- Use
Exploitation Strategy
1. Test Data Setup
- Create a user with the Contributor role.
- Identify the exact slug for the modal post type (likely
easy_modal).
2. Step-by-Step Exploitation
Step 1: Authenticate as Contributor
- Log in to the WordPress instance using the
http_requesttool to obtain session cookies.
Step 2: Get Nonce and Post ID
- Navigate to the "Add New Modal" screen to trigger the generation of a
post_ID(auto-draft) and a valid nonce. - URL:
wp-admin/post-new.php?post_type=easy_modal
Step 3: Inject Stored XSS
- Submit a POST request to
wp-admin/post.phpto save the modal with a malicious title. - Request Details:
- URL:
http://localhost:8080/wp-admin/post.php - Method:
POST - Content-Type:
application/x-www-form-urlencoded - Body:
action=editpost &post_type=easy_modal &post_ID=[POST_ID] &_wpnonce=[NONCE] &post_title=<script>alert('XSS_SUCCESS_TITLE')</script> &content=<img src=x onerror=alert('XSS_SUCCESS_CONTENT')> &publish=Publish
- URL:
Step 4: Embed the Modal (Trigger)
- As the contributor, create a public post/page containing the modal shortcode to ensure it renders on the frontend.
- Shortcode:
[easy-modal id="[POST_ID]"](inferred).
Step 5: Trigger the XSS
- Use
browser_navigateto visit the newly created page as an Administrator. - This demonstrates the escalation from Contributor to Administrator via XSS.
Expected Results
- The HTTP response from
post.phpshould indicate a successful redirect (302) or success message. - When the page with the shortcode is loaded, a JavaScript alert box with
'XSS_SUCCESS_TITLE'or'XSS_SUCCESS_CONTENT'should appear. - The HTML source of the rendered page should contain the raw, unescaped
<script>or<img>tags.
Verification Steps
- Database Check: Use WP-CLI to verify the payload is stored raw.
wp post get [POST_ID] --field=post_title - Frontend Check: Use
http_requestto fetch the page where the modal is embedded and grep for the payload.# Look for the unescaped script tag grep "<script>alert('XSS_SUCCESS_TITLE')</script>"
Alternative Approaches
If the plugin uses a custom AJAX interface instead of the CPT post.php flow:
- Search for AJAX actions:
grep -r "wp_ajax_em_" wp-content/plugins/easy-modal/. - Identify the saving function: Look for
update_optionorupdate_post_metacalls inside the AJAX handler. - Craft AJAX Request:
- Action:
em_save_modal(inferred). - Payload: Send the XSS in a JSON or form-data parameter.
- Nonce: Often localized in
window.em_admin_settings.nonce.
- Action:
Summary
The Easy Modal plugin for WordPress (<= 2.1.0) is vulnerable to Stored Cross-Site Scripting because it fails to properly sanitize modal settings upon saving and fails to escape output when rendering them. This allows authenticated attackers with Contributor-level access to inject malicious scripts into fields such as the modal title or content, which execute in the browser of any user (including administrators) who views the modal.
Vulnerable Code
// Inferred from research plan Code Flow (Processing) update_post_meta($post_id, 'em_modal_settings', $_POST['em_modal_settings']); --- // Inferred from research plan Code Flow (Rendering) echo $modal->post_title;
Security Fix
@@ -1,7 +1,7 @@ -update_post_meta($post_id, 'em_modal_settings', $_POST['em_modal_settings']); +if (isset($_POST['em_modal_settings']) && is_array($_POST['em_modal_settings'])) { + $sanitized_settings = array_map('sanitize_text_field', $_POST['em_modal_settings']); + update_post_meta($post_id, 'em_modal_settings', $sanitized_settings); +} ... -echo $modal->post_title; +echo esc_html($modal->post_title);
Exploit Outline
The exploit is carried out by an authenticated user with Contributor-level permissions. First, the attacker navigates to the 'Add New Modal' screen (likely wp-admin/post-new.php?post_type=easy_modal) to obtain a valid WordPress nonce and an auto-draft post ID. They then submit a POST request to wp-admin/post.php using the 'editpost' action, including a malicious XSS payload (e.g., <script>alert('XSS')</script>) in parameters like 'post_title' or 'em_modal_settings[title]'. Once the modal is published, the attacker can embed it into a post using a shortcode like [easy-modal id="POST_ID"]. The stored script executes whenever an administrator views the modal in the admin list or visits the page where the modal is embedded.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.