Skip to content
XSS Write-up Beginner

XSS in Bootstrap 4.3.1: Tooltip-Based Exploit

Bootstrap 4.3.1 tooltips inject the raw HTML from title, data-title and data-template attributes into the page without sanitising it. If an application lets user input reach those attributes, an attacker can run JavaScript in the victim's browser.

medium.com

Published on medium.com

A working XSS vulnerability exists in web apps using Bootstrap 4.3.1. The issue is due to unsanitized tooltip attributes (title, data-title, data-template).

Abhiram, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Bootstrap's tooltip code inserts the title attribute value as raw HTML into the DOM instead of escaping it.

Impact

An attacker could steal cookies or sessions, phish credentials through injected UI, inject remote CSS, or manipulate the interface, though the text notes this only happens if tooltips are active and user input reaches the attribute.

What the attacker needed

App uses Bootstrap 4.3.1 tooltips; user input reaches title or data-title; tooltips are initialised and shown

The fix

The text says to escape or sanitise content placed into title and data-* attributes with a library such as DOMPurify, block javascript: in href, upgrade to Bootstrap v5 or later, and add a Content-Security-Policy header.

How it was found

  1. Create a new div element in the browser console.
  2. Set its data-toggle attribute to tooltip.
  3. Set its title attribute to an image tag with an onerror handler.
  4. Append the element to the page body.
  5. Initialise and show the tooltip with jQuery.
  6. Observe the alert firing, confirming script execution.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A tooltip is the small pop-up box that appears when you hover over something on a web page. Bootstrap, a common set of ready-made page components, builds that box by inserting the text from the title attribute directly into the page as HTML. If a website puts something a user typed into that attribute, the browser treats it as code and runs it, which lets an attacker do things in the victim's session.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.