{"id":"GHSA-hhp5-vh47-5858","summary":"Bootstrap: Datepicker data API turns a sanitizer-preserved `data-bs-vcp-options` attribute into executable calendar HTML","details":"## Summary\n\n[Bootstrap](https://github.com/twbs/bootstrap)'s new Datepicker plugin (Bootstrap 6) is documented to take any Vanilla Calendar Pro setting through the data attribute `data-bs-vcp-options`, holding a JSON object.\nBootstrap's data API JSON-decodes that attribute, and the Datepicker spreads the decoded object straight into Vanilla Calendar Pro, which renders its `layouts` option with `innerHTML` under an identity default sanitizer.\nBootstrap's own security model promises that content is sanitized unless the integrator disables or modifies that sanitization, and scopes out only \"vulnerabilities caused solely by disabling or modifying content sanitization\".\nThis report disables and modifies nothing: an application that renders untrusted HTML through default DOMPurify keeps the inert `data-bs-*` attributes (DOMPurify preserves `data-*` by default), so a single input carrying `data-bs-toggle=\"datepicker\"` and a JSON `layouts.default` passes the sanitizer with no executable attribute, and the browser runs the attacker's script the moment a victim focuses that input.\n\n- Affected: `bootstrap` on the Bootstrap 6 line, including the published prerelease `6.0.0-alpha.1` (npm `next` tag, released 2026-10-08) and the default `main` branch at [`3b7f323`](https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/datepicker.ts#L419-L420). The Bootstrap 6 bundle ships Vanilla Calendar Pro (peer `vanilla-calendar-pro@^3.4.0`, resolved to `3.4.0`).\n- Not the current stable default: `npm install bootstrap` installs `5.3.8` (npm `latest`), which has no Datepicker plugin and is unaffected. We report this before the first stable 6.0 release so the behavior does not ship in it.\n- Related but distinct root cause: this is not the Toggler issue GHSA-pj28-6c95-2682 (which we also reported, accepted for a fix in v6 alpha.2). The Toggler fix does not touch the Datepicker, and the exploit still executes on that private fix branch. See \"Relationship to the Toggler advisory\" below.\n\n## Threat Model\n\nPreconditions:\n- An application renders rich HTML from an untrusted user, sanitizes it with DOMPurify in its default configuration (which keeps `data-*` attributes), and inserts the result into the DOM, for example with `innerHTML`. This is a common user-generated-content pattern, but it is the integration-specific condition that makes the bug reachable, so we treat it as non-universal.\n- The page loads the Bootstrap 6 bundle that contains the Datepicker plugin and bundled Vanilla Calendar Pro (`6.0.0-alpha.1`, or a build of current `main`).\n- The response has no Content Security Policy that forbids the resulting inline event handler. Bootstrap does not require or set such a CSP by default.\n- A victim focuses the attacker-supplied input. The interaction is one ordinary focus of a normal-looking date field (clicking or tabbing into it).\n\nAttack steps:\n- The attacker submits HTML through the application's normal content path: an `\u003cinput data-bs-toggle=\"datepicker\" data-bs-vcp-options='{\"layouts\":{\"default\":\"\u003cimg ... onerror=...\u003e\"}}'\u003e`.\n- DOMPurify's default sanitize keeps the two `data-bs-*` attributes and removes nothing else; the stored or rendered element has no event handler and looks inert.\n- A victim views the content and focuses the field; the Datepicker data API JSON-decodes `data-bs-vcp-options`, spreads it into Vanilla Calendar Pro, and VCP assigns the attacker's `layouts.default` to the calendar with `innerHTML` under its identity default sanitizer.\n- The injected markup's `onerror` handler runs the attacker's JavaScript on the application's origin.\n\nPractical impact in an app that renders DOMPurify-sanitized user HTML and loads Bootstrap 6:\n- Arbitrary JavaScript on the application origin as the victim: reading `localStorage`, `sessionStorage` and script-accessible cookies, exfiltrating a token, making authenticated same-origin requests, and modifying the page. Our PoC demonstrates attacker-chosen JavaScript execution (`window.pwned = true`) and a same-origin exfiltration request.\n\n## Root Cause\n\nBootstrap's generic data API JSON-decodes data-attribute values and merges every `data-bs-*` attribute, plus `data-bs-config`, into a plugin's configuration.\n\n```ts\n// https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/dom/manipulator.ts#L29-L31\n  try {\n    return JSON.parse(decodeURIComponent(value))\n  } catch {\n```\n\n```ts\n// https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/util/config.ts#L53-L58\n    return {\n      ...this.constructor.Default,\n      ...(typeof jsonConfig === 'object' ? jsonConfig : {}),\n      ...(isElement(element) ? Manipulator.getDataAttributes(element as HTMLElement) : {}),\n      ...(typeof config === 'object' ? config : {})\n    }\n```\n\nThe Datepicker declares `vcpOptions` as a pass-through object for any Vanilla Calendar Pro option, and spreads the attacker-controlled object directly into the calendar constructor options with no sanitizer.\n\n```ts\n// https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/datepicker.ts#L419-L420\n    const calendarOptions: Options = {\n      ...this._config.vcpOptions,\n```\n\nFocusing the input creates and shows the calendar automatically through the Datepicker data API, with no further interaction.\n\n```ts\n// https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/datepicker.ts#L571-L577\nEventHandler.on(document, EVENT_FOCUSIN_DATA_API, SELECTOR_DATA_TOGGLE, function () {\n  // Handle focus for input elements\n  if (this.tagName !== 'INPUT') {\n    return\n  }\n\n  Datepicker.getOrCreateInstance(this).show()\n})\n```\n\nVanilla Calendar Pro owns the HTML sink: its `sanitizerHTML` option defaults to an identity function, and the selected layout string is assigned with `innerHTML` through that default sanitizer.\n\n```ts\n// https://github.com/uvarov-frontend/vanilla-calendar-pro/blob/0947da2f3d5435f92b3de0124e081e0e0f8cccb1/package/src/scripts/creators/createLayouts.ts#L41-L44\n  if (!extensions.months?.render(self, target)) {\n    extensions.time?.destroy(self);\n    self.context.mainElement.innerHTML = self.sanitizerHTML(parseLayout(self, self.layouts[self.context.currentType]));\n  }\n```\n\nThe default `sanitizerHTML` is `(html) =\u003e html`, so by default nothing is stripped ([`renderState.ts#L6`](https://github.com/uvarov-frontend/vanilla-calendar-pro/blob/0947da2f3d5435f92b3de0124e081e0e0f8cccb1/package/src/scripts/utils/renderState.ts#L6), [`options.ts#L88`](https://github.com/uvarov-frontend/vanilla-calendar-pro/blob/0947da2f3d5435f92b3de0124e081e0e0f8cccb1/package/src/options.ts#L88)).\nVanilla Calendar Pro documents that layouts carry HTML and that an integrator must supply `sanitizerHTML` for untrusted content; the Bootstrap Datepicker neither supplies one nor keeps the HTML-bearing options off the untrusted data-attribute surface.\nThe complete chain is: a sanitizer-preserved `data-bs-vcp-options` attribute, JSON-decoded by Bootstrap, spread by the Datepicker into Vanilla Calendar Pro's `layouts`, rendered with `innerHTML` under the identity default sanitizer, producing an executable handler.\n\nBootstrap's JavaScript security model excludes only \"vulnerabilities caused solely by disabling or modifying content sanitization\".\nThat exclusion does not apply here: the application's DOMPurify is enabled and unmodified, and its documented default deliberately preserves `data-*` attributes.\nBootstrap then converts an otherwise inert, documented configuration attribute into live calendar markup.\nThe same configuration also reaches the Datepicker through the documented generic `data-bs-config` JSON attribute (`{\"vcpOptions\":{\"layouts\":{...}}}`), which we verified executes identically.\n\nBootstrap has treated attacker-controlled `data-*` options as a security boundary before: CVE-2019-8331 / GHSA-9v3m-8fp8-mj99 (tooltip/popover `data-template`) and CVE-2024-6485 / GHSA-vxmc-5x29-h64v (button `data-loading-text`), among others.\nThis is the same class of data-attribute script gadget in a new Bootstrap 6 plugin, through the bundled Vanilla Calendar Pro sink.\n\n## Proof of Concept\n\nThe reporter set up a minimal page that follows the documented user-generated-content pattern, where an application sanitizes untrusted HTML with DOMPurify's defaults, inserts it with `innerHTML`, and loads the Bootstrap 6 Datepicker, and act as a remote attacker who submits HTML and gets a victim to focus the field.\nPoC files are in [this gist](https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c#file-report-md).\n\n- Deployment: run [`run.sh`](https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c#file-run-sh), which `npm install`s `bootstrap@6.0.0-alpha.1`, `dompurify@3.4.17` and `playwright@1.64.1`, serves the pages on `http://127.0.0.1:18767` with no CSP, and drives real headless Chromium and Firefox. [`index-alpha1.html`](https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c#file-index-alpha1-html) loads the npm prerelease bundle; [`index-main.html`](https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c#file-index-main-html) loads [`bootstrap-main-3b7f323.bundle.min.js`](https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c#file-bootstrap-main-3b7f323-bundle-min-js), the production bundle built from `main@3b7f323`; [`index-alpha1-config.html`](https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c#file-index-alpha1-config-html) delivers the same payload through the generic `data-bs-config` attribute.\n- Attacker: the submitted HTML is the single element `\u003cinput id=\"malicious-calendar\" type=\"text\" data-bs-toggle=\"datepicker\" data-bs-vcp-options='{\"layouts\":{\"default\":\"\u003cimg id=pwn src=x data-u=/leak?token= onerror=window.pwned=true,fetch(this.dataset.u+window.__private)\u003e\"}}'\u003e`. The page sanitizes it with `DOMPurify.sanitize(dirty)` and inserts the result; the attacker position is a remote user of the content feature, with no account or privilege.\n- Exploit: open the page and focus the input. DOMPurify's output keeps only the inert `data-bs-*` attributes (no `onerror`); after focus the calendar DOM contains `\u003cimg id=\"pwn\" src=\"x\" data-u=\"/leak?token=\" onerror=\"window.pwned=true,fetch(this.dataset.u+window.__private)\"\u003e`, `window.pwned` is `true`, and a same-origin request `GET /leak?token=\u003ctoken\u003e` is issued. Running [`test.cjs`](https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c#file-test-cjs) over the matrix prints:\n\n```text\nPASS alpha1/vcp-options/chromium: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E\nPASS alpha1/vcp-options/firefox:  pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E\nPASS alpha1/config/chromium:      pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E\nPASS alpha1/config/firefox:       pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E\nPASS main/vcp-options/chromium:   pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E\nPASS main/vcp-options/firefox:    pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E\nPASS main/config/chromium:        pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E\nPASS main/config/firefox:         pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E\nPASS patched/vcp-options/chromium: pwned=false injected=false exfil=none\nPASS patched/config/chromium:      pwned=false injected=false exfil=none\nPASS patched/benign/chromium:      benign calendar renders=true pwned=false\n```\n\nThe payload is attacker-chosen: `data-bs-vcp-options` is copied verbatim into the calendar HTML, so the executed JavaScript is whatever the attacker wrote, not a fixed side effect.\n\nPoC run on the published prerelease `bootstrap@6.0.0-alpha.1` (npm), headless Chromium 156: the sanitized input executed the payload on focus and the result panel reads `window.pwned: true` with the exfiltration request recorded.\n\n![Bootstrap 6.0.0-alpha.1 with DOMPurify 3.4.17 defaults: the sanitized input carries no onerror, yet after focus the calendar DOM holds the injected onerror image, window.pwned is true, and GET /leak?token=\u003ctoken\u003e is issued.](https://gist.githubusercontent.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c/raw/62cd4f8cf8f7f2ac5a3a0de460e4a8df8a1cd3a4/bootstrap-alpha1-datepicker-xss.png)\n\nThe same result on a production bundle built from current `main@3b7f323`, confirming the default development branch is affected:\n\n![Bootstrap main 3b7f323 with DOMPurify 3.4.17 defaults: the sanitized input executes the payload on focus, window.pwned is true.](https://gist.githubusercontent.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c/raw/b5d61060707c263b5dba6c393a8d3f36110ad9b5/bootstrap-main-3b7f323-datepicker-xss.png)\n\nThe same page against a bundle built from `main@3b7f323` with our patch applied: no handler is injected, `window.pwned` stays `false`, and the calendar still renders normally.\n\n![Patched main 3b7f323: the exploit is blocked (window.pwned false, no injected image) while the real Vanilla Calendar Pro layout still renders.](https://gist.githubusercontent.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c/raw/25735fcdbe1d4449987bdf154cffe6dc8cecbb50/bootstrap-patched-datepicker-blocked.png)\n\n## Impact\n\nA remote attacker who can place HTML into an application that sanitizes with DOMPurify's defaults and loads the Bootstrap 6 Datepicker can run arbitrary JavaScript on that application's origin after one victim focus, despite the sanitizer.\nOn such a deployment this gives the attacker the victim's session: reading tokens from storage and script-accessible cookies, making authenticated same-origin requests as the victim, and modifying the page; our PoC reads a same-origin placeholder value and exfiltrates it with a same-origin request.\nThe attacker needs no account and no privileged access, no disabled or customized sanitizer, no JavaScript callback or application glue, no browser extension and no non-default Bootstrap build; only an application in the user-generated-rich-HTML class, a page with no blocking CSP, and one focus.\nA strict CSP that forbids inline event handlers would block the resulting handler, but Bootstrap neither requires nor documents such a CSP as its default.\nThe affected line is the opt-in Bootstrap 6 prerelease (npm `next`) or a current `main` build, not the stable `5.3.8` that `npm install bootstrap` gives; this and the application-specific sanitized-rich-HTML precondition are why we score attack complexity high.\n\n## Mitigation Advice\n\nKeep the HTML-bearing Vanilla Calendar Pro options out of the untrusted data-attribute surface.\nOur patch has the Datepicker override `_mergeConfigObj` so that the VCP options that Vanilla Calendar Pro renders as HTML (`layouts`, `popups`) or that replace its HTML sanitizer (`sanitizerHTML`) are dropped when they arrive through element data attributes (`data-bs-vcp-options`, or a `vcpOptions` object inside `data-bs-config`), while the same options supplied through the JavaScript `config` argument are kept intact.\nHTML callbacks such as `onCreateDateEls` cannot be expressed in a JSON data attribute, so they are already unreachable from the data API; markup and sanitizer callbacks belong in developer JavaScript, not in an element's attributes.\n\n```ts\nconst UNSAFE_VCP_DATA_OPTIONS = new Set(['layouts', 'popups', 'sanitizerHTML'])\n// in _mergeConfigObj(), after the normal merge, for options that came from the\n// element's data attributes and were not re-supplied by the JavaScript config:\nfor (const key of UNSAFE_VCP_DATA_OPTIONS) {\n  if (key in fromDataAttributes && !(key in fromJavaScript)) {\n    delete safe[key]\n  }\n}\n```\n\nThe reporter tested this against `main@3b7f323`.\nA bundle built from the patched source leaves the PoC input with no injected handler and does not execute on focus, through both the `data-bs-vcp-options` and the generic `data-bs-config` route, in headless Chromium and Firefox, while a benign datepicker still renders a working Vanilla Calendar Pro calendar and `layouts` supplied through the JavaScript API still apply.\nThe patch covers both delivery routes and all the HTML-bearing option keys (every `layouts` key, `popups`, and a `sanitizerHTML` override attempt); the seven added unit tests assert each is dropped from data attributes and kept from JavaScript, and the Datepicker suite passes (`vitest run js/tests/unit/datepicker.spec.js`: 120 passed, 7 new).\nA maintainer may instead prefer to ship a safe default `sanitizerHTML` to Vanilla Calendar Pro; note that Bootstrap's existing `sanitizeHtml`/`DefaultAllowlist` would strip Vanilla Calendar Pro's own layout elements and attributes and break the calendar, so that route needs a VCP-aware allowlist, which is why we keep the HTML-bearing options off the data-attribute surface instead.\nThe full patch, against `main@3b7f323` (`js/src/datepicker.ts` and `js/tests/unit/datepicker.spec.js`), is [`mitigation.diff`](https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c#file-mitigation-diff).\n\n### Relationship to the Toggler advisory (GHSA-pj28-6c95-2682)\n\nThe reporter separately reported the Bootstrap 6 Toggler data-attribute XSS (GHSA-pj28-6c95-2682), which Bootstrap accepted with a fix planned for v6 alpha.2.\nThis Datepicker issue shares only the broad external condition that DOMPurify preserves `data-*` attributes; it is a different root cause in a different component.\nThe Toggler fix changes only `js/src/toggler.ts` and its tests and docs, and does not touch the Datepicker or Vanilla Calendar Pro.\nWe built that exact private fix branch and re-ran this PoC: the Datepicker XSS still executed in Chromium and Firefox through both the `data-bs-vcp-options` and `data-bs-config` routes.\nBoth should be fixed in alpha.2.","aliases":["CVE-2026-141416"],"modified":"2026-12-02T01:45:50.932091960Z","published":"2026-12-02T00:30:38Z","database_specific":{"cwe_ids":["CWE-79","CWE-83"],"severity":"MODERATE","github_reviewed":true,"github_reviewed_at":"2026-12-02T00:30:38Z","nvd_published_at":"2026-12-01T21:17:10Z"},"references":[{"type":"WEB","url":"https://github.com/twbs/bootstrap/security/advisories/GHSA-hhp5-vh47-5858"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-141416"},{"type":"WEB","url":"https://github.com/twbs/bootstrap/commit/0710e4096c854c3be6a4a7a2bba404f93d449993"},{"type":"WEB","url":"https://gist.github.com/superboy-zjc/addeea5eb1e971c01274f72185ba9b1c"},{"type":"PACKAGE","url":"https://github.com/twbs/bootstrap"},{"type":"WEB","url":"https://github.com/twbs/bootstrap/releases/tag/v6.0.0-alpha.2"}],"affected":[{"package":{"name":"bootstrap","ecosystem":"npm","purl":"pkg:npm/bootstrap"},"ranges":[{"type":"SEMVER","events":[{"introduced":"6.0.0-alpha.1"},{"fixed":"6.0.0-alpha.2"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-hhp5-vh47-5858/GHSA-hhp5-vh47-5858.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"}]}