Repository navigation
fix: scale nested namespace declarations linearly - #33
Merged
Merged
Conversation
Every element declaring an xmlns prefix cloned the whole namespace matrix, and every open element kept its parent matrix alive on a stack. A document nested to depth N with per-level declarations cost O(N²) time and O(N²) memory, exhausting the heap with an uncatchable V8 fatal error on a ~120KB payload. Replace clone-on-write with a single mutable matrix and a per-element undo log (restore on close), making both time and memory linear in nesting depth. The `el.ns` proxy getter now exposes a stable snapshot, copied on access and cached until the matrix changes, so captured references keep their former immutability semantics. Ref: GHSA-6w8c-5m3c-g2m8 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
pull Bot
pushed a commit
to Mu-L/camunda
that referenced
this pull request
Sep 26, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [bpmn-js](https://redirect.github.com/bpmn-io/bpmn-js) | [`18.29.1` → `18.30.1`](https://renovatebot.com/diffs/npm/bpmn-js/18.29.1/18.30.1) |  |  | | [bpmn-js](https://redirect.github.com/bpmn-io/bpmn-js) | [`18.28.0` → `18.30.1`](https://renovatebot.com/diffs/npm/bpmn-js/18.28.0/18.30.1) |  |  | | [bpmn-moddle](https://redirect.github.com/bpmn-io/bpmn-moddle) | [`10.2.0` → `10.3.1`](https://renovatebot.com/diffs/npm/bpmn-moddle/10.2.0/10.3.1) |  |  | --- ### Release Notes <details> <summary>bpmn-io/bpmn-js (bpmn-js)</summary> ### [`v18.30.1`](https://redirect.github.com/bpmn-io/bpmn-js/blob/HEAD/CHANGELOG.md#18301) [Compare Source](https://redirect.github.com/bpmn-io/bpmn-js/compare/v18.30.0...v18.30.1) - `FIX`: prevent overflowing of text when layouting it ([bpmn-io/diagram-js#1106](https://redirect.github.com/bpmn-io/diagram-js/pull/1106), [#&camunda#8203;1105](https://redirect.github.com/bpmn-io/diagram-js/pull/1105)) - `FIX`: prevent text layouting from looping in certain scenarios ([#&camunda#8203;1106](https://redirect.github.com/bpmn-io/diagram-js/pull/1106), [bpmn-io/diagram-js#1105](https://redirect.github.com/bpmn-io/diagram-js/pull/1105)) - `DEPS`: update to `diagram-js@15.27.1` ### [`v18.30.0`](https://redirect.github.com/bpmn-io/bpmn-js/blob/HEAD/CHANGELOG.md#18300) [Compare Source](https://redirect.github.com/bpmn-io/bpmn-js/compare/v18.29.1...v18.30.0) - `FEAT`: source colors and corner radii from `@bpmn-io/theme` tokens ([#&camunda#8203;2497](https://redirect.github.com/bpmn-io/bpmn-js/pull/2497)) - `DEPS`: update to `diagram-js@15.27.0` </details> <details> <summary>bpmn-io/bpmn-moddle (bpmn-moddle)</summary> ### [`v10.3.1`](https://redirect.github.com/bpmn-io/bpmn-moddle/blob/HEAD/CHANGELOG.md#1031) [Compare Source](https://redirect.github.com/bpmn-io/bpmn-moddle/compare/v10.3.0...v10.3.1) - `DEPS`: update to `moddle-xml@12.3.1` ### [`v10.3.0`](https://redirect.github.com/bpmn-io/bpmn-moddle/blob/HEAD/CHANGELOG.md#1030) [Compare Source](https://redirect.github.com/bpmn-io/bpmn-moddle/compare/v10.2.0...v10.3.0) - `FEAT`: parse documents with deeply nested namespace declarations linearily ([nikku/saxen#33](https://redirect.github.com/nikku/saxen/pull/33)) - `DEPS`: update to `moddle-xml@12.3.0` </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At 08:00 PM through 11:59 PM and 12:00 AM through 08:59 AM, Monday through Friday (`* 20-23,0-8 * * 1-5`) - Only on Sunday and Saturday (`* * * * 0,6`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- 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/camunda/camunda). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMDMuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjExMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhcmVhL2Zyb250ZW5kIiwiYXV0b21lcmdlIiwiZGVwZW5kZW5jaWVzIl19-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Fixes the quadratic blow-up behind GHSA-6w8c-5m3c-g2m8: with namespace processing enabled, every element declaring an
xmlnsprefix cloned the entire namespace matrix, and every open element kept its parent matrix alive on a stack. A document nested to depth N with per-level declarations cost O(N²) time and memory — a ~120KB payload exhausted the heap with an uncatchable V8 fatal error.Approach: replace clone-on-write with a single mutable matrix plus a per-element undo log (restored when the element closes), making time and memory linear in nesting depth. The
el.nsproxy getter now exposes a snapshot, copied on access and cached until the matrix changes, so captured references keep their former immutability semantics (moddle-xml capturesobj.ns).The per-matrix element name cache (stored under a matrix symbol) could not survive a shared mutable matrix — it is now rebuilt whenever the matrix changes, and a regression test covers repeated tag names across shadowed scope boundaries.
Verified: advisory PoC depth 3000 goes from fatal OOM to ~40ms/7MB; depth 50000 parses linearly. Event streams are byte-identical pre/post on prefix-shadowing and streaming scenarios; full suite (192 tests) and perf parity pass.
Related to GHSA-6w8c-5m3c-g2m8
Steps to try out:
npx @bpmn-io/sr nikku/saxen#fix-namespace-declaration-dos -c "npm ci && npm test"Checklist
Ensure you provide everything we need to review your contribution:
Closes {LINK_TO_ISSUE}orRelated to {LINK_TO_ISSUE}@bpmn-io/srtool