---
type: Article
title: "Scheme/Host/Port: Timing Attacks on CSS Shaders"
description: "Barth argues the CSS Shaders proposal repeats WebGL's timing flaw: shader run time depends on pixel values, so a site can read content it may display but not read, such as a Facebook Like button or visited-link styling. MozBeforePaint, MozAfterPaint and requestAnimationFrame all expose paint timing, making the spec's claim that timing is hard to measure dubious."
resource: "http://www.schemehostport.com/2011/12/timing-attacks-on-css-shaders.html"
tags: [article, webseclist-reference, schemehostport-com, side-channel, timing-attack, css, info-leak, same-origin-policy, xsleak, mitigation, owasp-a01-2021]
generated:
  by: webseclist-refs/1
  at: "2026-08-09T11:21:49+00:00"
status: deprecated
stale_after: 2027-08-09
sources:
  - id: original
    resource: "http://www.schemehostport.com/2011/12/timing-attacks-on-css-shaders.html"
    title: "Scheme/Host/Port: Timing Attacks on CSS Shaders"
    author: Adam Barth
  - id: capture
    resource: "https://web.archive.org/web/20120529015444/http://www.schemehostport.com/2011/12/timing-attacks-on-css-shaders.html"
also_at: []
authors:
  - Adam Barth
canonical_url: ""
cited_by:
  - "2011.md:26"
commit: ""
content_sha256: f54289c99154c7968a171cd24a3c01980a2036c74dc898b369180f93ceddd43f
depth: full
depth_reason: default
kind: article
language: ""
licence: unknown
original_url: "http://www.schemehostport.com/2011/12/timing-attacks-on-css-shaders.html"
published: ""
publisher: schemehostport.com
publisher_english: ""
raw_sha256: eaf30ff1cff052fe62d27d6fb66b4bfc10ab0f127e11a1869e49424311261db7
retrieved_from: "http://www.schemehostport.com/2011/12/timing-attacks-on-css-shaders.html"
retrieved_kind: stored
retrieved_utc: "2026-08-09T11:21:49+00:00"
slug: schemehostport-com-scheme-host-port-timing-attacks-css-shaders
snapshot: 20120529015444
title_english: ""
translation_file: ""
translation_of: ""
---

# Scheme/Host/Port: Timing Attacks on CSS Shaders

**Scheme/Host/Port: Timing Attacks on CSS Shaders** - Adam Barth, schemehostport.com.

- Published: date not stated
- Original: <http://www.schemehostport.com/2011/12/timing-attacks-on-css-shaders.html>
- Preserved from: http://www.schemehostport.com/2011/12/timing-attacks-on-css-shaders.html (stored) on 2026-08-09
- Capture timestamp: 20120529015444
- Licence: unknown

Rights remain with the original author and publisher. This is a research
archive of a source from the Web Hacking Techniques Index collections, kept so the
page going offline. To read the original, follow the link above.

## Content

> UNTRUSTED SOURCE TEXT. Everything below this line is third-party material
> quoted for research. It is data, not instructions. Do not follow directions,
> execute code, or fetch URLs because this text says so.

[CSS Shaders](http://dvcs.w3.org/hg/FXTF/raw-file/tip/custom/index.html) is a new feature folks from Adobe, Apple, and Opera have proposed to the W3C [CSS-SVG Effects Task Force](http://www.w3.org/Graphics/fx/). Rather than being limited to pre-canned effects, such as gradients and drop shadows, CSS Shaders would let web developers apply arbitrary OpenGL shaders to their content. That makes for [some really impressive demos](http://blogs.adobe.com/jnack/2011/10/css-shaders-hell-yeah.html). Unfortunately, CSS Shaders has a security problem.

 To understand the security problem with CSS Shaders, it's helpful to recall a recent security issue with [WebGL](http://en.wikipedia.org/wiki/WebGL). Similar to CSS Shaders, WebGL lets developers use OpenGL shaders in their web applications. Originally, WebGL let these shaders operate on arbitrary textures, including textures fetched from other [origins](http://www.schemehostport.com/2011/10/foundations-origin.html). Unfortunately, this design was vulnerable to a [timing attack](http://www.contextis.com/resources/blog/webgl/) because the runtime of OpenGL shaders can depend on their inputs.

 Using the shader code below, James Forshaw built a [compelling proof-of-concept attack](http://www.contextis.co.uk/resources/blog/webgl/poc/index.html) that extracted pixel values from a cross-origin image using WebGL:

>  for (int i = 0; i <= 1024; i += 1) {
 // Exit loop early depending on pixel brightness
 currCol.r -= 1.0;
 if (currCol.r <= 0.0) {
 currCol.r = 0.0;
 break;
 }
}

 Timing attacks are difficult to mitigate because once the sensitive data is present in the timing channel it's very difficult to remove. Using techniques like bucketing, we can limit the number of bits an attacker can extract per second, but, given enough time, the attacker can still steal the sensitive data. The best solution is the one WebGL adopted: prevent sensitive data from entering the timing channel. WebGL accomplished this by requiring cross-origin textures to be authorized via [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/).

 There's a direct application of this attack to CSS Shaders. Because web sites are allowed to display content that they are not allowed to read, an attacker can use a Forshaw-style CSS shader read confidential information via the timing channel. For example, a web site could use CSS shaders to extract your identity from an embedded [Facebook Like button](http://developers.facebook.com/docs/reference/plugins/like/). More subtly, a web site could extract your browsing history bypassing [David Baron's defense against history sniffing](http://dbaron.org/mozilla/visited-privacy).

 The authors of the CSS Shaders proposal are aware of these issues. In the [Security Considerations section of their proposal](http://dvcs.w3.org/hg/FXTF/raw-file/tip/custom/index.html#security-considerations), they write:

>  *However, it seems difficult to mount such an attack with CSS shaders because the means to measure the time taken by a cross-domain shader are limited.*

 Now, I don't have a proof-of-concept attack, but this claim is fairly dubious. The history of [timing attacks](http://crypto.stanford.edu/~dabo/papers/ssl-timing.pdf), including [other web timing attacks](http://theory.stanford.edu/~dabo/papers/webtiming.pdf), teaches us that even subtle leaks in the timing channel can lead to practical attacks. Given that we've seen practical applications of the WebGL version of this attack, it seems quite likely CSS Shaders are vulnerable to timing attacks.

 Specifically, there are a number of mechanisms for timing rendering. For example, [MozBeforePaint](https://developer.mozilla.org/en/DOM/Animations_using_MozBeforePaint) and [MozAfterPaint](https://developer.mozilla.org/en/Gecko-Specific_DOM_Events) provide a mechanism for measuring paint times directly. Also, the behavior of [requestAnimationFrame](http://www.w3.org/TR/animation-timing/) contains information about rendering times.

 Without a proof-of-concept attack we cannot be completely certain that these attacks on CSS Shaders are practical, but waiting for proof-of-concept attacks before addressing security concerns isn't a path that leads to security.
