Skip to content

[css-variables] Consider specifying allowed size limit of var() expansion #5510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
twilco opened this issue Sep 13, 2020 · 4 comments
Closed
Labels
Closed Rejected as Wontfix by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-variables-1 Current Work Testing Unnecessary Memory aid - issue doesn't require tests

Comments

@twilco
Copy link
Contributor

twilco commented Sep 13, 2020

Quoting https://drafts.csswg.org/css-variables/#long-variables:

To avoid this sort of attack, UAs must impose a UA-defined limit on the allowed length of the token stream that a var() function expands into. If a var() would expand into a longer token stream than this limit, it instead makes the property it’s expanding into invalid at computed-value time.

This specification does not define what size limit should be imposed. However, since there are valid use-cases for custom properties that contain a kilobyte or more of text, it’s recommended that the limit be set relatively high.

Should this limit be explicitly set in the spec to avoid compatibility issues?

Gecko currently requires expansions to be 1mb or less, while Chromium and WebKit both set a limit of 65536 tokens.

@Loirooriol
Copy link
Contributor

A limit that would be reasonable today will probably become absurdly low in 30 years.
And then, if we set a limit now, we will either be stuck with it, or break sites that relied on that limit when we raise it.
So it's better to not specify the limit, this makes it less likely that sites will rely on some specific value.
See similar discussion in #3462

@tabatkins tabatkins added the css-variables-1 Current Work label Sep 14, 2020
@tabatkins
Copy link
Member

Yeah, unless there's a strong demand from implementors, I'm inclined to leave it undefined. Both of those limits you cite sound reasonable to me (and are within an order of magnitude of each other; 2^16 tokens probably translates to ~250KB on average, around 1/4 the Firefox limitation).


(#3462 is a bit different; it's a pretty small limitation, even if it is much larger than most code will ever run into, so having an agreed-upon min is relatively more important.)

@tabatkins
Copy link
Member

Closing this as WONTFIX, please let me know if that resolution is satisfactory or if you'd like the WG to discuss it more.

@twilco
Copy link
Contributor Author

twilco commented Sep 14, 2020

That works for me. Thanks to you both.

@tabatkins tabatkins added Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. and removed Commenter Response Pending labels Sep 14, 2020
@tabatkins tabatkins added the Testing Unnecessary Memory aid - issue doesn't require tests label Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Rejected as Wontfix by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-variables-1 Current Work Testing Unnecessary Memory aid - issue doesn't require tests
Projects
None yet
Development

No branches or pull requests

3 participants