MCP server CSS mix-blend-mode consent security
Four SA-CSS-MBM consent attack patterns using mix-blend-mode to composite dark consent text against a white background in ways that produce white-on-white or near-white output. The lighten blend mode computes max(source, backdrop) per channel — on a white background the output is always white regardless of source color. The screen formula reduces to exactly 1.0 whenever the backdrop channel is 1.0, making any dark text invisible. color-dodge divides the backdrop by (1−source), clamping to white on any white background. soft-light with a white parent container applies extreme brightening that washes out dark child text. All four patterns leave opacity:1 and the color property unchanged, evading standard opacity and color checks.
The CSS mix-blend-mode property changes how an element's pixels are composited with the pixels of the element behind it (its backdrop). The backdrop is the rendered result of all elements stacking below the element in the stacking context, including the page background. When a white background exists behind a consent text element, several blend modes mathematically guarantee that the output is white regardless of the element's actual color property. Automated WCAG checkers that extract getComputedStyle(el).color and compare it to the background color do not account for blend mode compositing: they will report rgb(17,17,17) on white as passing 19.6:1 contrast while the rendered output is 1:1.
SA-CSS-MBM-001: mix-blend-mode:lighten — max(source, backdrop) always white
The lighten blend mode computes the output for each color channel as max(Cs, Cb), where Cs is the source (element) channel value and Cb is the backdrop (background) channel value. On a white background, every backdrop channel equals 1.0. For any dark text color, every source channel is less than 1.0. Therefore max(dark, 1.0) = 1.0 at every pixel, and the consent text is rendered identically to the white background — contrast ratio 1:1.
.consent-text {
color: #111111;
mix-blend-mode: lighten; /* lighten: output = max(Cs, Cb) per channel */
}
/* Lighten formula (per W3C compositing and blending spec):
B(Cs, Cb) = max(Cs, Cb)
sRGB color #111111 per channel:
sRGB value = 17/255 = 0.0667
Linear light: since 0.0667 > 0.04045, use: ((0.0667 + 0.055) / 1.055)^2.4 ≈ 0.00518
White background → Cb = 1.0 (linear) for all three channels (R, G, B).
Lighten result per channel:
R_out = max(0.00518, 1.0) = 1.0
G_out = max(0.00518, 1.0) = 1.0
B_out = max(0.00518, 1.0) = 1.0
Output color: rgb(255, 255, 255) — identical to white background.
Rendered contrast ratio: (1.0 + 0.05) / (1.0 + 0.05) = 1:1 — CRITICAL WCAG failure.
Note: ANY dark text color produces the same result on a white background.
#888888 → sRGB 0.533 → linear ≈ 0.247 → max(0.247, 1.0) = 1.0 → still white.
#ff0000 (red) → R=1.0, G=0, B=0 → max(R:1.0,1.0)=1.0; G,B also max to 1.0 → white.
Any Cs < Cb=1.0 → max(Cs, 1.0) = 1.0. Lighten on white always outputs white.
CSSOM evasion:
getComputedStyle(el).color → "rgb(17, 17, 17)" (unchanged; contrast reported 19.6:1)
getComputedStyle(el).opacity → "1" (opacity unchanged)
getComputedStyle(el).mixBlendMode → "lighten" (detectable via this property)
Detection algorithm:
1. Read getComputedStyle(el).mixBlendMode for each consent text element.
2. If mixBlendMode ∈ {"lighten", "screen", "color-dodge"} → proceed to step 3.
3. Resolve backdrop color: walk ancestor chain for background-color.
If R, G, B all >= 245 → white backdrop confirmed.
4. CRITICAL finding. */
CSSOM blind spot: Standard WCAG contrast checkers extract getComputedStyle(el).color and compare it to the computed background color. They will report 19.6:1 for #111111 on white. The mixBlendMode computed style property is available on every element but is not factored into WCAG contrast calculation by any standard tool. Auditors must explicitly read mix-blend-mode and simulate blend output before computing contrast.
getComputedStyle reports original color unchanged. Detection: mixBlendMode === "lighten" on consent text with white backdrop → CRITICAL.SA-CSS-MBM-002: mix-blend-mode:screen — formula collapses to 1.0 on white backdrop
The screen blend mode formula is B(Cs,Cb) = Cs + Cb − Cs×Cb, which can be rewritten as 1 − (1−Cs)(1−Cb). When the backdrop is white (Cb=1.0), the term (1−Cb)=0, so the product (1−Cs)(1−Cb)=0 regardless of Cs. The result is always 1−0=1.0. No matter what color the consent text is, the screen blend mode over a white background produces white output at every pixel.
.consent-text {
color: #111111;
mix-blend-mode: screen; /* screen: output = Cs + Cb - Cs * Cb */
}
/* Screen blend mode formula (W3C compositing and blending spec):
B(Cs, Cb) = Cs + Cb - Cs * Cb
= 1 - (1 - Cs)(1 - Cb)
For white background: Cb = 1.0
Substituting Cb = 1.0:
B(Cs, 1.0) = 1 - (1 - Cs)(1 - 1.0)
= 1 - (1 - Cs) * 0
= 1 - 0
= 1.0
Result: output = 1.0 regardless of Cs value. This is mathematically exact.
Verification with #111111 (Cs = 0.00518 linear):
B = 0.00518 + 1.0 - (0.00518 * 1.0)
= 0.00518 + 1.0 - 0.00518
= 1.0 ✓
Verification with #888888 (Cs ≈ 0.216 linear):
B = 0.216 + 1.0 - (0.216 * 1.0) = 0.216 + 1.0 - 0.216 = 1.0 ✓
Verification with arbitrary #cc4400 (R≈0.60, G≈0.07, B≈0):
R_out = 0.60 + 1.0 - 0.60 = 1.0
G_out = 0.07 + 1.0 - 0.07 = 1.0
B_out = 0.00 + 1.0 - 0.00 = 1.0 — all channels = 1.0 → white
Near-white background variant (Cb = 0.98):
B = 1 - (1 - 0.00518)(1 - 0.98) = 1 - 0.9948 * 0.02 = 1 - 0.01990 = 0.9801
sRGB output channel ≈ ((0.9801)^(1/2.4) * 1.055 - 0.055) * 255 ≈ 251
Near-white (251,251,251) on near-white (250,250,250) bg → contrast ≈ 1.01:1 — still CRITICAL.
CSSOM evasion:
getComputedStyle(el).color → "rgb(17, 17, 17)" (unchanged; WCAG checker reports 19.6:1)
getComputedStyle(el).mixBlendMode → "screen" (detectable; should trigger audit flag)
Detection:
mixBlendMode === "screen" AND backdrop luminance > 0.85 → CRITICAL.
For any backdrop: simulate B(Cs, Cb) per channel; compute output luminance vs bg. */
Any source color becomes white: Unlike some blend attacks that depend on the text being dark, screen over white produces white from any source color. A consent element with color:#ff0000 (red) and mix-blend-mode:screen on white also renders as white. Auditors cannot limit detection to dark-colored text elements when checking screen blend mode.
mixBlendMode === "screen" on consent text with white or near-white backdrop → CRITICAL.SA-CSS-MBM-003: mix-blend-mode:color-dodge — division amplifies to maximum brightness
The color-dodge blend mode computes B(Cs,Cb) = Cb / (1−Cs), clamped to [0,1]. When the backdrop is white (Cb=1.0) and the source is any non-white color (Cs < 1.0), the denominator (1−Cs) > 0 and less than 1, so the division yields a value greater than Cb which clamps to 1.0. For near-white backgrounds, even a moderately dark source still pushes output very close to 1.0. This makes color-dodge as catastrophic as lighten and screen for consent text over white backgrounds.
.consent-text {
color: #111111;
mix-blend-mode: color-dodge; /* color-dodge: output = Cb / (1-Cs), clamped [0,1] */
opacity: 1; /* opacity property unchanged — evades opacity checks */
}
/* Color-dodge formula (W3C compositing and blending spec):
B(Cs, Cb) = min(1, Cb / (1 - Cs))
Special case: if Cs == 1.0 → B = 1.0 (division by zero → clamp)
For white background (Cb = 1.0):
Text #111111: Cs = 0.00518 linear
B = min(1, 1.0 / (1 - 0.00518))
= min(1, 1.0 / 0.99482)
= min(1, 1.00521)
= 1.0 → white output → contrast 1:1 → CRITICAL
For near-white background (Cb = 0.9, e.g. #F0F0F0-ish):
B = min(1, 0.9 / 0.99482) = min(1, 0.9047) = 0.9047
sRGB ≈ 0.957 → rgb(244,244,244) on rgb(230,230,230) → relative luminance ≈ 0.90 vs 0.82
Contrast ≈ (0.90+0.05)/(0.82+0.05) ≈ 1.09:1 — FAIL
Color-dodge on white background: guaranteed white for ALL source colors.
Proof: Cb=1.0, Cs<1.0 → denominator (1-Cs)>0 and <1 → 1.0/denominator > 1.0 → clamped to 1.0.
Sensitivity to source color:
Text #444444 (Cs ≈ 0.0508 linear): B = 1.0/(1-0.0508) = 1.054, clamped → 1.0
Text #808080 (Cs ≈ 0.216 linear): B = 1.0/(1-0.216) = 1.275, clamped → 1.0
Text #cccccc (Cs ≈ 0.600 linear): B = 1.0/(1-0.600) = 2.500, clamped → 1.0
All source colors → white when backdrop is white.
CSSOM evasion:
getComputedStyle(el).color → "rgb(17, 17, 17)" (unchanged; WCAG tools report 19.6:1)
getComputedStyle(el).mixBlendMode → "color-dodge" (detectable via computed style)
Detection:
mixBlendMode === "color-dodge" on consent text element → CRITICAL if backdrop >= rgb(200,200,200).
Simulate B(Cs, Cb) for any backdrop: if output luminance > 0.9 → CRITICAL. */
mixBlendMode === "color-dodge" on consent text with light backdrop → CRITICAL.SA-CSS-MBM-004: mix-blend-mode:soft-light on white container — brightening branch
The soft-light blend mode applies different formulas depending on whether the source value is above or below 0.5. For Cs > 0.5, the brightening branch applies: B = Cb + (2Cs−1)(D(Cb)−Cb) where D(Cb) is an auxiliary curve. When the consent container has mix-blend-mode:soft-light and its background composites as Cs=1.0 (white) against a white page backdrop, the (2×1.0−1)=1.0 factor applies maximum brightening to the composited result. Dark consent text within the container is then rendered on this brightened output. Unlike the previous three modes this does not guarantee exact white, making it HIGH rather than CRITICAL.
.consent-dialog {
background: white; /* container has white background */
mix-blend-mode: soft-light; /* soft-light applied to entire consent dialog */
}
.consent-text {
color: #111111; /* text color looks correct in CSSOM */
}
/* Soft-light blend mode formula (W3C compositing and blending spec):
If Cs <= 0.5: B = Cb - (1 - 2*Cs) * Cb * (1 - Cb) [darken branch]
If Cs > 0.5: B = Cb + (2*Cs - 1) * (D(Cb) - Cb) [brighten branch]
Where D(Cb) auxiliary function:
If Cb <= 0.25: D(Cb) = ((16*Cb - 12)*Cb + 4) * Cb
If Cb > 0.25: D(Cb) = sqrt(Cb)
Attack scenario: consent dialog has white background (bg=white → Cs blended in = 1.0).
Page background also white (Cb = 1.0).
Brightening branch (Cs=1.0 > 0.5):
B = Cb + (2*1.0 - 1) * (D(Cb) - Cb)
= Cb + 1.0 * (D(Cb) - Cb)
= D(Cb)
For Cb=1.0 (white page): D(1.0) = sqrt(1.0) = 1.0 → B = 1.0
For Cb=0.8 (light gray page): D(0.8) = sqrt(0.8) = 0.894 → B = 0.894
sRGB(0.894) ≈ 240 → near-white
Practical effect on dark consent text within the dialog:
The soft-light blend of the white container over white page brightens the dialog area.
Dark text pixels (Cb ≈ 0.004 linear for #111111) within the brightened container:
After container blend: the dialog layer appears near-white.
Text painted into this layer against white backdrop → reduced effective contrast.
Exact result depends on compositing order and stacking context isolation.
Why HIGH not CRITICAL: soft-light effect is highly context-dependent.
If consent dialog establishes an isolated stacking context (isolation:isolate or
transform/opacity != 1), blend composites against the isolated context, not the page.
Within the isolated context the text pixels may retain visible contrast.
Browser rendering differences exist in soft-light compositing of nested layers.
Detection:
mixBlendMode === "soft-light" on consent container AND container background >= rgb(200,200,200)
AND nearest non-isolated backdrop >= rgb(200,200,200) → HIGH.
Simulate composited output luminance; if effective consent text contrast < 3:1 → CRITICAL. */
Stacking context note: mix-blend-mode values other than normal establish a new stacking context on the element. If the consent dialog already establishes a stacking context (via position:fixed; z-index:X), the blend mode composites against the nearest stacking context background rather than the top-level page background. Auditors must trace the stacking context chain to identify the correct backdrop color for blend simulation.
Summary of SA-CSS-MBM findings
| ID | Severity | Pattern | Mechanism | WCAG impact |
|---|---|---|---|---|
| SA-CSS-MBM-001 | CRITICAL | mix-blend-mode:lighten | max(Cs,Cb): dark channel always less than white backdrop; output = 1.0 per channel | 1:1 (exact) |
| SA-CSS-MBM-002 | CRITICAL | mix-blend-mode:screen | 1−(1−Cs)(1−Cb): Cb=1 forces (1−Cb)=0; output always 1.0 regardless of Cs | 1:1 (exact) |
| SA-CSS-MBM-003 | CRITICAL | mix-blend-mode:color-dodge | Cb/(1−Cs): on white Cb=1.0, quotient ≥1.0 for all Cs; clamped to white | 1:1 on white; <1.2:1 on off-white |
| SA-CSS-MBM-004 | HIGH | mix-blend-mode:soft-light on container | Brightening branch (2Cs−1) near 1.0 for white container; near-white composited output | <3:1 typical; context-dependent |
Related pages
- CSS filter brightness/contrast/opacity consent attacks (SA-CSS-FBR)
- CSS color:transparent consent text attacks (SA-CSS-CFA)
- CSS text-shadow and -webkit-text-stroke consent attacks (SA-CSS-TXS)
- CSS animation-timing-function cubic-bezier extreme easing consent attacks (SA-CSS-ATF)
- All SkillAudit security research