Reference

Security

Classes can come from content you do not control. JX treats them as untrusted input.

The risk

An arbitrary value is the only part of a class copied into the CSS. Without checks, c:[red;}body{display:none] would close its rule and open another one.

These classes produce no rule and trigger a warning:

c:[red;}body{display:none]
bg:[url(javascript:alert(1))]
c:[</style><script>alert(1)</script>]
c:[expression(alert(1))]

What is rejected

Risk Rejected in an arbitrary value
Escaping the declaration ; { } ! \ /* */
Escaping a style tag <
Loading code javascript: vbscript: expression() @import
Data URLs data: except images and fonts
Malformed value Unclosed parentheses or quotes

Note

The check runs twice: in the parser, then in the rules when the CSS is generated. A token built by hand does not bypass it.

Size limits

  • A class: 512 characters.
  • An arbitrary value: 512 characters.
  • Stacked variants: 8, without repetition.

Parsing and extraction run in linear time, whatever the input.

Runtime compilation

If you compile user-typed classes in the browser, the engine applies the same checks. JxParser.analyzeAll isolates the security-related rejections:

final report = const JxParser().analyzeAll(input);
if (report.securityFailures.isNotEmpty) {
  // Reject or flag the input.
}

Note

The content of jx.yaml (theme, breakpoints) is not validated: it is written by the project's developer and considered trusted.

Reporting a vulnerability

Do not open a public issue. The process is described in SECURITY.md, at the root of the repository.