Lightweight Accordion <= 1.5.20 - Authenticated (Contributor+) Stored Cross-Site Scripting
Description
The Lightweight Accordion plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the plugin's `lightweight-accordion` shortcode in all versions up to, and including, 1.5.20 due to insufficient input sanitization and output escaping on user supplied attributes. 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
<=1.5.20Source Code
WordPress.org SVNThis research plan outlines the technical steps to analyze and exploit **CVE-2025-13740**, a Stored Cross-Site Scripting (XSS) vulnerability in the **Lightweight Accordion** plugin for WordPress. --- ### 1. Vulnerability Summary * **Vulnerability:** Authenticated (Contributor+) Stored Cross-Site…
Show full research plan
This research plan outlines the technical steps to analyze and exploit CVE-2025-13740, a Stored Cross-Site Scripting (XSS) vulnerability in the Lightweight Accordion plugin for WordPress.
1. Vulnerability Summary
- Vulnerability: Authenticated (Contributor+) Stored Cross-Site Scripting.
- Location: The
lightweight-accordionshortcode implementation. - Cause: The plugin fails to sanitize or escape user-supplied attributes (such as
title,class, orheader) within the shortcode callback function before rendering them in the HTML output. - Impact: A user with Contributor-level permissions (the lowest level that can create content) can inject malicious JavaScript. This script executes in the browser context of any user (including Administrators) who views the post or page containing the shortcode.
2. Attack Vector Analysis
- Authentication: Authenticated (Contributor or higher).
- Entry Point: Post/Page editor (via Shortcode).
- Vulnerable Parameter: Shortcode attributes (e.g.,
title,class,id). - Preconditions: The plugin "Lightweight Accordion" must be active. The attacker needs credentials for a Contributor account.
3. Code Flow (Inferred)
- Registration: The plugin registers the shortcode in the main plugin file (likely
lightweight-accordion.phpor an included loader) usingadd_shortcode( 'lightweight-accordion', 'callback_function_name' ). - Processing: When a post is rendered, WordPress calls the callback function, passing an
$attsarray containing the user-defined attributes. - Merge: The callback typically uses
shortcode_atts()to merge user input with default values. - Sink: The callback constructs an HTML string. The vulnerability exists because it concatenates the raw values from
$atts(e.g.,$atts['title']) directly into the HTML string or echoes them without using escaping functions likeesc_html()oresc_attr(). - Output: The malicious HTML is returned to the WordPress content filter and displayed on the frontend.
4. Nonce Acquisition Strategy
This vulnerability is authenticated, so we must acquire a standard WordPress session and the necessary nonces for post creation/editing.
- Authentication: Use the
http_requesttool to log in as a Contributor. - Nonce for Post Creation:
- Navigate to
wp-admin/post-new.php. - Use
browser_evalto extract the_wpnoncefrom the form or the REST API nonce from thewpApiSettingsobject. - JS Command:
window.wpApiSettings?.nonceordocument.querySelector('#_wpnonce')?.value.
- Navigate to
- Editor Context: If using the Gutenberg editor, the nonce is typically passed in the
X-WP-Nonceheader for REST API requests to/wp/v2/posts.
5. Exploitation Strategy
The goal is to create a post containing a lightweight-accordion shortcode with a payload in its attributes.
Step 1: Identify Vulnerable Attribute
We will test common accordion attributes: title, class, id, header, state.
Step 2: Construct the Payload
- Attribute Breakout (for
classorid):"][script]alert(document.domain)[/script]" - Direct Injection (for
titleorheader):[lightweight-accordion title="<script>alert(1)</script>"]Content[/lightweight-accordion]
Step 3: Execute the HTTP Request
Use the REST API (preferred for modern WordPress) to create a post.
- Endpoint:
POST /wp-json/wp/v2/posts - Headers:
Content-Type: application/jsonX-WP-Nonce: [EXTRACTED_NONCE]
- Body:
{
"title": "XSS Test",
"content": "[lightweight-accordion title='<img src=x onerror=alert(domain)>']Accordion Content[/lightweight-accordion]",
"status": "pending"
}
Note: Contributors cannot "publish" directly, but "pending" or "draft" posts can be previewed by the contributor or viewed by an admin in the dashboard.
6. Test Data Setup
- Install Plugin: Ensure
lightweight-accordionversion <= 1.5.20 is installed and active. - Create User: Create a user with the
contributorrole.wp user create attacker attacker@example.com --role=contributor --user_pass=password123
7. Expected Results
- The HTTP request should return
201 Created. - When the post is viewed (via
?p=[ID]or the preview link), the HTML source should contain the unescaped payload. - Example Vulnerable Output:
<span class="lightweight-accordion-title"><img src=x onerror=alert(domain)></span> - The browser should trigger the
alert(domain)box.
8. Verification Steps
- Database Check: Verify the shortcode is stored correctly in the
wp_poststable.wp db query "SELECT post_content FROM wp_posts WHERE post_title='XSS Test'"
- Frontend Inspection: Fetch the rendered page and check for the lack of escaping.
- Use
http_request(GET) on the post URL and grep foronerror=alert.
- Use
9. Alternative Approaches
- Attribute Breakout: If the
titleis escaped withesc_html()but theclassis used in an attribute and escaped withesc_html()(incorrectly) instead ofesc_attr(), we can break out of the attribute:[lightweight-accordion class='"> <script>alert(1)</script> <"'] - Classic Editor Submission: If the REST API is disabled, use a
POSTrequest towp-admin/post.phpwithaction=editpostand the standard form-encoded data including_wpnonceandcontent.
Summary
The Lightweight Accordion plugin for WordPress is vulnerable to Stored Cross-Site Scripting via its shortcode attributes because it fails to sanitize or escape user-provided inputs like 'title' and 'class'. Authenticated attackers with Contributor-level permissions can inject malicious JavaScript into posts that executes in the context of any user viewing the content.
Vulnerable Code
// lightweight-accordion.php (Inferred logic based on research plan) function lightweight_accordion_callback( $atts, $content = null ) { $a = shortcode_atts( array( 'title' => '', 'class' => '', 'header' => 'header', ), $atts ); // The values from $a are concatenated directly into the HTML string without escaping $output = '<div class="lightweight-accordion ' . $a['class'] . '">'; $output .= '<' . $a['header'] . ' class="lightweight-accordion-title">' . $a['title'] . '</' . $a['header'] . '>'; $output .= '<div class="lightweight-accordion-content">' . do_shortcode( $content ) . '</div>'; $output .= '</div>'; return $output; } add_shortcode( 'lightweight-accordion', 'lightweight_accordion_callback' );
Security Fix
@@ -8,8 +8,8 @@ ), $atts ); - $output = '<div class="lightweight-accordion ' . $a['class'] . '">'; - $output .= '<' . $a['header'] . ' class="lightweight-accordion-title">' . $a['title'] . '</' . $a['header'] . '>'; + $output = '<div class="lightweight-accordion ' . esc_attr( $a['class'] ) . '">'; + $output .= '<' . esc_attr( $a['header'] ) . ' class="lightweight-accordion-title">' . wp_kses_post( $a['title'] ) . '</' . esc_attr( $a['header'] ) . '>'; $output .= '<div class="lightweight-accordion-content">' . do_shortcode( $content ) . '</div>';
Exploit Outline
1. Log in to the WordPress site with at least Contributor-level credentials. 2. Navigate to the post editor (Gutenberg or Classic) to create a new post or edit an existing one. 3. Extract the required security nonce (_wpnonce or X-WP-Nonce) from the editor interface. 4. Submit a post content containing the `lightweight-accordion` shortcode with a malicious payload in an attribute. Example: `[lightweight-accordion title='<img src=x onerror=alert(document.domain)>']Content[/lightweight-accordion]`. 5. Save the post as a draft or submit it for review. 6. Access the post's frontend URL or preview link to trigger the JavaScript execution in the browser.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.