723 Commits
Author SHA1 Message Date
Cure53andGitHub 0a707ecd2a fix: addressed a possible DoS with IN_PLACE and KEEP_CONTENT, thanks @n2duc (#1555)
fix: fixed an OSV scanner false alert by updating the toml
2026-07-29 15:53:35 +02:00
Cure53andGitHub f57b386c9c release: 3.4.12 (#1536) 2026-07-11 13:45:45 +02:00
Cure53andGitHub 044b58b401 fix: addressed an issue with hook-handling for CE sanitization (#1527)
* fix: addressed an issue with hook-handling for CE sanitization, thanks @Rikuxx0

* chore: rebuild dist to sync purify.min.js + sourcemaps after main merge
2026-07-11 13:23:47 +02:00
83bcf3eac7 Allow SVG dominant-baseline and text-orientation presentation attributes (#1526)
Both are pure presentation attributes from the W3C SVG2 text property
adaptions but were missing from the SVG attribute allow-list, so
DOMPurify stripped e.g. <text dominant-baseline="middle">. Their
baseline siblings alignment-baseline and baseline-shift are already
allow-listed; both added attributes are enum-only with no script/URL
surface.

Fixes #1525

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-11 12:45:59 +02:00
Cure53andGitHub 866f9bac28 Cure53 inplace hardening 2 (#1524)
* * feat: block declarative-partial-updates patch directives
* feat: harden style mXSS check against foreign-content teleport
* fefend against declarative partial updates (Chrome 150)
* test: add tests for partial-update patch directives

* feat: loosened the style check a bit again
test: added correct test coverage for template scrubbing

* fix: slightly changed behavior of node removal to avoid breakage, see #1521

* chore: regenerated dist files to be in sync again

* fix: made sure that _neutralizeRoot calls _neutralizeSubtree first

* test: added tests for the formerly addressed IN_PLACE behavior

* chore: fixed the out-of-sync dist files

* chore: hardened against several smaller declarative patching crashes

* test: extended tests to cover more declarative patching cases
2026-07-09 21:03:01 +02:00
Cure53andGitHub c79bfe3272 Cure53 fix hook detach (#1523)
* * feat: block declarative-partial-updates patch directives
* feat: harden style mXSS check against foreign-content teleport
* fefend against declarative partial updates (Chrome 150)
* test: add tests for partial-update patch directives

* feat: loosened the style check a bit again
test: added correct test coverage for template scrubbing

* fix: slightly changed behavior of node removal to avoid breakage, see #1521

* chore: regenerated dist files to be in sync again
2026-07-07 11:26:27 +02:00
Cure53andGitHub 03b4a15964 Cure53 proactive hardening against declarative partial updates (#1516)
* * feat: block declarative-partial-updates patch directives
* feat: harden style mXSS check against foreign-content teleport
* fefend against declarative partial updates (Chrome 150)
* test: add tests for partial-update patch directives

* feat: loosened the style check a bit again
test: added correct test coverage for template scrubbing
2026-07-07 10:18:08 +02:00
Cure53andGitHub 8a565c0454 release: 3.4.11 (#1493)
* release: 3.4.11
* updated README
2026-06-17 11:23:04 +02:00
Cure53andGitHub 5c76e10187 chore: modified the packages.json again to get rid of vulnerable deps (#1491) 2026-06-16 17:16:24 +02:00
Cure53andGitHub ae9f24044c fix: hook allowlist clone-guard now covers the setConfig() path (#1482)
* fix: hook allowlist clone-guard now covers the setConfig() path

* test: added test coverage for recent config leak fixes

* fix: hardened the entry points for hooks

* docs: updated threat model docs to be more accurate regarding exotic configs
2026-06-13 17:14:36 +02:00
Cure53andGitHub 206da3d65b release: 3.4.10 (#1477) 2026-06-12 13:49:52 +02:00
Cure53andGitHub adecaa0e37 chore: refactoring run pt4, demo touchup, docs, comments, small things (#1476) 2026-06-12 12:41:53 +02:00
Cure53andGitHub 9ef570a0d4 chore: refactoring run pt3, performance, de-dos, micro optimizations (#1475) 2026-06-12 12:11:53 +02:00
Cure53andGitHub b187055a13 chore: refactoring run pt2, methods, structure, more dedup (#1474) 2026-06-12 11:07:51 +02:00
Cure53andGitHub 4112e9d87c chore: refactoring run pt1, types, typos and dedup (#1473)
refactor: extract public type declarations into src/types.ts

Moves the type-level code (DOMPurify interface, hook types,
RemovedElement/RemovedAttribute, WindowLike, HooksMap) from the bottom
of purify.ts into src/types.ts. purify.ts imports what it references
and re-exports the public surface unchanged.

No emitted-JS change: all four runtime bundles rebuild byte-identical.
Bundled d.ts is semantically identical (only 'declare const _default'
moves after the type block). verify-typescript passes for all consumer
flavors.

refactor: single source of truth for integration point defaults

The default MATHML_TEXT_INTEGRATION_POINTS and HTML_INTEGRATION_POINTS
arrays were written twice - at declaration and inline in _parseConfig.
Extract frozen DEFAULT_* constants (elements already lowercase, so
addToSet's isFrozen guard is a no-op) referenced from both sites. A
fresh set object is still allocated per parse, exactly as before.

refactor: remove dead branches, fix internal naming, align hardened style

- _isValidAttribute: drop the FORBID_ATTR[lcName] re-checks; both sit
  after the unconditional early return and FORBID_ATTR cannot change
  between the two points, so they were constants.
- Remove unreachable direct-property fallbacks on getChildNodes /
  getAttributes / getShadowRoot: lookupGetter always returns a
  callable, and the dead fallback was the clobberable read. The
  nullable getNodeType/getNodeName ternaries stay.
- NODE_TYPE.progressingInstruction -> processingInstruction (internal).
- seal() the per-config CUSTOM_ELEMENT_HANDLING, matching the sealed
  initial declaration; drop bare Array.from in
  _scrubTemplateExpressions (static NodeList via unapplied forEach is
  an identical snapshot).
2026-06-11 23:58:45 +02:00
Cure53andGitHub 4b6ab47f27 release: 3.4.9 (#1458) 2026-06-10 10:27:20 +02:00
Cure53andGitHub 52cb1f7c62 fix: added further robustness for exotic IN_PLACE usage (#1453)
* fix: added further robustness for exotic IN_PLACE usage
test: expanded test suite accordingly

* chore: refactored the code a bit after recent IN_PLACE changes

* fix: added enhanced robustness after recent IN_PLACE audit
test: expanded the array of IN_PLACE tests accordingly
2026-06-06 18:08:49 +02:00
Cure53andGitHub 54c6c1bf2a fix: better handing of TT policy wipes & nodeName detection (#1443)
* fix: attempting to fix an issue with nodeName checks on happy-dom

* test: added happy-dom tests but just so we have them, too broken still

* fix: implemented better handling of Trusted Type policy wipes via config

* fix: further hardened the TT-related attack surface and added tests

* fix: hardened IN_PLACE a bit further against exotic elements
test: added test-coverage for IN_PLACE and DOM clobbering
2026-06-06 11:37:42 +02:00
Cure53andGitHub 609cdc3a9f release: 3.4.8 (#1438) 2026-06-03 12:55:42 +02:00
Cure53andGitHub 71b8d3c69f fix: addressed the types issues again (#1424)
doc:  updated README
test: expanded the test suite
2026-05-29 17:44:49 +02:00
Cure53andGitHub 167c91118d see #1422 (#1423)
* see #1422

fix: made sure the type defintions are up to date for TT:null

* fix: refined an element nodeName check for better robustness
2026-05-29 15:09:12 +02:00
Cure53andGitHub 3f2746566b Cure53 template scrub (#1421)
* fix: made the node iterator for template scrubbing more robust

* test: expanded the test suite to cover the recent template scrub changes
2026-05-29 08:48:29 +02:00
Cure53andGitHub 751bd269e5 Cure53 cleanup root (#1418)
* chore: decluttered the repo root for better tidiness

* chore: also moved playwright config for cleanup purposes

* chore: dropped some stale files, removed references
2026-05-28 10:16:20 +02:00
Cure53andGitHub 90280b7772 release: 3.4.7 (#1413)
* release: 3.4.7

* release: 3.4.7
2026-05-27 13:20:24 +02:00
Cure53andGitHub 45b9090ad1 fix: made the handling on shadow roots and IN_PLACE more robust (#1409)
* fix: made the handling on shadow roots and IN_PLACE more robust

* chore: removed some of the more spammy inline comments

* test: expanded the test coverage for IN_PLACE and Shadow DOM
2026-05-27 12:07:59 +02:00
Cure53andGitHub 119efb84d8 Spread ALLOWED_TAGS and ALLOWED_ATTR in hooks (#1396)
* Spread ALLOWED_TAGS and ALLOWED_ATTR in hooks

* Implement tests for allowlist pollution mitigation

Add tests to verify hook-driven allowlist pollution fix in DOMPurify.

* fix: made sure the hooks behavior doesn't mess up the tests
2026-05-26 16:58:10 +02:00
Cure53andGitHub 3cfa748aca release: 3.4.6 (#1393) 2026-05-26 12:25:51 +02:00
Cure53andGitHub d9b84f4990 fix: added better protection against IN_PLACE clobbering (#1392)
* fix: added better protection against IN_PLACE clobbering
test: expanded the test coverage even further

* test: fixed some inaccurate tests and expanded test surface
2026-05-26 12:00:11 +02:00
Cure53andGitHub 6ee53bdb97 fix: added more checks for clobbering when IN_PLACE is used (#1391)
tests: expanded test suite with more cases
2026-05-24 21:48:43 +02:00
Cure53andGitHub c66033618f fix: fixed a possible DOM clobbering with IN_PLACE and shadow DOM (#1390)
test: extended the tests for above case
2026-05-24 15:54:56 +02:00
Cure53andGitHub ea2954869e release: 3.4.5 (#1381) 2026-05-18 09:29:26 +02:00
Cure53andGitHub 7f069c16af release: 3.4.4 (#1373) 2026-05-17 12:10:11 +02:00
93bd456d00 fix: attempting to add a stronger check for cross-realm windows (#1370)
* fix: attempting to add a stronger check for cross-realm windows
* fix: removed a crash caused by the newly added cross-realm checks

---------

Co-authored-by: Mario Heiderich <[email protected]>
2026-05-16 18:15:44 +02:00
Cure53andGitHub aaa88877dd Update purify.ts (#1365)
* Update purify.ts
* Update test-suite.js
* test: updated the dist versions, missed in last commit
2026-05-15 16:35:04 +02:00
Cure53andGitHub 74812f14e4 fix: added better template scrubbing for IN_PLACE, thanks @demon1a (#1364)
fix: restructured template scrubbing to be more modular
test: added test cases for the above
2026-05-15 15:54:50 +02:00
Luke WarlowandGitHub 6179b85996 Add command and commandfor attribute into allowed list (#1354)
* Add command and commandfor attribute into allowed list
* Also add test case for command/commandfor and popovertarget/popovertargetaction
* Add selectedcontent element to allow list of tags
2026-05-13 19:19:10 +02:00
Cure53andGitHub 50c35382ed release: 3.4.3 (#1350) 2026-05-13 12:45:38 +02:00
Cure53andGitHub 1ec559a0b8 Cure53 shadowdom fix (#1336)
* fix: added better handling of nested Shadow DOM trees, thanks @fishjojo1

* fix: refined the node iteration code to catch more cases
2026-05-08 17:20:57 +02:00
Cure53GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
6f7f4a1e1d Cure53 template regex fix (#1330)
* build(deps-dev): bump @babel/preset-env from 7.29.2 to 7.29.3

Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.29.2 to 7.29.3.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.29.3/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-version: 7.29.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* build: rebuild dist/ for @babel/preset-env 7.29.3

* fix: made the template regexes more robust against ReDoS

* fixed missing newline

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-02 11:27:10 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Mario Heiderich
6a02ea5ed4 build(deps-dev): bump @babel/preset-env from 7.29.2 to 7.29.3 (#1325)
* build(deps-dev): bump @babel/preset-env from 7.29.2 to 7.29.3

Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.29.2 to 7.29.3.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.29.3/packages/babel-preset-env)

---
updated-dependencies:
- dependency-name: "@babel/preset-env"
  dependency-version: 7.29.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* build: rebuild dist/ for @babel/preset-env 7.29.3

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mario Heiderich <[email protected]>
2026-05-01 11:17:55 +02:00
Cure53andGitHub 905574ff64 release: 3.4.2 (#1321) 2026-04-30 13:18:51 +02:00
Drew NeilandGitHub 1d0b822626 fix: apply URI validation to attributes allowed via ADD_ATTR callback (#1320)
* fix: apply URI validation to attributes allowed via ADD_ATTR callback

The function form of ADD_ATTR (introduced in PR #1150) allowed attribute
names to bypass URI scheme validation. When the attributeCheck callback
returned true, the attribute value was accepted without checking it
against IS_ALLOWED_URI, meaning javascript: and data: URIs could pass
through unsanitized.

The array form of ADD_ATTR and the default ALLOWED_ATTR set both flow
through URI validation correctly; the function form now does too.

The fix removes the attributeCheck branch as a separate early-exit and
folds it into the name-permitted test that precedes value validation:

  const nameIsPermitted =
    ALLOWED_ATTR[lcName] ||
    (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function &&
      EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag));

  } else if (!nameIsPermitted || FORBID_ATTR[lcName]) {

Tests added: javascript: URI is stripped when href is allowed via
ADD_ATTR callback; safe https: URI is preserved.

* test: use assert.equal to avoid CodeQL substring URL warning
2026-04-30 09:29:09 +02:00
Cure53andGitHub e11a079d68 Cure53 fuzzer update (#1298)
* test: added more fuzzer properties and a negative check
* chore: getting ready for 3.4.1 release
2026-04-21 16:10:15 +02:00
Cure53andGitHub e3ae8a093a Cure53 code hardening (#1296)
* chore: added stronger check for HTML Custom Element tagnames
cxhore: added stronger check for IN_PLACE tagname types

* test: add regression and pinning tests from April 2026 review
2026-04-21 11:37:59 +02:00
Mario Heiderich af0e4a1457 build: migrate rollup-plugin-typescript2 and pre-commit
Switch rollup-plugin-typescript2 → @rollup/plugin-typescript (official,
actively maintained by the Rollup team). Type declaration pipeline is
unaffected — types are generated by tsc directly, not the rollup plugin.

Switch pre-commit → husky (modern standard, zero runtime deps, actively
maintained). Hook behavior is identical: lint + build + stage dist files.
The prepare script ensures hooks install automatically on npm install.
2026-04-17 11:33:54 +03:00
Mario Heiderich dda7c46e84 chore(deps): bump rimraf, prettier, eslint-plugin-prettier, minimist 2026-04-16 11:54:57 +02:00
Cure53andGitHub 9b3886edb3 Merge branch 'main' into cure53-basic-fuzzer 2026-04-15 22:33:52 +03:00
Mario Heiderich 4f730dbeeb fix: added better config hardening and removed crash potentials
test: expanded test suite to cover above changes
2026-04-15 21:28:42 +02:00
Mario Heiderich 93e7eaf908 fix: made the NAMESAPCE config handling less crashy 2026-04-15 20:22:44 +02:00
Cure53andGitHub 7276704d83 Cure53 basic fuzzer (#1266)
* test: added first scaffold for a simple data type and config fuzzer

* test: Extended the fuzzer a bit to cover the config object

* test: expanded fuzzer test coverage for bad config values
fix: fixed several crashes caused by bad config values and data types
fix: added necessary utility messages to utils.js
2026-04-15 13:32:31 +02:00