Skip to content

CRW-10794: Fix CVE-2026-41240 by updating DOMPurify to patched version #705

Merged
RomanNikitenko merged 7 commits into
che-incubator:mainfrom
sbouchet:CVE-2026-41240
May 21, 2026
Merged

CRW-10794: Fix CVE-2026-41240 by updating DOMPurify to patched version #705
RomanNikitenko merged 7 commits into
che-incubator:mainfrom
sbouchet:CVE-2026-41240

Conversation

@sbouchet
Copy link
Copy Markdown
Collaborator

@sbouchet sbouchet commented May 12, 2026

What does this PR do?

This PR fixes CVE-2026-41240

dompurify version is updated to 3.4.2
dompurify sources files are also updated to use the upstream ones from that version.

What issues does this PR fix?

https://redhat.atlassian.net/browse/CRW-10794

How to test this PR?

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Summary by CodeRabbit

  • New Features

    • Sanitizer now accepts predicate-based rules for allowed attributes and tags.
    • Added configuration to extend forbidden-content filtering.
  • Chores

    • DOMPurify dependency updated to v3.4.2 across affected components and build manifests.
  • Security / Stability

    • Sanitization behavior hardened with tighter parsing, attribute/tag checks, and template handling.
  • Documentation

    • Top-level changelog updated with a new entry.

Review Change Stack

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 12, 2026

@sbouchet: This pull request references CRW-10794 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the vulnerability to target the "5.0.0" version, but no target version was set.

Details

In response to this:

What does this PR do?

This PR fixes CVE-2026-41240

dompurify version is updated to 3.4.2
dompurify sources files are also updated to use the upstream ones from that version.

What issues does this PR fix?

https://redhat.atlassian.net/browse/CRW-10794

How to test this PR?

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Click here to review and test in web IDE: Contribute

@sbouchet sbouchet marked this pull request as ready for review May 12, 2026 15:06
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 12, 2026

@sbouchet: This pull request references CRW-10794 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the vulnerability to target the "5.0.0" version, but no target version was set.

Details

In response to this:

What does this PR do?

This PR fixes CVE-2026-41240

dompurify version is updated to 3.4.2
dompurify sources files are also updated to use the upstream ones from that version.

What issues does this PR fix?

https://redhat.atlassian.net/browse/CRW-10794

How to test this PR?

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Summary by CodeRabbit

  • New Features

  • DOMPurify sanitization now supports predicate functions for fine-grained control over allowed attributes and tags.

  • Added configuration option to extend forbidden content filtering.

  • Chores

  • Updated DOMPurify library dependency to version 3.4.2 across extensions for improved security and performance.

Review Change Stack

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b5fadc99-c8fc-4867-9620-e629f3a915be

📥 Commits

Reviewing files that changed from the base of the PR and between 955638a and cb92e38.

📒 Files selected for processing (2)
  • .rebase/CHANGELOG.md
  • rebase.sh

📝 Walkthrough

Walkthrough

This PR upgrades DOMPurify from 3.2.7 to 3.4.2 across extension dependency declarations, vendored cgmanifest metadata, type definitions (.d.ts), and the core DOMPurify implementation. The update widens Config.ADD_ATTR/ADD_TAGS to accept predicate functions, adds ADD_FORBID_CONTENTS, introduces safer internal helpers (stringifyValue, guarded cloning, isRegex), tightens _parseConfig and attribute/tag decision paths (EXTRA_ELEMENT_HANDLING, FORBID_ATTR precedence), adds recursive shadow-DOM sanitization, inserts a changelog entry, and updates rebase conflict handlers to preserve local DOMPurify files.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant stringifyValue
  participant _parseConfig
  participant sanitizePipeline
  Caller->>stringifyValue: provide dirty input
  stringifyValue-->>_parseConfig: normalized string
  _parseConfig->>sanitizePipeline: normalized config + EXTRA_ELEMENT_HANDLING
  sanitizePipeline->>sanitizePipeline: element checks, attribute checks, shadow DOM recursion
  sanitizePipeline-->>Caller: sanitized output or thrown error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • rgrunber
  • azatsarynnyy
  • RomanNikitenko
  • vitaliy-guliy

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Rebase Rules For Upstream Changes ❌ Error PR modifies 5 files under code/ but lacks .rebase/ rule files for dompurify.d.ts and dompurify.js (only shell handlers exist, not rule files). Add .rebase/replace/code/src/vs/base/browser/dompurify/dompurify.d.ts.json and .rebase/replace/code/src/vs/base/browser/dompurify/dompurify.js.json with appropriate replacement rules.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title meets all requirements: under 72 characters (71), uses imperative mood ('Fix'), includes JIRA key (CRW-10794), and clearly describes the security fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rebase.sh`:
- Around line 375-395: The rebase helper currently auto-resolves DomPurify by
unconditionally running git checkout --ours and git add in
apply_code_vs_base_browser_dompurify_changes() (and the similar block for
dompurify.d.ts), which can silently drop upstream security fixes; replace the
unconditional checkout/add with logic that detects a merge conflict on
code/src/vs/base/browser/dompurify/dompurify.js and dompurify.d.ts and aborts
the script with a non-zero exit and a clear message instructing a manual review
(or run a version/sha compare against the upstream file and abort if upstream is
newer) instead of staging changes automatically so maintainers must inspect and
resolve DomPurify merges manually.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 09ee6db4-3491-4ba7-a3bb-4db80f3bb403

📥 Commits

Reviewing files that changed from the base of the PR and between 08a7c34 and 4192130.

⛔ Files ignored due to path filters (2)
  • code/extensions/markdown-language-features/package-lock.json is excluded by !**/package-lock.json
  • code/extensions/mermaid-chat-features/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • .rebase/CHANGELOG.md
  • .rebase/override/code/extensions/markdown-language-features/package.json
  • .rebase/override/code/extensions/mermaid-chat-features/package.json
  • .rebase/replace/code/src/vs/base/browser/dompurify/cgmanifest.json.json
  • code/extensions/markdown-language-features/package.json
  • code/extensions/mermaid-chat-features/package.json
  • code/src/vs/base/browser/dompurify/cgmanifest.json
  • code/src/vs/base/browser/dompurify/dompurify.d.ts
  • code/src/vs/base/browser/dompurify/dompurify.js
  • rebase.sh

Comment thread rebase.sh
Comment on lines +375 to +395
git checkout --ours code/src/vs/base/browser/dompurify/dompurify.d.ts > /dev/null 2>&1

# don't apply changes, keep ours version totally

# resolve the change
git add code/src/vs/base/browser/dompurify/dompurify.d.ts > /dev/null 2>&1
}

# Apply changes on code/src/vs/base/browser/dompurify/dompurify.js file
apply_code_vs_base_browser_dompurify_changes() {

echo " ⚙️ reworking code/src/vs/base/browser/dompurify/dompurify.js..."

# reset the file from what is upstream
git checkout --ours code/src/vs/base/browser/dompurify/dompurify.js > /dev/null 2>&1

# don't apply changes, keep ours version totally

# resolve the change
git add code/src/vs/base/browser/dompurify/dompurify.js > /dev/null 2>&1
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid auto-resolving DomPurify conflicts with unconditional --ours.

This path can silently suppress upstream DomPurify security fixes on future rebases. For security-sensitive vendored files, fail fast and require manual review (or compare versions and abort when upstream is newer) instead of auto-staging --ours.

Suggested safer approach
-    elif [[ "$conflictingFile" == "code/src/vs/base/browser/dompurify/dompurify.d.ts" ]]; then
-      apply_code_vs_base_browser_dompurify_d_changes
-    elif [[ "$conflictingFile" == "code/src/vs/base/browser/dompurify/dompurify.js" ]]; then
-      apply_code_vs_base_browser_dompurify_changes
+    elif [[ "$conflictingFile" == "code/src/vs/base/browser/dompurify/dompurify.d.ts" ]] || \
+         [[ "$conflictingFile" == "code/src/vs/base/browser/dompurify/dompurify.js" ]]; then
+      echo "DomPurify conflict detected in $conflictingFile. Manual security review required."
+      exit 1

Also applies to: 560-563

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rebase.sh` around lines 375 - 395, The rebase helper currently auto-resolves
DomPurify by unconditionally running git checkout --ours and git add in
apply_code_vs_base_browser_dompurify_changes() (and the similar block for
dompurify.d.ts), which can silently drop upstream security fixes; replace the
unconditional checkout/add with logic that detects a merge conflict on
code/src/vs/base/browser/dompurify/dompurify.js and dompurify.d.ts and aborts
the script with a non-zero exit and a clear message instructing a manual review
(or run a version/sha compare against the upstream file and abort if upstream is
newer) instead of staging changes automatically so maintainers must inspect and
resolve DomPurify merges manually.

@github-actions
Copy link
Copy Markdown

1 similar comment
@github-actions
Copy link
Copy Markdown

sbouchet and others added 3 commits May 13, 2026 10:37
Signed-off-by: Stephane Bouchet <sbouchet@redhat.com>
Protect the DOMPurify ^3.2.7 → ^3.4.2 bump across upstream rebases:
- Override rules for markdown-language-features and
mermaid-chat-features
  package.json to set dompurify dependency to ^3.4.2
- Replace rules for dompurify/cgmanifest.json to update commitHash, tag,
  and version fields
- Routing in rebase.sh for dompurify.d.ts and dompurify.js using
  git checkout --ours (vendored library full version bump)
- New routing for mermaid-chat-features/package.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stephane Bouchet <sbouchet@redhat.com>
Signed-off-by: Stephane Bouchet <sbouchet@redhat.com>
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 13, 2026

@sbouchet: This pull request references CRW-10794 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the vulnerability to target the "5.0.0" version, but no target version was set.

Details

In response to this:

What does this PR do?

This PR fixes CVE-2026-41240

dompurify version is updated to 3.4.2
dompurify sources files are also updated to use the upstream ones from that version.

What issues does this PR fix?

https://redhat.atlassian.net/browse/CRW-10794

How to test this PR?

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Summary by CodeRabbit

  • New Features

  • Sanitizer now accepts predicate functions to control allowed attributes and tags.

  • Added a configuration option to extend forbidden content filtering.

  • Chores

  • Updated DOMPurify dependency to v3.4.2 across relevant extensions.

  • Documentation

  • Top-level changelog updated with the new entry.

Review Change Stack

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@code/src/vs/base/browser/dompurify/dompurify.js`:
- Line 1: The vendored DOMPurify file was updated to 3.4.2 but the root
package-lock.json still pins DOMPurify at "3.2.7"; update the lockfile so the
two occurrences of version "3.2.7" become "3.4.2" (or simply regenerate the root
lockfile) to match the bundled build — e.g., run a fresh install (npm install /
npm ci) or regenerate the lockfile and commit the updated package-lock.json so
the root lockfile and the vendored DOMPurify (3.4.2) are consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8e2a072d-3d39-4e5c-84ce-5c4c731241ec

📥 Commits

Reviewing files that changed from the base of the PR and between 4192130 and d0b8160.

⛔ Files ignored due to path filters (2)
  • code/extensions/markdown-language-features/package-lock.json is excluded by !**/package-lock.json
  • code/extensions/mermaid-chat-features/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • .rebase/CHANGELOG.md
  • .rebase/override/code/extensions/markdown-language-features/package.json
  • .rebase/override/code/extensions/mermaid-chat-features/package.json
  • .rebase/replace/code/src/vs/base/browser/dompurify/cgmanifest.json.json
  • code/extensions/markdown-language-features/package.json
  • code/extensions/mermaid-chat-features/package.json
  • code/src/vs/base/browser/dompurify/cgmanifest.json
  • code/src/vs/base/browser/dompurify/dompurify.d.ts
  • code/src/vs/base/browser/dompurify/dompurify.js
  • rebase.sh
✅ Files skipped from review due to trivial changes (3)
  • code/extensions/mermaid-chat-features/package.json
  • .rebase/replace/code/src/vs/base/browser/dompurify/cgmanifest.json.json
  • code/src/vs/base/browser/dompurify/cgmanifest.json
🚧 Files skipped from review as they are similar to previous changes (5)
  • code/extensions/markdown-language-features/package.json
  • .rebase/override/code/extensions/mermaid-chat-features/package.json
  • .rebase/override/code/extensions/markdown-language-features/package.json
  • rebase.sh
  • code/src/vs/base/browser/dompurify/dompurify.d.ts

Comment thread code/src/vs/base/browser/dompurify/dompurify.js
@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 19, 2026

@sbouchet: This pull request references CRW-10794 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the vulnerability to target the "5.0.0" version, but no target version was set.

Details

In response to this:

What does this PR do?

This PR fixes CVE-2026-41240

dompurify version is updated to 3.4.2
dompurify sources files are also updated to use the upstream ones from that version.

What issues does this PR fix?

https://redhat.atlassian.net/browse/CRW-10794

How to test this PR?

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Summary by CodeRabbit

  • New Features

  • Sanitizer now supports predicate-based rules for allowed attributes and tags.

  • New configuration to extend forbidden content filtering.

  • Chores

  • DOMPurify updated to v3.4.2 across affected extensions.

  • Security / Stability

  • Sanitization behavior hardened for safer content handling.

  • Documentation

  • Top-level changelog updated with the new entry.

Review Change Stack

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@github-actions
Copy link
Copy Markdown

@sbouchet sbouchet self-assigned this May 20, 2026
@sbouchet sbouchet moved this to Ready for Review in Eclipse Che Team C Backlog May 20, 2026
@github-actions
Copy link
Copy Markdown

Comment thread .rebase/CHANGELOG.md Outdated
Comment thread .rebase/CHANGELOG.md Outdated
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 21, 2026

@sbouchet: This pull request references CRW-10794 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the vulnerability to target the "5.0.0" version, but no target version was set.

Details

In response to this:

What does this PR do?

This PR fixes CVE-2026-41240

dompurify version is updated to 3.4.2
dompurify sources files are also updated to use the upstream ones from that version.

What issues does this PR fix?

https://redhat.atlassian.net/browse/CRW-10794

How to test this PR?

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Summary by CodeRabbit

  • New Features

  • Sanitizer now accepts predicate-based rules for allowed attributes and tags.

  • Added configuration to extend forbidden-content filtering.

  • Chores

  • DOMPurify dependency updated to v3.4.2 across affected components and build manifests.

  • Security / Stability

  • Sanitization behavior hardened with tighter parsing, attribute/tag checks, and template handling.

  • Documentation

  • Top-level changelog updated with a new entry.

Review Change Stack

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@RomanNikitenko RomanNikitenko merged commit 71fa070 into che-incubator:main May 21, 2026
13 checks passed
@github-actions
Copy link
Copy Markdown

@sbouchet sbouchet deleted the CVE-2026-41240 branch May 21, 2026 12:06
@sbouchet sbouchet moved this from Ready for Review to ✅ Done in Eclipse Che Team C Backlog May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants