Results of running the DOMPurify 3.4.16 test suite on a parse5-based window (follow-up to #1583)
Background & Context
In #1583 you said that if someone finds a server environment where your tests are green, you would like to know. I built one and would like to share the results and ask for your review of the claims, not for endorsement.
purify-edge runs the unmodified DOMPurify (pinned to 3.4.16, never patched) on a small DOM built on parse5 instead of jsdom. The DOM is about 800 lines in src/. I am the author. None of this is endorsed by you, and the README says so.
What I ran
- Your test suite at the 3.4.16 tag, unmodified, on the shim window: 984 tests and 1,247 assertions, identical to the jsdom run assertion by assertion.
sh scripts/official-suite.shreproduces it. - A differential fuzzer against DOMPurify on jsdom: more than 200,000 inputs on the default configs with 0 differences. Another 60,000 inputs on 12 extended configs (RETURN_DOM, IN_PLACE, SAFE_FOR_TEMPLATES, WHOLE_DOCUMENT, XHTML and others) gave 7 differences, all in two documented XHTML-mode classes, each checked to fail closed (purify-edge keeps less than jsdom, never more).
- 2,273 corpus cases (chat output, your own
expect.mjsvectors, large newsletters) with 0 differences.
What I think this does and does not show
- It shows parity with jsdom on those inputs. It does not show parity with a browser, and I do not claim the shim is safe in general. I agree with your README that the server-side DOM is part of the trusted computing base, and this one is the added attack surface of the package.
- Your suite has gaps I found by deliberately breaking the shim. Breaking custom-element
disconnectedCallbackhandling, or attribute case folding, does not turn your suite red on the shim (it does catch breaking the shadow root,textContent, template-content cloning andDOMParser). These may be worth knowing about whatever server DOM anyone uses. - It is verified against exactly one DOMPurify version. The pin only moves when the suite and fuzz runs pass again, and there is no automatic bump.
What I am offering
Any of these, or none:
- A CI job (in your repo, or just in mine, whichever you prefer) that runs your suite against the shim on each release, and a way for you to be told if it ever goes red.
- A pull request adding test cases for the two gaps above, following your contribution rules (signed commits, linter, full suite).
- If you ever want to mention a verified option in the README's server-side section, I would defer to your wording, and I would equally understand if you would rather not.
I would also value hearing which mXSS classes from your Attack Classes wiki depend on DOM implementation details, so I can add them to the differential tests.
Please close this if it is not useful. Security reports for the shim go through GitHub private vulnerability reporting on my repo.
Whoa, this is very cool, thanks for the contribution and the ping here 🙂
What I am offering
Yes, please, all three sound reasonable, please send a PR, happy to review.
Thanks! PR is up: #1660. Three independent commits (the two tests, the test:purify-edge runner, and the README note), so feel free to take only some of them.
All merged 🙂 Thanks again!