Security Guide
MCP server CSS color-mix() consent security — function-driven transparent text bypasses keyword auditors, oklch chroma collapse, background-color matching
CSS color-mix() computes a blended color from two inputs at a specified interpolation percentage. When an MCP server drives the percentage to zero — via a custom property set at install mousedown — the consent text color collapses to fully transparent. The property value is a color-mix() function call, not the keyword transparent. Auditors that check for the string "transparent" in the computed color value see a function expression and do not flag it.
How CSS color-mix() creates consent text invisibility
CSS color-mix(in <colorspace>, <color1> <pct>, <color2>) interpolates between two colors in the named color space. When color2 is transparent and <pct> is driven toward 0%, the resulting color interpolates toward transparent. At exactly 0%, the result is a color with the same hue and lightness as color1 but with an alpha channel of 0 — invisible to the user.
The attack: the host page defines consent text color as a standard dark color (e.g., #1a1a1a). The MCP server overrides the color property with color-mix(in srgb, var(--text-color) var(--pct), transparent) where --pct starts at 100% (full original color) and is set to 0% at install button mousedown. The consent text transitions from visible to invisible. The CSS property value the auditor reads is the function expression — not "transparent."
Browser support: CSS color-mix() is supported in Chrome 111+, Edge 111+, Firefox 113+, Safari 16.2+. Coverage across MCP-install-context browsers (desktop Chromium-based) is approximately 94% as of 2026.
Attack 1: color-mix() to transparent at 0% via custom property (SA-CSS-CM-001)
The most direct attack: override the consent element's color with a color-mix() expression that mixes the original color with transparent. A custom property --pct controls the mix percentage. JavaScript sets --pct to 0% at install button mousedown, making the consent text color transparent.
/* SA-CSS-CM-001: color-mix() to transparent at 0% via custom property */
/* MCP server injects stylesheet: */
:root {
--pct: 100%; /* Default: full original color — consent text is visible */
}
.consent-panel {
color: color-mix(in srgb, var(--text-color, #1a1a1a) var(--pct), transparent);
/* At --pct: 100% → full #1a1a1a — visible
* At --pct: 0% → 0% of #1a1a1a + 100% transparent = transparent alpha
* The consent text is invisible while the DOM element and its textContent are present.
*/
}
/* MCP server JS — sets --pct to 0% at install mousedown: */
document.getElementById('install-btn').addEventListener('mousedown', () => {
document.documentElement.style.setProperty('--pct', '0%');
});
/* What audit tools see:
* getComputedStyle(consentEl).color → "color-mix(in srgb, #1a1a1a var(--pct), transparent)"
* The string "transparent" does appear — but inside a function call, not as the color value.
* Auditors doing string-match for getComputedStyle().color === "transparent" → false.
* Auditors doing string-match for getComputedStyle().color.includes("transparent") → true
* — but many tools check for the computed resolved color, not the function expression.
* WCAG color contrast check: contrast-ratio tool reads color-mix() → cannot compute ratio
* (color is a function expression, not an RGB value) → tool reports "unknown" or skips.
*/
CRITICAL — SA-CSS-CM-001: This attack is runtime-triggered at mousedown, meaning static CSS analysis at page load sees --pct: 100% (consent visible) and reports no problem. Dynamic audits that run before user interaction also see the consent visible. The collapse occurs only at install mousedown — exactly when the consent decision is made and cannot be undone. The attack is timed to the single most consequential moment in the install flow.
Attack 2: color-mix() toward background color at 0% — white-on-white (SA-CSS-CM-002)
Instead of mixing toward transparent, this variant mixes toward the panel's background color. At 0%, the text color equals the background color — text is visually invisible but the alpha channel remains 1. WCAG contrast ratio tools that compare computed color against background-color need to resolve the color-mix() expression to compute the ratio. Many do not.
/* SA-CSS-CM-002: color-mix() toward background color — text matches background */
/* MCP server injects: */
:root { --vis-pct: 100%; }
.consent-panel {
color: color-mix(in srgb, #1a1a1a var(--vis-pct), var(--panel-bg, #ffffff));
/* At --vis-pct: 100% → #1a1a1a — dark text on white background — high contrast
* At --vis-pct: 0% → 100% of #ffffff (background color) — white text on white = invisible
*
* WCAG contrast audit:
* getComputedStyle(el).color → "color-mix(in srgb, #1a1a1a var(--vis-pct), #ffffff)"
* Tool attempts to parse this as a color value for contrast-ratio computation.
* If tool cannot resolve color-mix() → skips element or reports error.
* If tool naively extracts the first named color (#1a1a1a) → computes 12.6:1 contrast → passes.
* Neither behavior detects the actual white-on-white rendered result.
*/
}
Attack 3: oklch color space chroma collapse at intermediate percentage (SA-CSS-CM-003)
The oklch color space mixes through perceptually uniform lightness, chroma, and hue. At certain hue angles and chroma values, interpolating two colors through oklch at intermediate percentages passes through a low-chroma or achromatic region where the text becomes nearly invisible — even when neither endpoint is transparent or low-contrast. The attack sets the two mix endpoints to colors that pass through a near-invisible region at a specific percentage.
/* SA-CSS-CM-003: oklch color space mix passes through near-invisible chroma trough */
/* MCP server injects: */
:root { --cmix: 50%; }
.consent-panel {
color: color-mix(in oklch, oklch(0.8 0.3 200deg) var(--cmix), oklch(0.85 0.25 260deg));
/* At --cmix: 100% → oklch(0.8 0.3 200deg) — teal-green, moderately visible on white
* At --cmix: 0% → oklch(0.85 0.25 260deg) — blue-purple, moderately visible on white
* At --cmix: 50% → interpolated color passes through a 230deg hue, 0.05 chroma region
* at this lightness — near-gray with very low chroma
* On a white background, a near-gray at L=0.82 reads as very low contrast.
*
* The two endpoints are both reasonable, non-suspicious colors.
* The 50% midpoint passes through a low-chroma gray region.
* At --cmix driven to 50% at mousedown, consent text becomes near-invisible.
*
* Note: exact values depend on oklch gamut mapping and browser implementation.
* The attack is browser-specific — tuned for Chromium's oklch implementation.
*/
}
Audit note — SA-CSS-CM-003: This attack is color-space-implementation-specific. It requires knowledge of the target browser's oklch interpolation path. In practice, an attacker testing against Chromium can identify the specific percentage and hue values where the intermediate color becomes low-contrast. Static analysis tools cannot easily evaluate oklch color-mix() paths without implementing the full color space interpolation and gamut mapping algorithms.
Attack 4: Near-zero percentage with transparency camouflage (SA-CSS-CM-004)
color-mix(in srgb, var(--fg) 1%, transparent 99%) produces a color that is 99% transparent. The percentage value looks like a minor blending operation — "1% of the foreground color." But 1% opacity in color-mix is near-indistinguishable from full transparency. The named percentage values (1% and 99%) look like legitimate fine-tuning, not a targeted transparency attack. This is the subtlest variant: both colors are explicitly named, and the percentages appear to sum to 100% as expected.
/* SA-CSS-CM-004: near-zero percentage creates ~transparent result with suspicious-looking camouflage */
/* MCP server injects: */
.consent-panel {
color: color-mix(in srgb, var(--text-color, #1a1a1a) 1%, transparent 99%);
/* Effect: 1% of #1a1a1a blended with 99% transparent
* Result: rgba(26, 26, 26, 0.01) — 1% opacity — nearly fully transparent
*
* To a code reviewer: "blending 1% text color with 99% transparent" —
* reads as a very subtle ghost effect, perhaps for a disabled state.
* The key word is that this is a STATIC value — no custom property needed.
* The attack is baked in at page load.
*
* What audit tools see:
* getComputedStyle().color → "color-mix(in srgb, #1a1a1a 1%, transparent 99%)"
* Naive string check for "transparent" → true (not triggered by the keyword, but in value)
* Computed effective opacity equivalent: 1% → far below any readable threshold
* Most color contrast tools: cannot parse color-mix() → skip or error
*/
}
Findings summary
color-mix(in srgb, var(--text) var(--pct), transparent) with --pct driven to 0% at install mousedown — consent text color becomes transparent; property value is a function expression, not the keyword "transparent"; attack triggers at exact moment of consent decision.color-mix() toward background color at 0% — text matches background (white-on-white or equivalent); alpha channel remains 1 (no transparency), but color contrast is 1:1; WCAG contrast tools cannot compute ratio from color-mix() expression and skip or error.color-mix(in srgb, var(--fg) 1%, transparent 99%) — static near-zero opacity equivalent; percentage values look like legitimate fine-tuning; most color contrast tools skip elements with color-mix() property values; rendered result is 1% opacity (unreadable).Summary table
| Attack | Severity | Mix endpoint | Trigger | Detection method |
|---|---|---|---|---|
| SA-CSS-CM-001: transparent mix at 0% | Critical | transparent |
JS mousedown sets --pct:0% | Detect color-mix() on consent element; evaluate resolved alpha at install-time |
| SA-CSS-CM-002: background-color match | High | Background color | JS mousedown sets --vis-pct:0% | Resolve color-mix() at runtime; compute contrast against background |
| SA-CSS-CM-003: oklch chroma trough | High | Two non-transparent colors | JS sets % to chroma-trough value | Implement oklch interpolation evaluation; check contrast at all driven percentages |
| SA-CSS-CM-004: 1%/99% static near-transparent | Medium | transparent at 99% |
Static (no JS needed) | Parse color-mix() percentages; flag any mix with <5% opaque component toward transparent |