Skip to content

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

Open
sbouchet wants to merge 4 commits into
che-incubator:mainfrom
sbouchet:CVE-2026-41240
Open

CRW-10794: Fix CVE-2026-41240 by updating DOMPurify to patched version #705
sbouchet wants to merge 4 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 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

@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

📝 Walkthrough

Walkthrough

This PR upgrades DOMPurify from version 3.2.7 to 3.4.2 across all Che Code extension dependencies, type definitions, and vendored implementation. The upgrade introduces expanded configuration options allowing predicate functions for dynamic tag/attribute validation (ADD_TAGS, ADD_ATTR), a new ADD_FORBID_CONTENTS option, and substantial internal security enhancements including recursive shadow DOM sanitization, stricter attribute validation with clobbering protection, reserved custom element names, and improved input type handling. Build metadata and rebase conflict handlers are updated to align with the new version.

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
  • vitaliy-guliy
  • RomanNikitenko

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 The PR modifies upstream code/src/vs/base/browser/dompurify/dompurify.d.ts and dompurify.js but lacks corresponding .rebase/ rule files required by the check. Only dedicated rebase.sh handlers exist. Add .rebase/replace/ or .rebase/override/ rule files for dompurify.d.ts and dompurify.js to match the pattern used for cgmanifest.json and other modified upstream files.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change (updating DOMPurify to fix CVE-2026-41240), is under 72 characters, includes the JIRA key (CRW-10794), and uses imperative mood.
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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

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.

2 participants