renovate[bot] 7c6a36728c chore: bump up dompurify version to v3.4.12 [SECURITY] (#15326)
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [dompurify](https://redirect.github.com/cure53/DOMPurify) | [`3.4.11`
→ `3.4.12`](https://renovatebot.com/diffs/npm/dompurify/3.4.11/3.4.12) |
![age](https://developer.mend.io/api/mc/badges/age/npm/dompurify/3.4.12?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/dompurify/3.4.11/3.4.12?slim=true)
|

---

### DOMPurify: `CUSTOM_ELEMENT_HANDLING` bypasses
`afterSanitizeElements` for allowed custom elements.

[GHSA-c2j3-45gr-mqc4](https://redirect.github.com/advisories/GHSA-c2j3-45gr-mqc4)

<details>
<summary>More information</summary>

#### Details
##### Summary

There is a possible hook-policy inconsistency in DOMPurify 3.4.11
involving `CUSTOM_ELEMENT_HANDLING`.

When a custom element is allowed via
`CUSTOM_ELEMENT_HANDLING.tagNameCheck`, it appears that the element does
not go through `afterSanitizeElements` in the same way as a normal
element. As a result, an application that relies on
`afterSanitizeElements` as a security policy layer to strip sensitive
attributes from all elements may see those attributes removed from
normal elements but preserved on allowed custom elements.

This does not appear to be a direct DOMPurify XSS or a case where
DOMPurify directly allows executable payloads. The preserved value is
still inert at sanitize time. The issue becomes relevant when the
allowed custom element later re-injects that attribute value into an
HTML sink such as `innerHTML`, creating a second-order XSS gadget.

##### Details

The issue appears to originate from the control flow in `src/purify.ts`:
line 1672~1691

```tsx
const _sanitizeDisallowedNode = function (
    currentNode: any,
    tagName: string
  ): boolean {
    /* Check if we have a custom element to handle */
    if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
      if (
        CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&
        regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)
      ) {
        return false;
      }

      if (
        CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&
        CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)
      ) {
        return false;
      }
    }
```

`CUSTOM_ELEMENT_HANDLING` is parsed from user configuration at
`src/purify.ts`: line 741~748

```tsx
const customElementHandling =
      objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') &&
      cfg.CUSTOM_ELEMENT_HANDLING &&
      typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object'
        ? clone(cfg.CUSTOM_ELEMENT_HANDLING)
        : create(null);

    CUSTOM_ELEMENT_HANDLING = create(null);
```

In particular, `tagNameCheck`, `attributeNameCheck`, and
`allowCustomizedBuiltInElements` are copied into the internal
`CUSTOM_ELEMENT_HANDLING` object there.

During element sanitization, `_sanitizeElements()` checks whether a node
is forbidden or not allowlisted at `src/purify.ts`: line 1805~1814

```tsx
/* Remove element if anything forbids its presence */
    if (
      FORBID_TAGS[tagName] ||
      (!(
        EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function &&
        EXTRA_ELEMENT_HANDLING.tagCheck(tagName)
      ) &&
        !ALLOWED_TAGS[tagName])
    ) {
      return _sanitizeDisallowedNode(currentNode, tagName);
    }
```

If so, it immediately delegates to `_sanitizeDisallowedNode(currentNode,
tagName)` and returns its boolean result.

Inside `_sanitizeDisallowedNode()`, the custom-element-specific allow
path is implemented at `src/purify.ts`: line 1672~1692

```tsx
const _sanitizeDisallowedNode = function (
    currentNode: any,
    tagName: string
  ): boolean {
    /* Check if we have a custom element to handle */
    if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
      if (
        CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&
        regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)
      ) {
        return false;
      }

      if (
        CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&
        CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)
      ) {
        return false;
      }
    }
```

If the node is treated as a basic custom element and
`CUSTOM_ELEMENT_HANDLING.tagNameCheck` matches, the function returns
`false` immediately at line 1682 or 1689, meaning “do not remove this
node”.

That early `return false` is significant because control returns
directly to `_sanitizeElements()` via the `return
_sanitizeDisallowedNode(...)` at line 1813. As a result, the later logic
in `_sanitizeElements()` is skipped for that custom element instance,
including:

- the namespace validation at `src/purify.ts`: line 1816~1826

```tsx
* Check whether element has a valid namespace.
       Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
       nodeType getter rather than `instanceof Element`, which is realm-
       bound and short-circuits to false for any node minted in a different
       realm — letting a foreign-realm element with a forbidden namespace
       slip past the namespace check entirely. */
    const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
    if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
      _forceRemove(currentNode);
      return true;
    }
```

- the fallback-tag mXSS check at `src/purify.ts`: line 1828~1837

```tsx
/* Make sure that older browsers don't get fallback-tag mXSS */
    if (
      (tagName === 'noscript' ||
        tagName === 'noembed' ||
        tagName === 'noframes') &&
      regExpTest(EXPRESSIONS.FALLBACK_TAG_CLOSE, currentNode.innerHTML)
    ) {
      _forceRemove(currentNode);
      return true;
    }
```

- most importantly for this report, the `afterSanitizeElements` hook
dispatch at `src/purify.ts`: line 1850~1851.

```tsx
   /* Execute a hook if present */
    _executeHooks(hooks.afterSanitizeElements, currentNode, null);
```

In other words, a normal allowlisted element continues through
`_sanitizeElements()` and reaches `hooks.afterSanitizeElements`, but a
disallowed-by-default element that is revived by the
`CUSTOM_ELEMENT_HANDLING.tagNameCheck` path does not. This creates a
policy inconsistency: an application that relies on
`afterSanitizeElements` to remove an attribute from all elements will
observe that the policy is applied to normal elements but not to custom
elements allowed through `CUSTOM_ELEMENT_HANDLING`.

In the PoC, the application hook removes `data-bio` from ordinary
elements, but the same attribute remains on `<x-bio>` because the
custom-element keep path bypasses `afterSanitizeElements`. The attribute
itself is inert at sanitize time and DOMPurify is not directly allowing
executable SVG/HTML through. The security impact appears when the
application-defined custom element later reads the preserved `data-bio`
value in `connectedCallback()` and writes it to `innerHTML`, turning the
preserved attribute into a second-order XSS gadget.

##### PoC

Reproduced on DOMPurify 3.4.11.

##### Steps

1. Save the following HTML to a file, for example `poc.html`.
2. Open it in a browser.
3. Observe that the `div` control loses `data-bio`, while the allowed
custom element keeps it.
4. Observe that after `connectedCallback()` runs, the candidate payload
is reinserted into the DOM and executes through the custom element’s own
sink.

##### HTML PoC

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.4.11/purify.min.js"></script>
</head>
<body>
<pre id="result"></pre>

<script>
window.__controlFired = false;
window.__candidateFired = false;

customElements.define("x-bio", class extends HTMLElement {
  connectedCallback() {
    const bio = this.getAttribute("data-bio");
    if (bio) this.innerHTML = bio;
  }
});

DOMPurify.addHook("afterSanitizeElements", node => {
  if (node.hasAttribute && node.hasAttribute("data-bio")) {
    node.removeAttribute("data-bio");
  }
});

const config = {
  CUSTOM_ELEMENT_HANDLING: {
    tagNameCheck: /^x-/
  }
};

const controlInput =
  '<div data-bio="&lt;img src=x onerror=window.__controlFired=true&gt;"></div>';

const candidateInput =
  '<x-bio data-bio="&lt;img src=x onerror=window.__candidateFired=true&gt;"></x-bio>';

const cleanControl = DOMPurify.sanitize(controlInput, config);
const cleanCandidate = DOMPurify.sanitize(candidateInput, config);

const container = document.createElement("div");
container.innerHTML = cleanCandidate;
document.body.appendChild(container);

setTimeout(() => {
  document.getElementById("result").textContent =
    "This is not direct DOMPurify XSS.\n" +
    "The payload becomes executable only after x-bio writes data-bio into innerHTML.\n\n" +
    "control: " + cleanControl + "\n" +
    "candidate: " + cleanCandidate + "\n" +
    "after connectedCallback: " + container.innerHTML + "\n" +
    "control fired: " + window.__controlFired + "\n" +
    "candidate fired: " + window.__candidateFired;
}, 100);
</script>
</body>
</html>
```

##### Expected result

```
control: <div></div>
candidate: <x-bio data-bio="<img src=x onerror=window.__candidateFired=true>"></x-bio>
after connectedCallback: <x-bio data-bio="..."><img src="x" onerror="window.__candidateFired=true"></x-bio>
control fired: false
candidate fired: true
```

This is output of HTML PoC.

<img width="1917" height="961" alt="poc"
src="https://github.com/user-attachments/assets/80e22989-5779-42f8-8ffb-106e9a4c2b10"
/>

##### Impact

This does not appear to affect DOMPurify’s default configuration as a
direct sanitizer bypass.

The impact is limited to applications that:

- enable `CUSTOM_ELEMENT_HANDLING`,
- rely on `afterSanitizeElements` as a security policy layer,
- expect that hook to apply uniformly to all surviving elements,
- and have allowed custom elements that later re-inject preserved
attribute values into `innerHTML` or another HTML sink.

In that situation, the behavior can become a second-order XSS gadget
because a security-relevant attribute is removed from normal elements
but remains on allowed custom elements.

Possible fixes or mitigations might include

- ensuring that allowed custom elements also consistently pass through
`afterSanitizeElements`
- documenting clearly that elements preserved via
`CUSTOM_ELEMENT_HANDLING` may not participate in the same post-element
hook flow as normal allowlisted elements.

#### Severity
- CVSS Score: 2.1 / 10 (Low)
- Vector String:
`CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N`

#### References
-
[https://github.com/cure53/DOMPurify/security/advisories/GHSA-c2j3-45gr-mqc4](https://redirect.github.com/cure53/DOMPurify/security/advisories/GHSA-c2j3-45gr-mqc4)
-
[https://github.com/cure53/DOMPurify/pull/1537](https://redirect.github.com/cure53/DOMPurify/pull/1537)
-
[https://github.com/cure53/DOMPurify/commit/a9ca1e537422319a557a9a2aa61f003b23b4a197](https://redirect.github.com/cure53/DOMPurify/commit/a9ca1e537422319a557a9a2aa61f003b23b4a197)
-
[https://github.com/cure53/DOMPurify/releases/tag/3.4.12](https://redirect.github.com/cure53/DOMPurify/releases/tag/3.4.12)
-
[https://github.com/advisories/GHSA-c2j3-45gr-mqc4](https://redirect.github.com/advisories/GHSA-c2j3-45gr-mqc4)

This data is provided by the [GitHub Advisory
Database](https://redirect.github.com/advisories/GHSA-c2j3-45gr-mqc4)
([CC-BY
4.0](https://redirect.github.com/github/advisory-database/blob/main/LICENSE.md)).
</details>

---

### Release Notes

<details>
<summary>cure53/DOMPurify (dompurify)</summary>

###
[`v3.4.12`](https://redirect.github.com/cure53/DOMPurify/releases/tag/3.4.12):
DOMPurify 3.4.12

[Compare
Source](https://redirect.github.com/cure53/DOMPurify/compare/3.4.11...3.4.12)

- Fixed an issue where a hook would not get called for custom elements,
thanks [@&#8203;Rikuxx0](https://redirect.github.com/Rikuxx0)
- Hardened the handling of hooks removing elements,
[@&#8203;mkrause-bee360](https://redirect.github.com/mkrause-bee360)
- Added support for a few new SVG attributes, thanks
[@&#8203;cbn-falias](https://redirect.github.com/cbn-falias) &
[@&#8203;Develop-KIM](https://redirect.github.com/Develop-KIM)
- Hardened the handling of declarative partial updates
- Updated the documentation is several spots, README, wiki, etc.
- Bumped several dependencies where possible

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/toeverything/AFFiNE).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNzUuMiIsInVwZGF0ZWRJblZlciI6IjQzLjI3NS4yIiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5IiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-23 11:35:23 +08:00
2026-04-09 12:41:38 +08:00
2026-06-24 23:55:19 +08:00
2026-07-04 03:41:23 +08:00
2026-02-06 19:49:02 +08:00
2023-07-10 06:19:59 +00:00
2026-06-01 23:54:41 +08:00
2023-04-13 20:30:18 +00:00
2026-03-20 05:23:03 +08:00
2023-05-03 00:47:43 -05:00
2025-12-29 19:08:49 +08:00
2023-09-15 07:50:00 +00:00
2026-02-23 21:03:13 +08:00
2026-06-01 20:13:59 +08:00
2026-07-15 13:25:57 +08:00

AFFiNE.Pro
Write, Draw and Plan All at Once

affine logo

A privacy-focused, local-first, open-source, and ready-to-use alternative for Notion & Miro.
One hyper-fused platform for wildly creative minds.



AFFiNE - One app for all - Where Notion meets Miro | Product Hunt


Releases All Contributors TypeScript-version-icon


Docs, canvas and tables are hyper-merged with AFFiNE - just like the word affine (əˈfʌɪn | a-fine).

Getting started & staying tuned with us.

Star us, and you will receive all release notifications from GitHub without any delay!

What is AFFiNE

AFFiNE is an open-source, all-in-one workspace and an operating system for all the building blocks that assemble your knowledge base and much more -- wiki, knowledge management, presentation and digital assets. It's a better alternative to Notion and Miro.

Features

A true canvas for blocks in any form. Docs and whiteboard are now fully merged.

  • Many editor apps claim to be a canvas for productivity, but AFFiNE is one of the very few which allows you to put any building block on an edgeless canvas -- rich text, sticky notes, any embedded web pages, multi-view databases, linked pages, shapes and even slides. We have it all.

Multimodal AI partner ready to kick in any work

  • Write up professional work report? Turn an outline into expressive and presentable slides? Summary an article into a well-structured mindmap? Sorting your job plan and backlog for tasks? Or... draw and code prototype apps and web pages directly all with one prompt? With you, AFFiNE AI pushes your creativity to the edge of your imagination, just like Canvas AI to generate mind map for brainstorming.

Local-first & Real-time collaborative

  • We love the idea of local-first that you always own your data on your disk, in spite of the cloud. Furthermore, AFFiNE supports real-time sync and collaborations on web and cross-platform clients.

Self-host & Shape your own AFFiNE

  • You have the freedom to manage, self-host, fork and build your own AFFiNE. Plugin community and third-party blocks are coming soon. More tractions on Blocksuite. Check there to learn how to self-host AFFiNE.

Acknowledgement

“We shape our tools and thereafter our tools shape us”. A lot of pioneers have inspired us along the way, e.g.:

  • Quip & Notion with their great concept of “everything is a block”
  • Trello with their Kanban
  • Airtable & Miro with their no-code programmable datasheets
  • Miro & Whimiscal with their edgeless visual whiteboard
  • Remote & Capacities with their object-based tag system

There is a large overlap of their atomic “building blocks” between these apps. They are not open source, nor do they have a plugin system like Vscode for contributors to customize. We want to have something that contains all the features we love and also goes one step even further.

Thanks for checking us out, we appreciate your interest and sincerely hope that AFFiNE resonates with you! 🎵 Checking https://affine.pro/ for more details ions.

Contributing

Bug Reports Feature Requests Questions/Discussions AFFiNE Community
Create a bug report Submit a feature request Check GitHub Discussion Visit the AFFiNE's Discord
Something isn't working as expected An idea for a new feature, or improvements Discuss and ask questions A place to ask, learn and engage with others

Calling all developers, testers, tech writers and more! Contributions of all types are more than welcome, you can read more in docs/types-of-contributions.md. If you are interested in contributing code, read our docs/CONTRIBUTING.md and feel free to check out our GitHub issues to get stuck in to show us what youre made of.

Before you start contributing, please make sure you have read and accepted our Contributor License Agreement. To indicate your agreement, simply edit this file and submit a pull request.

For bug reports, feature requests and other suggestions you can also create a new issue and choose the most appropriate template for your feedback.

For translation and language support you can visit our Discord.

If you have questions, you are welcome to contact us. One of the best places to get more info and learn more is in the Discord where you can engage with other like-minded individuals.

Templates

AFFiNE now provides pre-built templates from our team. Following are the Top 10 most popular templates among AFFiNE users,if you want to contribute, you can contribute your own template so other people can use it too.

Blog

Welcome to the AFFiNE blog section! Here, youll find the latest insights, tips, and guides on how to maximize your experience with AFFiNE and AFFiNE AI, the leading Canvas AI tool for flexible note-taking and creative organization.

Ecosystem

Name
@affine/component AFFiNE Component Resources
@toeverything/theme AFFiNE theme

Upstreams

We would also like to give thanks to open-source projects that make AFFiNE possible:

  • Blocksuite - 💠 BlockSuite is the open-source collaborative editor project behind AFFiNE.

  • y-octo - 🐙 y-octo is a native, high-performance, thread-safe YJS CRDT implementation, serving as the core engine enabling the AFFiNE Client/Server to achieve "local-first" functionality.

  • OctoBase - 🐙 OctoBase is the open-source database behind AFFiNE, local-first, yet collaborative. A light-weight, scalable, data engine written in Rust.

  • yjs - Fundamental support of CRDTs for our implementation on state management and data sync on web.

  • electron - Build cross-platform desktop apps with JavaScript, HTML, and CSS.

  • React - The library for web and native user interfaces.

  • napi-rs - A framework for building compiled Node.js add-ons in Rust via Node-API.

  • Jotai - Primitive and flexible state management for React.

  • async-call-rpc - A lightweight JSON RPC client & server.

  • Vite - Next generation frontend tooling.

  • Other upstream dependencies.

Thanks a lot to the community for providing such powerful and simple libraries, so that we can focus more on the implementation of the product logic, and we hope that in the future our projects will also provide a more easy-to-use knowledge base for everyone.

Contributors

We would like to express our gratitude to all the individuals who have already contributed to AFFiNE! If you have any AFFiNE-related project, documentation, tool or template, please feel free to contribute it by submitting a pull request to our curated list on GitHub: awesome-affine.

contributors

Self-Host

Begin with Docker to deploy your own feature-rich, unrestricted version of AFFiNE. Our team is diligently updating to the latest version. For more information on how to self-host AFFiNE, please refer to our documentation.

Run on Sealos

Run on ClawCloud

Feature Request

For feature requests, please see discussions.

Building

Codespaces

From the GitHub repo main page, click the green "Code" button and select "Create codespace on master". This will open a new Codespace with the (supposedly auto-forked AFFiNE repo cloned, built, and ready to go).

Local

See BUILDING.md for instructions on how to build AFFiNE from source code.

Contributing

We welcome contributions from everyone. See docs/contributing/tutorial.md for details.

License

Editions

  • AFFiNE Community Edition (CE) is the current available version, it's free for self-host under the MIT license.

  • AFFiNE Enterprise Edition (EE) is yet to be published, it will have more advanced features and enterprise-oriented offerings, including but not exclusive to rebranding and SSO, advanced admin and audit, etc., you may refer to https://affine.pro/pricing for more information

See LICENSE for details.

Languages
TypeScript 89.5%
Swift 4.2%
Rust 4.2%
Kotlin 1%
JavaScript 0.4%
Other 0.5%