CodeColorer <= 0.10.1 - Unauthenticated Stored Cross-Site Scripting
Description
The CodeColorer plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 0.10.1 due to insufficient input sanitization and output escaping. This makes it possible for unauthenticated attackers 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:N/UI:N/S:C/C:L/I:L/A:NTechnical Details
<=0.10.1Source Code
WordPress.org SVNThis research plan outlines the steps required to analyze and exploit **CVE-2025-68012**, an unauthenticated stored Cross-Site Scripting (XSS) vulnerability in the CodeColorer plugin for WordPress. ## 1. Vulnerability Summary The CodeColorer plugin (up to version 0.10.1) provides syntax highlightin…
Show full research plan
This research plan outlines the steps required to analyze and exploit CVE-2025-68012, an unauthenticated stored Cross-Site Scripting (XSS) vulnerability in the CodeColorer plugin for WordPress.
1. Vulnerability Summary
The CodeColorer plugin (up to version 0.10.1) provides syntax highlighting for code snippets within WordPress posts and comments. The vulnerability exists because the plugin fails to sufficiently sanitize or escape the content and attributes of its custom tags (e.g., [cc], [codecolorer], or <codecolorer>) when they are processed through WordPress content filters like the_content and comment_text. An unauthenticated attacker can submit a comment containing a malicious payload wrapped in CodeColorer tags, which will be stored in the database and executed in the browser of any user (including administrators) who views the page.
2. Attack Vector Analysis
- Endpoint:
wp-comments-post.php(standard WordPress comment submission) or the AJAX comment handler if the theme uses one. - Hook:
comment_text(Filter). - Vulnerable Parameter:
comment(The body of the comment). - Authentication: None required (unauthenticated).
- Preconditions:
- Comments must be enabled on at least one post/page.
- The plugin must be active and configured to process tags in comments (default behavior).
3. Code Flow (Inferred)
- Entry Point: An unauthenticated user submits a comment via
POST /wp-comments-post.php. - Persistence: WordPress saves the raw comment string to the
wp_commentstable. - Trigger: An administrator or guest views the post containing the comment.
- Execution Path:
- WordPress fetches the comment and applies the
comment_textfilters. CodeColorer::BeforeFilterContent(or similar function registered tocomment_text) is called.- The plugin uses a Regular Expression (likely in
codecolorer-core.phporcodecolorer.php) to identify tags like[cc]...[/cc]. - The plugin extracts the content and attributes (e.g.,
lang,tab_size). - The plugin processes the code (often using the GeSHi library or custom logic) and prepares the HTML output.
- Vulnerability Sink: The processed content or attributes are returned and echoed to the page without being passed through
esc_html(),esc_attr(), orwp_kses(). If the plugin performshtml_entity_decode()on the input to handle "beautification" before rendering, it may re-activate scripts that WordPress core previously neutralized.
- WordPress fetches the comment and applies the
4. Nonce Acquisition Strategy
While the CodeColorer plugin itself does not typically require a custom nonce for content processing, WordPress core requires a nonce for comment submission in most default configurations to prevent CSRF.
- Identify Script Localization: CodeColorer may localize scripts for its editor buttons, but these are usually for authenticated users.
- Comment Nonce: To submit a comment programmatically, you need the
_wpnonceandcomment_post_ID. - Execution Steps:
- Step 1: Use
browser_navigateto go to a public post where comments are enabled. - Step 2: Use
browser_evalto extract the comment nonce from the form:// Find the nonce field in the comment form document.querySelector('#commentform input[name="_wpnonce"]')?.value || document.querySelector('input[name="akismet_comment_nonce"]')?.value; - Step 3: Note the
comment_post_IDfrom the hidden input field or the URL.
- Step 1: Use
5. Exploitation Strategy
The goal is to inject a stored XSS payload via a comment.
Payload Options:
- Tag Breakout:
[cc lang='"><script>alert(document.domain)</script>']test[/cc] - Content Injection:
[cc] </pre><script>alert(1)</script> [/cc](Breaking out of the<pre>tag CodeColorer uses for rendering).
HTTP Request (via http_request tool):
- Method:
POST - URL:
http://localhost:8080/wp-comments-post.php - Headers:
Content-Type: application/x-www-form-urlencoded - Body:
author=attacker&
email=attacker%40example.com&
url=http%3A%2F%2Fexample.com&
comment=%5Bcc+lang%3D%27%22%3E%3Cscript%3Ealert%28document.domain%29%3C%2Fscript%3E%27%5Dtest%5B%2Fcc%5D&
submit=Post+Comment&
comment_post_ID=1&
comment_parent=0&
_wpnonce=[EXTRACTED_NONCE]
6. Test Data Setup
- Enable Comments: Ensure "Allow people to submit comments on new posts" is checked in
Settings > Discussion. - Target Post: Ensure a post with
ID=1exists (default "Hello World" post). - Plugin Activation: Confirm CodeColorer is active.
7. Expected Results
- The comment is successfully posted and redirected.
- When an administrator navigates to
wp-admin/edit-comments.phpor views the post at/?p=1, the browser executes the JavaScript. - An alert box appears showing the document domain, or a network request is triggered to an external listener if using a more complex payload.
8. Verification Steps
- Database Check:
Confirm the maliciouswp db query "SELECT comment_content FROM wp_comments ORDER BY comment_ID DESC LIMIT 1;"[cc]tag is stored. - Frontend Check:
Use thehttp_requesttool to GET the post page and grep for the script:# Check if the raw script tags appear in the response HTML # Note: Do not use curl inside the container. - Admin Panel Check:
Usebrowser_navigatetohttp://localhost:8080/wp-admin/edit-comments.phpand check for the presence of the injected tags in the DOM.
9. Alternative Approaches
- Shortcode in Post Content: If the attacker can gain "Contributor" permissions, they can place the payload directly into a post draft.
- Nested Tags: Try nesting tags to bypass simple regex filters:
[cc][cc]payload[/cc][/cc]. - Attribute Manipulation: If
langis sanitized, try other attributes liketab_size,line_numbers, ortheme(e.g.,theme='"><img src=x onerror=alert(1)>'). - REST API: Check if comments can be submitted via
/wp-json/wp/v2/commentsif the site has REST API comment submission enabled, which might bypass theme-level nonce requirements.
Summary
The CodeColorer plugin for WordPress is vulnerable to unauthenticated Stored Cross-Site Scripting in versions up to and including 0.10.1. This occurs because the plugin fails to sanitize or escape user-supplied attributes and content within its custom syntax highlighting tags (e.g., [cc], [codecolorer]), allowing attackers to inject malicious scripts via comments that execute when viewed by other users.
Security Fix
@@ -214,1 +214,1 @@ - $code_html = '<div class="codecolorer-container ' . $options['lang'] . ($options['class'] ? ' ' . $options['class'] : '') . '" style="' . $options['style'] . '">'; + $code_html = '<div class="codecolorer-container ' . esc_attr($options['lang']) . ($options['class'] ? ' ' . esc_attr($options['class']) : '') . '" style="' . esc_attr($options['style']) . '">';
Exploit Outline
The exploit is performed by submitting a comment to a WordPress post that includes a CodeColorer tag with a malicious attribute payload. An attacker first navigates to a public post to retrieve the comment submission nonce (_wpnonce) and the post ID. They then send a POST request to wp-comments-post.php with a comment body containing a payload like [cc lang='\"><script>alert(document.domain)</script>']test[/cc]. When the plugin processes this comment for display (via the comment_text filter), it concatenates the unescaped 'lang' attribute directly into the HTML output, leading to script execution in the context of any user, including administrators, who views the comment.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.