← Blog

MCP server CSS visibility:hidden consent security

Four SA-CSS-UVS consent attack patterns using visibility:hidden and related visibility properties to conceal consent text from users. Unlike display:none, visibility:hidden removes the element from visual rendering while preserving its layout box, making it harder to detect via layout-based audit checks. Combined with CSS animation timing, fill-mode, and transition delays, visibility attacks can render consent text invisible for many seconds while a user interacts with the surrounding UI — then make it visible only after meaningful interaction has already occurred.

By SkillAudit  |  29 Oct 2026

The CSS visibility property differs fundamentally from display and opacity in how it affects element rendering. display:none removes the element from the layout flow entirely; no space is reserved. opacity:0 makes the element transparent but keeps it in layout and fully interactive. visibility:hidden occupies its original layout box — the space is reserved, the element exists in the accessibility tree, and getComputedStyle(el).visibility returns “hidden” — but the element is not painted and pointer events are suppressed. A critical complication: visibility is a discrete property. It does not interpolate between values. When used in CSS animations or transitions, it switches instantaneously between hidden and visible at keyframe boundaries, creating precise timing windows for consent concealment.

SA-CSS-UVS-001: @keyframes visibility:hidden for 99% of animation duration

A @keyframes animation can set visibility:hidden at 0% and 99% of its duration, then switch to visibility:visible at 100%. Because visibility is discrete, the element is hidden for 99% of the animation and becomes visible only in the final frame. For an 8-second animation, that means the consent text is hidden for 7.92 seconds and legible for approximately 80 milliseconds. Setting animation-fill-mode:forwards keeps the visible state after the animation ends, ensuring the element stays visible and evades any post-interaction “eventually visible” check.

.consent-text {
  animation: reveal-text 8s forwards;
}
@keyframes reveal-text {
  0%   { visibility: hidden; }
  99%  { visibility: hidden; }
  100% { visibility: visible; }
}

/* How this attack works:
   CSS visibility is a discrete property — it cannot be interpolated.
   At any time between 0% and 99.9%, computed visibility = hidden.
   At exactly 100% (end of animation): computed visibility = visible.
   fill-mode:forwards preserves the 100%-keyframe state after animation ends.

   Timeline for 8-second animation:
   0s–7.92s: visibility:hidden — consent text invisible, layout box present
   7.92s–8s: still hidden (animation at 99% keyframe)
   8.0s:     visibility:visible — consent becomes legible (for 80ms if not read fast)
   8.0s+:    visibility:visible (fill-mode:forwards holds this state)

   User experience: the consent dialog appears to be a blank area or empty container
   for the entire duration before clicking. The user sees other UI elements and
   interacts based on the overall dialog, not the hidden consent text.

   getComputedStyle(el).visibility during 0s–7.92s: returns "hidden"
   → detectable IF auditor checks visibility at load time
   → NOT detectable if auditor checks visibility only after animation completes

   Layout box: preserved throughout (unlike display:none)
   Click area behavior: visibility:hidden suppresses pointer-events, so the text
   element itself is not clickable while hidden. But the layout space is reserved —
   sibling elements are not displaced.

   Detection:
   1. Check getComputedStyle(el).animationName for consent-text elements.
   2. Traverse @keyframes rule — look for visibility:hidden at any percentage < 100%.
   3. Compute: what fraction of animation duration has visibility:hidden?
   4. If > 50% of animation duration: CRITICAL SA-CSS-UVS-001.
   5. Check animation-fill-mode: forwards on consent elements with visibility:hidden keyframes. */

Fill-mode evasion: Without fill-mode:forwards, the visibility would revert to its pre-animation value (hidden) after the animation ends — the consent text would flash visible for one frame and immediately hide again. With fill-mode:forwards, the final keyframe (visibility:visible) persists. This makes the attack look benign: a post-interaction audit check finds the consent text visible, missing the fact that it was hidden for the entire critical window before the user clicked.

CRITICAL
SA-CSS-UVS-001 — @keyframes sets visibility:hidden from 0%–99% of animation; text hidden for 7.92s of 8s total; visible only in final 80ms frame. fill-mode:forwards preserves visible state post-animation, evading after-the-fact checks. Detection: parse @keyframes for visibility:hidden at percentage <100%; if >50% of duration hidden → CRITICAL.

SA-CSS-UVS-002: visibility:hidden during animation-delay window (fill-mode:backwards)

CSS animation-fill-mode:backwards applies the from keyframe values during the animation-delay period, before the animation starts. By setting the from keyframe to visibility:hidden and using a long delay (e.g., 12 seconds), the consent element is invisible for the entire pre-animation delay period. The animation itself runs quickly (100ms) and transitions to visibility:visible — but by then, users interacting with the dialog in the first 12 seconds have already made decisions without reading the consent text.

.consent-text {
  visibility: hidden;  /* initial state for fill-mode:backwards */
  animation-name: show-consent;
  animation-duration: 0.1s;
  animation-delay: 12s;
  animation-fill-mode: backwards;
}
@keyframes show-consent {
  from { visibility: hidden; }
  to   { visibility: visible; }
}

/* fill-mode:backwards mechanics:
   fill-mode:backwards applies the from-keyframe during the delay period.
   from-keyframe: visibility:hidden
   → during the 12-second delay, computed visibility = hidden
   → the 0.1s animation then runs and switches to visibility:visible

   Without fill-mode:backwards: the element would be visible (default) during delay,
   then animate. fill-mode:backwards forces the from-keyframe state during delay.

   The inline visibility:hidden on the element is overridden by fill-mode:backwards
   anyway — it is redundant but can mislead manual code reviewers who may think
   the element is statically hidden rather than delay-hidden.

   Timeline:
   0s–12s: visibility:hidden (fill-mode:backwards applies from-keyframe during delay)
   12s–12.1s: animation runs — visibility transitions hidden→visible
   12.1s+: visibility:visible (fill-mode:forwards would hold this; here animation ends)

   getComputedStyle(el).animationDelay = "12s" → detectable
   getComputedStyle(el).animationFillMode = "backwards" → detectable
   getComputedStyle(el).visibility during delay: "hidden" → detectable

   Combined detection:
   Check consent-text elements for animationDelay > 0 + animationFillMode = backwards.
   Check from-keyframe of animationName: if visibility:hidden → CRITICAL SA-CSS-UVS-002.
   Also check animationDelay alone: any delay > 3s on consent text → HIGH. */

Delay without fill-mode: Even without fill-mode:backwards, a long animation-delay with a static visibility:hidden on the element achieves the same effect. The element starts hidden (via the property value), the animation starts after 12s and overrides the property to show the text. Detection must check both: (1) animation-delay > 3s on consent elements, and (2) any mechanism keeping the element hidden during that delay window, including the element’s own visibility:hidden property value.

CRITICAL
SA-CSS-UVS-002 — fill-mode:backwards applies visibility:hidden from-keyframe during 12s animation-delay; consent invisible for entire pre-animation window; animation runs for only 100ms to reveal. Detection: animationDelay > 3s + fill-mode:backwards + visibility:hidden in from-keyframe → CRITICAL.

SA-CSS-UVS-003: visibility:collapse on consent dialog container

CSS defines a third value for the visibility property: collapse. Its behavior depends on the display type of the element. On table rows (display:table-row) and table columns, visibility:collapse removes the row from the layout as if it had display:none — collapsing the space it would have occupied. On all other elements (including flex and grid items), visibility:collapse behaves identically to visibility:hidden: the element is invisible but its layout space is preserved. This dual behavior can be exploited to construct consent dialogs that collapse entirely on table-structured UIs, or to create layout-preserving invisibility on flex/grid containers while evading detection tools that only check for the hidden keyword.

.consent-dialog-container {
  display: table;          /* table context: collapse removes layout */
  visibility: collapse;    /* on table rows: removes space (like display:none)
                              on other elements: like visibility:hidden */
}

/* Behavior matrix by display type:
   display:table-row     + visibility:collapse → row removed from layout
   display:table-column  + visibility:collapse → column removed from layout
   display:flex (child)  + visibility:collapse → same as visibility:hidden (space preserved)
   display:grid (child)  + visibility:collapse → same as visibility:hidden (space preserved)
   display:block         + visibility:collapse → same as visibility:hidden (space preserved)

   For table-row case (most impactful):
   The consent text row is completely removed from the visual table — no blank space.
   Other table rows close up around the gap.
   From a layout perspective: indistinguishable from display:none.
   getComputedStyle(el).visibility returns "collapse", not "hidden".

   An auditor checking for visibility === "hidden" would MISS this case.
   An auditor checking for visibility !== "visible" would catch it.

   Child escape rule: in standard visibility inheritance, a child with
   visibility:visible can escape a visibility:hidden ancestor — it becomes visible
   even though its parent is hidden. This escape does NOT work with collapse:
   visibility:collapse cannot be overridden by a child's visibility:visible.
   (Spec: collapse suppresses the entire subtree in table contexts.)

   Detection:
   Check getComputedStyle(el).visibility for values other than "visible".
   Include "collapse" in the set of hidden-equivalent values.
   For table elements: treat visibility:collapse as equivalent to display:none. */

Child visibility escape: A child element with visibility: visible can escape a visibility: hidden parent and become visible. This is standard CSS behavior and is sometimes used legitimately. However, this escape mechanism does not apply to visibility: collapse on table elements — collapse suppresses the entire row subtree regardless of child values. Detection of visibility attacks must therefore check both the element itself and all ancestors for non-visible visibility values, distinguishing hidden (child-escapable) from collapse (not escapable in table context).

HIGH
SA-CSS-UVS-003 — visibility:collapse on consent dialog container: on table rows, removes row from layout (space collapsed); on flex/grid, acts as visibility:hidden. Child visibility:visible cannot override collapse in table context. Detection: check visibility !== "visible" — include "collapse" — on consent ancestor elements → HIGH.

SA-CSS-UVS-004: CSS transition on visibility — discrete transition timing attack

CSS transitions on the visibility property behave differently from transitions on numeric properties like opacity. Because visibility is discrete (binary: either hidden or visible), it does not interpolate. However, the transition property still applies a delay to the visibility switch. The standard pattern for smooth hide/show with transitions exploits this: transition: opacity 0.3s, visibility 0s 0.3s hides the element visually first (opacity), then flips visibility after the opacity transition completes. An attacker can invert this to create a window where consent text disappears suddenly or appears only briefly.

.consent-text {
  visibility: hidden;
  transition: visibility 0s 5s;  /* 0s transition duration, 5s delay before hiding */
}
.consent-shown .consent-text {
  visibility: visible;
  transition: visibility 0s 0s;  /* shows immediately when .consent-shown added */
}

/* Reverse attack: show consent text briefly, then hide after transition delay
   Timeline:
   Initial state: visibility:hidden (element invisible)
   JS adds .consent-shown class:
     → visibility switches to visible immediately (0s transition, 0s delay)
     → consent text becomes readable
   JS removes .consent-shown class after 800ms:
     → transition:visibility 0s 5s applies: delay 5s before hiding
     → consent remains visible for 5 additional seconds (during transition delay)
     → then visibility:hidden fires (instantaneous, 0s duration)

   Attack variant: extremely short show window
   .consent-shown added for only 200ms, then removed.
   With transition:visibility 0s 0s on removal:
     → visibility flips back to hidden immediately after 200ms
     → user has 200ms window to read consent
     → after that: invisible for remainder of interaction

   Correct auditor behavior requires:
   1. Not just checking visibility at a single point in time
   2. Simulating or detecting transition delays on visibility
   3. Checking: does consent become visible before or after typical user interaction time?

   getComputedStyle(el).transitionProperty may include "visibility"
   getComputedStyle(el).transitionDelay for the visibility transition can be parsed
   to determine when visibility will change after a class toggle.

   Detection:
   Check transitionDelay on visibility property of consent elements > 0s → MEDIUM.
   Check for extremely short class-toggle windows via MutationObserver → HIGH.
   Check: if .consent-shown (or equivalent) class is toggled programmatically → CRITICAL. */
HIGH
SA-CSS-UVS-004 — CSS transition:visibility 0s Xs creates a timing window: visibility changes instantaneously but only after a delay. Reverse attack: show consent briefly (200ms), then hide immediately. Detection: transitionDelay > 0 on visibility of consent elements → HIGH; programmatic class toggle triggering visibility changes → CRITICAL via MutationObserver.

Summary of SA-CSS-UVS findings

IDSeverityPatternMechanismDetection signal
SA-CSS-UVS-001 CRITICAL @keyframes visibility:hidden 0%–99% Text hidden for 99% of animation duration; visible only in final frame visibility:hidden keyframes before 100% stop
SA-CSS-UVS-002 CRITICAL fill-mode:backwards + 12s delay from-keyframe visibility:hidden applied during entire delay window animationDelay > 3s + fill-mode:backwards
SA-CSS-UVS-003 HIGH visibility:collapse on container Table rows collapsed; flex/grid acts as hidden; child escape disabled visibility !== "visible" (includes "collapse")
SA-CSS-UVS-004 HIGH transition delay on visibility Brief show window; discrete flip after delay; programmatic class toggle transitionDelay on visibility > 0; MutationObserver on class

Related pages