github voku/anti-xss 4.1.50

49 minutes ago

4.1.50

Security fixes

  • Event handler attributes (GHSA-…): every attribute named on + ASCII letters with a value is removed, not only the
    names on the internal list. Before, e.g. WebKit's ongesturestart / onwebkitmouseforcedown and every unknown or
    future event survived xss_clean() (264–281 of 514 known event names, all unknown names). The attributes are found
    with the HTML tokenizer rules, so text and values like title="onreading mode", data-onclick, on:click are kept.
  • Fail closed if PCRE fails (GHSA-… or hardening, see the advisory): if a regex fails (e.g. pcre.backtrack_limit),
    xss_clean() no longer returns the unchecked input; failed steps use non-regex fallbacks and the input is reported as
    XSS.

Behavior changes

  • Unknown on… attributes with a value are removed (e.g. <x onxxx=1>). Names that are no event handlers in any browser
    (on:click, on_load, on-click, onfoo1) and attributes without a value are kept.
  • Event names directly after a - are no longer removed from text and attribute names (data-onclick="…" stayed
    data-="…" before, aria-onfocus-hint became aria--hint).
  • If PCRE fails, the output is lossy on purpose (markup encoded, : / + / control chars removed).

Documentation

  • New README sections: supported output contexts (HTML body context only; not attribute values without escaping, URLs
    without scheme validation, JavaScript or CSS), the event handler rule and the PCRE behavior.

Tests / CI

  • Browser tests in Chromium, Firefox and WebKit (sanitized fixtures must not execute, raw controls must).
  • tests/fixtures/browser-event-handlers.txt (514 names from specs and engine sources, pinned, generated by
    build/event-handlers/extract.py), PCRE failure tests (separate processes, JIT on/off), differential corpus
    regenerated (18 of 2000 results changed, reviewed).

Verification (commit 985a8c1)

  • PHPUnit 368 tests, PHPStan level 8, Infection on the changed lines (gate 70%), CI PHP 7.1–8.5 incl. lowest
    dependencies, Chromium / Firefox / WebKit — see the PR checks.

Don't miss a new anti-xss release

NewReleases is sending notifications on new releases.