Skip to content

fix(ui): close DOMPurify math-equation bypass and mention-dropdown XSS - #32875

Merged
harsh-vador merged 1 commit into
mainfrom
fix/ui-sanitize-bypass-mention-xss
Sep 8, 2026
Merged

harsh-vador merged 1 commit into
mainfrom
fix/ui-sanitize-bypass-mention-xss

Conversation

@harsh-vador

@harsh-vador harsh-vador commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes

Fixes three UI security findings from a nightly security sweep:

  • High — DOMPurify bypass via <block-math-equation> (stored XSS): getSanitizeContent() regex-extracted the entire matched <block-math-equation>...</block-math-equation> substring — opening-tag attributes and nested children included — into a placeholder before DOMPurify.sanitize(), then restored the raw original verbatim. A payload like <block-math-equation><img src=x onerror=...></block-math-equation> in any description/comment survived sanitization intact and fired at the pre-processing innerHTML step (transformImgTagsToFileAttachment) before the editor schema could strip it. Fixed by dropping the exemption and allowlisting the tag properly via ADD_TAGS: ['block-math-equation'] + ADD_ATTR: ['math_equation', 'isediting'], so DOMPurify sanitizes nested content and event-handler attributes normally while preserving legitimate equations.
  • High — mention-dropdown innerHTML XSS (stored XSS): FeedEditor.renderItems() interpolated item.name, item.type, and breadcrumb names (search-index data sourced from user-editable displayName/name fields) unescaped into an HTML template assigned via innerHTML. A poisoned displayName executed when any user typed @/# in the feed editor. Fixed by escaping all interpolated values with lodash escape.
  • Medium — reverse tabnabbing: added rel="noopener noreferrer" to the target=_blank external-source link in CommonEntitySummaryInfoV1 and the open-link Button in LinkPopup (antd Button, unlike Typography.Link, injects no default rel).
Screenshot 2026-09-07 at 9 27 04 PM Screenshot 2026-09-07 at 9 27 24 PM Screenshot 2026-09-07 at 9 29 02 PM

Tests

  • sanitize.utils.test.ts: 2 new tests — nested payload inside block-math-equation is stripped; event-handler attributes on the tag itself are stripped. All existing math-equation/entity-link preservation tests pass unchanged.
  • FeedEditor.test.tsx: new test driving the real renderItem handler with a hostile entity name — asserts it renders as literal text, never parsed markup.
  • LinkPopup.test.tsx / CommonEntitySummaryInfoV1.test.tsx: assert rel="noopener noreferrer" on the external links.

yarn jest on the 4 touched suites: 44 passed. yarn eslint on changed files: 0 errors, no new warnings.

Type of change

  • Bug fix (security)

🤖 Generated with Claude Code

- sanitize.utils: stop exempting the whole <block-math-equation> match
  from DOMPurify — the raw-substring restore let attacker-controlled
  attributes/children (e.g. <img onerror>) nested inside the tag bypass
  sanitization entirely (stored XSS). Allowlist the tag and its
  attributes via ADD_TAGS/ADD_ATTR instead, so nested content and event
  handlers are sanitized normally.
- FeedEditor: escape entity name/type/breadcrumb values (user-editable,
  sourced from the search index) before interpolating them into the
  mention-suggestion innerHTML template (stored XSS).
- CommonEntitySummaryInfoV1/LinkPopup: add rel="noopener noreferrer" to
  target=_blank links on externally-sourced URLs (reverse tabnabbing).

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added the UI UI specific issues label Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@gitar-bot

gitar-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Closes three UI security vulnerabilities: DOMPurify bypass via <block-math-equation> tag (stored XSS), mention-dropdown innerHTML XSS from unsanitized entity names, and reverse tabnabbing on external links. Fixed by properly allowlisting the math tag through DOMPurify configuration, escaping interpolated values in feed editor rendering, and adding rel="noopener noreferrer" to target-blank links. All new and existing tests pass.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 49b4fa872a2ac495b32dbb4c7667d5231dc36ddc in Playwright run 34132039189, attempt 1.

✅ 808 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 59m 50s

⏱️ Max setup 4m 19s · max shard execution 19m 9s · max shard-job elapsed before upload 22m 51s · reporting 4s

🌐 203.44 requests/attempt · 2.75 app boots/UI scenario · 26.54% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 26.54% (convergence target: at most 15%).
  • Browser traffic was 203.44 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.75 per UI scenario (2016 boots / 732 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 159 0 0 0 0 0
✅ Shard chromium-02 162 0 0 0 0 0
✅ Shard chromium-03 160 0 0 0 0 0
🟡 Shard chromium-04 169 0 1 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 1 flaky test(s) (passed on retry)
  • Pages/TasksUIFlow.spec.ts › Create and resolve description task for Pipeline via UI (shard chromium-04, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@harsh-vador harsh-vador self-assigned this Sep 7, 2026
@harsh-vador harsh-vador added the safe to test Add this label to run secure Github workflows on PRs label Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 4 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 4 warning(s) across 2 changed file(s).

Count Rule
3 react-hooks/exhaustive-deps
1 openmetadata-imports/no-api-calls-in-iteration
All findings
Location Rule Message
🟡 src/components/ActivityFeed/FeedEditor/FeedEditor.tsx:129:20 openmetadata-imports/no-api-calls-in-iteration Avoid issuing one API request per item. Fetch at the data owner, use a bulk endpoint, or use useQueries with an intentional concurrency policy.
🟡 src/components/ActivityFeed/FeedEditor/FeedEditor.tsx:210:7 react-hooks/exhaustive-deps React Hook useCallback has an unnecessary dependency: 'userProfilePics'. Either exclude it or remove the dependency array.
🟡 src/components/ActivityFeed/FeedEditor/FeedEditor.tsx:254:7 react-hooks/exhaustive-deps React Hook useMemo has missing dependencies: 'renderItems', 't', and 'userSuggestionRenderer'. Either include them or remove the dependency array.
🟡 src/components/common/OverviewSection/CommonEntitySummaryInfoV1.tsx:57:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 70%
70.38% (95006/134976) 54.89% (56193/102369) 56.29% (18766/33333)

@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@pmbrull
pmbrull removed this pull request from the merge queue due to the queue being cleared Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — queue_cleared (2026-09-08T04:16:50Z)

The entry left the queue before it was built, so no checks ran against it.

@harsh-vador
harsh-vador added this pull request to the merge queue Sep 8, 2026
Merged via the queue into main with commit 2c22122 Sep 8, 2026
160 of 172 checks passed
@harsh-vador
harsh-vador deleted the fix/ui-sanitize-bypass-mention-xss branch September 8, 2026 14:26
harshach added a commit to harshach/OpenMetadata that referenced this pull request Sep 10, 2026
One conflict, in FeedEditor.tsx renderItems: main's open-metadata#32875 and this branch
fix the same mention-dropdown XSS by different means. Main escapes each
value interpolated into the innerHTML string template; this branch replaced
the template with JSX + renderToStaticMarkup, which escapes by construction
and also drops the per-suggestion ReactDOM.render root that leaked.

Kept this branch's version and dropped the now-unused lodash `escape`
import. Main's open-metadata#32875 changes outside this function -- the DOMPurify
math-equation bypass in sanitize.utils and the rel="noopener" additions --
are untouched, and both sides' XSS regression tests are retained and pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants