Skip to content
XSS Write-up Intermediate

Exploiting XSS in hidden inputs and meta tags

The article describes how the new HTML popover API in Chrome can be abused to execute JavaScript in hidden inputs and meta tags via the onbeforetoggle event. An attacker who can inject HTML into a hidden input or meta tag can achieve XSS if the page already contains a popover element, by duplicating its id and using the popovertarget attribute.

Gareth Heyes Follow

Published on portswigger.net

It all started when I noticed the new popover behaviour with Chrome on Twitter. We all know about annoying modal dialogs that nag you to subscribe to a newsletter - now you can create these popups without JavaScript!

Gareth Heyes (@garethheyes), on portswigger.net

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

Impact

An attacker could execute arbitrary JavaScript in the context of the vulnerable page, potentially leading to data theft or other malicious actions, but only if the page already has a popover element and the user interacts with it.

What the attacker needed

Victim clicks a button; page has an existing popover element; injection point in hidden input or meta tag

How it was found

  1. Identify a page that contains a popover element (an element with the popover attribute and a corresponding button with popovertarget).
  2. Inject HTML into a hidden input or meta tag that includes an onbeforetoggle event handler and a popover attribute with the same id as the existing popover.
  3. When the user clicks the button that targets the popover, the onbeforetoggle event fires on the injected element, executing the JavaScript.

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.

Cross-site scripting (XSS) is when an attacker sneaks JavaScript into a web page so it runs in a victim's browser. Normally, hidden input fields and meta tags are hard to exploit because most events don't fire there. This article shows that a new browser feature called popovers lets an event fire when a button is clicked, even inside those restricted elements, so injected code can run.

What is XSS?

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

More by Gareth Heyes

View all

15 more disclosed reports, best first.

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.