MODERATE 6.1

CVE-2026-141416

Bootstrap: Datepicker data API turns a sanitizer-preserved `data-bs-vcp-options` attribute into executable calendar HTML

Description

Summary

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. Bootstrap'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. Bootstrap'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". This 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.

  • 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. The Bootstrap 6 bundle ships Vanilla Calendar Pro (peer vanilla-calendar-pro@^3.4.0, resolved to 3.4.0).
  • 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.
  • 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.

Threat Model

Preconditions:

  • 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.
  • 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).
  • 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.
  • A victim focuses the attacker-supplied input. The interaction is one ordinary focus of a normal-looking date field (clicking or tabbing into it).

Attack steps:

  • The attacker submits HTML through the application's normal content path: an <input data-bs-toggle="datepicker" data-bs-vcp-options='{"layouts":{"default":"<img ... onerror=...>"}}'>.
  • 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.
  • 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.
  • The injected markup's onerror handler runs the attacker's JavaScript on the application's origin.

Practical impact in an app that renders DOMPurify-sanitized user HTML and loads Bootstrap 6:

  • 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.

Root Cause

Bootstrap's generic data API JSON-decodes data-attribute values and merges every data-bs-* attribute, plus data-bs-config, into a plugin's configuration.

// https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/dom/manipulator.ts#L29-L31
try {
return JSON.parse(decodeURIComponent(value))
} catch {
// https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/util/config.ts#L53-L58
return {
...this.constructor.Default,
...(typeof jsonConfig === 'object' ? jsonConfig : {}),
...(isElement(element) ? Manipulator.getDataAttributes(element as HTMLElement) : {}),
...(typeof config === 'object' ? config : {})
}

The 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.

// https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/datepicker.ts#L419-L420
const calendarOptions: Options = {
...this._config.vcpOptions,

Focusing the input creates and shows the calendar automatically through the Datepicker data API, with no further interaction.

// https://github.com/twbs/bootstrap/blob/3b7f32318876bbd3c9cc14d3f891d744f39cd538/js/src/datepicker.ts#L571-L577
EventHandler.on(document, EVENT_FOCUSIN_DATA_API, SELECTOR_DATA_TOGGLE, function () {
// Handle focus for input elements
if (this.tagName !== 'INPUT') {
return
}
Datepicker.getOrCreateInstance(this).show()
})

Vanilla 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.

// https://github.com/uvarov-frontend/vanilla-calendar-pro/blob/0947da2f3d5435f92b3de0124e081e0e0f8cccb1/package/src/scripts/creators/createLayouts.ts#L41-L44
if (!extensions.months?.render(self, target)) {
extensions.time?.destroy(self);
self.context.mainElement.innerHTML = self.sanitizerHTML(parseLayout(self, self.layouts[self.context.currentType]));
}

The default sanitizerHTML is (html) => html, so by default nothing is stripped (renderState.ts#L6, options.ts#L88). Vanilla 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. The 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.

Bootstrap's JavaScript security model excludes only "vulnerabilities caused solely by disabling or modifying content sanitization". That exclusion does not apply here: the application's DOMPurify is enabled and unmodified, and its documented default deliberately preserves data-* attributes. Bootstrap then converts an otherwise inert, documented configuration attribute into live calendar markup. The same configuration also reaches the Datepicker through the documented generic data-bs-config JSON attribute ({"vcpOptions":{"layouts":{...}}}), which we verified executes identically.

Bootstrap 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. This is the same class of data-attribute script gadget in a new Bootstrap 6 plugin, through the bundled Vanilla Calendar Pro sink.

Proof of Concept

The 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. PoC files are in this gist.

  • Deployment: run run.sh, which npm installs 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 loads the npm prerelease bundle; index-main.html loads bootstrap-main-3b7f323.bundle.min.js, the production bundle built from main@3b7f323; index-alpha1-config.html delivers the same payload through the generic data-bs-config attribute.
  • Attacker: the submitted HTML is the single element <input id="malicious-calendar" type="text" data-bs-toggle="datepicker" data-bs-vcp-options='{"layouts":{"default":"<img id=pwn src=x data-u=/leak?token= onerror=window.pwned=true,fetch(this.dataset.u+window.__private)>"}}'>. 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.
  • 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 <img id="pwn" src="x" data-u="/leak?token=" onerror="window.pwned=true,fetch(this.dataset.u+window.__private)">, window.pwned is true, and a same-origin request GET /leak?token=<token> is issued. Running test.cjs over the matrix prints:
PASS alpha1/vcp-options/chromium: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E
PASS alpha1/vcp-options/firefox: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E
PASS alpha1/config/chromium: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E
PASS alpha1/config/firefox: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E
PASS main/vcp-options/chromium: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E
PASS main/vcp-options/firefox: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E
PASS main/config/chromium: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E
PASS main/config/firefox: pwned=true injected=true exfil=.../leak?token=%3Ctoken%3E
PASS patched/vcp-options/chromium: pwned=false injected=false exfil=none
PASS patched/config/chromium: pwned=false injected=false exfil=none
PASS patched/benign/chromium: benign calendar renders=true pwned=false

The 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.

PoC 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.

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= is issued.

The same result on a production bundle built from current main@3b7f323, confirming the default development branch is affected:

Bootstrap main 3b7f323 with DOMPurify 3.4.17 defaults: the sanitized input executes the payload on focus, window.pwned is true.

The 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.

Patched main 3b7f323: the exploit is blocked (window.pwned false, no injected image) while the real Vanilla Calendar Pro layout still renders.

Impact

A 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. On 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. The 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. A strict CSP that forbids inline event handlers would block the resulting handler, but Bootstrap neither requires nor documents such a CSP as its default. The 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.

Mitigation Advice

Keep the HTML-bearing Vanilla Calendar Pro options out of the untrusted data-attribute surface. Our 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. HTML 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.

const UNSAFE_VCP_DATA_OPTIONS = new Set(['layouts', 'popups', 'sanitizerHTML'])
// in _mergeConfigObj(), after the normal merge, for options that came from the
// element's data attributes and were not re-supplied by the JavaScript config:
for (const key of UNSAFE_VCP_DATA_OPTIONS) {
if (key in fromDataAttributes && !(key in fromJavaScript)) {
delete safe[key]
}
}

The reporter tested this against main@3b7f323. A 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. The 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). A 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. The full patch, against main@3b7f323 (js/src/datepicker.ts and js/tests/unit/datepicker.spec.js), is mitigation.diff.

Relationship to the Toggler advisory (GHSA-pj28-6c95-2682)

The 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. This Datepicker issue shares only the broad external condition that DOMPurify preserves data-* attributes; it is a different root cause in a different component. The Toggler fix changes only js/src/toggler.ts and its tests and docs, and does not touch the Datepicker or Vanilla Calendar Pro. We 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. Both should be fixed in alpha.2.

Affected Maven artifacts (3)

ArtifactAffected versionsFixed in
org.mvnpm » bootstrapvia npm bootstrap
>= 6.0.0-alpha.1, < 6.0.0-alpha.2
6.0.0-alpha.2
org.webjars » bootstrapvia npm bootstrap
>= 6.0.0-alpha.1, < 6.0.0-alpha.2
6.0.0-alpha.2
org.webjars.npm » bootstrapvia npm bootstrap
>= 6.0.0-alpha.1, < 6.0.0-alpha.2
6.0.0-alpha.2

Blast radius

1affected artifacts
1affected versions
0dependent artifacts (est.)
0dependent versions

Computed from the dependency graph of build 20261201.0702 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.

Other ecosystems

Also affects npm (1 package) . See all on OSV