Skip to content
XSS Write-up Advanced

Stealing Credit Card Info with CSS

A CSS injection flaw in a payment form allowed an attacker to load arbitrary CSS via a postMessage, which could be used to exfiltrate credit card details as the user typed them. The attacker could steal card number, CVV, and expiry data by sending crafted CSS that triggered requests to their server.

castilho.sh

Published on castilho.sh

It's been a while since I posted something ... But I plan to bring new content into the blog and to get off on the right foot.

The author, on castilho.sh

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

Likely the application inserted user-supplied font URLs directly into a CSS @import rule without sanitisation, allowing arbitrary CSS injection.

Impact

An attacker could steal credit card information (card number, CVV, and expiry date) from users who typed it into the form after being tricked into visiting a malicious page.

What the attacker needed

Victim clicks a link; victim types card details

How it was found

  1. The attacker creates CSS files that use attribute selectors to match input values and trigger background-image requests to their server.
  2. The attacker hosts these CSS files on their own server.
  3. The attacker sends a postMessage to the checkout page with the CSS file URLs in the fonts array.
  4. The victim visits the attacker's page, which opens the checkout page and sends the postMessage.
  5. The victim types their credit card information into the form.
  6. The browser loads the attacker's CSS, which causes requests to the attacker's server containing the typed characters.

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.

The payment page accepted a list of font styles from another window and inserted them into the page without checking. An attacker could send their own stylesheet that made the browser request a URL containing the characters typed into the card form, revealing the card details to the attacker's server.

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.