Laboratorio pedagógico de CVE-2026-93485 (Comment2Shell): stored XSS no autenticado en WordPress core vía wpautop -> RCE, con demo del root cause auto-verificada, control 7.1.1 y la vía Post2Shell
WordPress core · Unauthenticated stored XSS -> RCE via admin session · zero-click CVSS 3.1 7.1 (Patchstack) · found by Rafie Muhammad (Awesome Motive) · fixed in WordPress 7.1.1 (2026-09-17), backported down to 4.7.36
A self-contained Docker lab to understand and defend against this vulnerability. It replicates the original write-up's scenario: an anonymous visitor leaves a comment; when someone with an admin session simply views the page, the payload executes in their browser and escalates to command execution on the server (hence Comment2Shell).
It also contributes something new to the field (verified with real
execution, not described in the write-up): the same chain works via
contributor POST content — the surface is not only comments
(make post2shell, details in research/HALLAZGOS.md,
Spanish).
Everything runs on your machine against your own containers. Nothing here is to be used against third-party systems.
<!-- The full payload (with a REAL newline inside cite) -->
<blockquote cite="a
b"><code>x" onfocus=alert(document.domain) autofocus tabindex=0</code></blockquote>
(Full Spanish README with extra details: README.md)
make lab # victim WP 7.1.0 at http://localhost:8080 (admin / lab-admin-2026)
make plant # phase 1: anonymous comment with the payload
make view # phase 2: HTML served to the admin -> verdict (live/inert)
make demo-flip # phase 3: root-cause with the REAL 7.1.0 vs 7.1.1 code
make rce # phase 5: XSS->RCE (nonce -> plugin upload -> id)
make post2shell # phase 6 (CONTRIBUTION): contributor-post vector, victim vs control
make landing # serves the landing at :8090 (also published at https://686f6c61.github.io/POC-WP-CORE-CVE-2026-93485/)
make clean # destroy everything
Full demo (includes the WP 7.1.1 patched negative control at :8081):
make full-demo
Check it in your own browser (direct): after make plant, log in
at http://localhost:8080/wp-admin (admin / lab-admin-2026) and open the
post — you will see the document.domain alert without clicking
anything. On the control (:8081, WP 7.1.1) the same comment is inert
text.
Requirements: Docker + docker compose, curl, python3, make.
The bug lives in the gap between sanitization and rendering of comment content:
| Step | What happens | Where |
|---|---|---|
| 1. Plant | The comment passes wp_kses_post. The allowlist permits blockquote[cite] and <code>. kses re-encodes & < > ' " in attribute values, but not the newline -> cite="a\nb" survives, and the raw quote inside <code> is legal text. | wp-includes/kses.php |
| 2. wpautop breaks the tag | At render time wpautop protects \n inside tags with an <!-- wpnl --> placeholder… which contains a >. The regex at line 563 |<p><blockquote([^\>]*)|i is not quote-aware: its capture stops at that internal > and injects ><p> in the MIDDLE of the cite value. | wp-includes/formatting.php:563 |
| 3. wptexturize curls the quote | The wptexturize pass over the final template HTML (get_the_block_template_html() -> block-template.php:297) turns cite's closing quote into ” (the attribute stays "open") because the injected <p> acts as a tag boundary; but it respects the raw quote inside <code> (exclusion list pre, code, kbd, style, script, tt). | template pass, after wpautop |
| 4. The browser executes | For the browser, the cite value now extends to the quote inside <code>x". Everything after — onfocus=…, autofocus, tabindex=0 — becomes real attributes of the <blockquote>. tabindex=0 makes it focusable and autofocus fires onfocus on load: zero-click XSS. | visitor/admin browser |
The RCE escalation (phase 5) is the one from the write-up: with the admin
session, the JS fetches /wp-admin/plugin-install.php?tab=upload, extracts
_wpnonce, builds an in-memory ZIP with a one-line plugin and uploads it to
update.php?action=upload-plugin. No activation needed: plugin files are
directly reachable under /wp-content/plugins/.
- $text = preg_replace( '|<p><blockquote([^>]*)>|i', '<blockquote$1><p>', $text );
+ $text = preg_replace( '!<p><blockquote((?:[^>"\']|"[^"]*"|\'[^\']*\')*)>!i', '<blockquote$1><p>', $text );
The new pattern only crosses quotes as complete pairs ("…"), so the match
ends at the tag's real >. Full forensic analysis in
research/PARCHE.md (Spanish).
Links: patch commit (b05c380) · full diff 7.1…7.1.1 · tag 7.1.1 · WordPress releases
The diff also includes a second security change. Besides line 563, 7.1.1 hardened
WP_HTML_Tag_Processor::set_modifiable_text() (class-wp-html-tag-processor.php:3991:
/--!?>/ -> /^-?>|--!?>/ for HTML comment data). It is not on kses's read
path and public CVE coverage doesn't mention it — documented as part of our
patch forensics (HALLAZGOS §5, Spanish).
The write-up and the CVE describe the vector through the anonymous comment
form. But the root cause — kses keeps inside attribute values +
wpautop line 563 + template-level wptexturize pass — is not
comment-specific: it also occurs on the_content of any post whose author
lacks unfiltered_html (contributor/author), since their content is
sanitized with wp_filter_post_kses on save and rendered through the same
pipeline.
Verified in this lab (make post2shell on victim and control):
onfocus executes real JavaScript in headless
Chrome (DOM marker data-c2s-post="XSS-EN-POST-DE-COLABORADOR").Implications: "Comment2Shell" is also "Post2Shell" (attacker needs an
authenticated contributor instead of nobody — less severe, more people to
watch); IOCs must include post_content from low-trust users, not just
wp_comments; and "are comments open?" is the wrong question — sites with
closed comments but open contributor registration remain exposed unpatched.
Real lab captures (regenerate with make capturas; the browser shots use a
visible-effect variant of the same payload). Full captions in
README.md.
| WP 7.1.0 — XSS fires on page load | WP 7.1.1 — inert |
|---|---|
![]() | ![]() |