Repository navigation
fix(ui): close DOMPurify math-equation bypass and mention-dropdown XSS - #32875
Conversation
- 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]>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ ApprovedCloses three UI security vulnerabilities: DOMPurify bypass via OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
✅ Playwright Results — workflow succeededValidated commit ✅ 808 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|
| 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
|
🚦 Removed from the merge queue —
|
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]>



Describe your changes
Fixes three UI security findings from a nightly security sweep:
<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 beforeDOMPurify.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-processinginnerHTMLstep (transformImgTagsToFileAttachment) before the editor schema could strip it. Fixed by dropping the exemption and allowlisting the tag properly viaADD_TAGS: ['block-math-equation']+ADD_ATTR: ['math_equation', 'isediting'], so DOMPurify sanitizes nested content and event-handler attributes normally while preserving legitimate equations.FeedEditor.renderItems()interpolateditem.name,item.type, and breadcrumb names (search-index data sourced from user-editabledisplayName/namefields) unescaped into an HTML template assigned viainnerHTML. A poisoned displayName executed when any user typed@/#in the feed editor. Fixed by escaping all interpolated values with lodashescape.rel="noopener noreferrer"to thetarget=_blankexternal-source link inCommonEntitySummaryInfoV1and the open-link Button inLinkPopup(antdButton, unlikeTypography.Link, injects no default rel).Tests
sanitize.utils.test.ts: 2 new tests — nested payload insideblock-math-equationis 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 realrenderItemhandler with a hostile entity name — asserts it renders as literal text, never parsed markup.LinkPopup.test.tsx/CommonEntitySummaryInfoV1.test.tsx: assertrel="noopener noreferrer"on the external links.yarn jeston the 4 touched suites: 44 passed.yarn eslinton changed files: 0 errors, no new warnings.Type of change
🤖 Generated with Claude Code