fix: DOM-based XSS in job and notebook source URLs#21175
fix: DOM-based XSS in job and notebook source URLs#21175WeichenXu123 merged 1 commit intomlflow:masterfrom
Conversation
🛠 DevTools 🛠
Install mlflow from this PRFor Databricks, use the following command: |
There was a problem hiding this comment.
Pull request overview
This PR addresses a DOM-based Cross-Site Scripting (XSS) vulnerability (CWE-79) in the MLflow UI by adding URL sanitization for workspace URLs used in job and notebook source links. The vulnerability allowed attackers to inject malicious URLs with dangerous protocols (javascript:, data:, vbscript:) that would execute when users clicked on source links.
Changes:
- Added
sanitizeUrl()utility function that validates URLs to only allow http/https protocols - Applied sanitization to
getJobSourceUrl()andgetNotebookSourceUrl()to block dangerous workspace URLs - Updated
renderJobSource()andrenderNotebookSource()to render plain text instead of links when URLs fail sanitization - Added comprehensive test coverage for URL sanitization and fallback behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| mlflow/server/js/src/common/utils/Utils.tsx | Added sanitizeUrl function and applied it to getJobSourceUrl and getNotebookSourceUrl; updated render functions to handle empty URLs |
| mlflow/server/js/src/common/utils/Utils.test.tsx | Added comprehensive tests for sanitizeUrl, URL sanitization in get*SourceUrl functions, and render fallback behavior |
|
Documentation preview for e3a20b8 is available at: More info
|
WeichenXu123
left a comment
There was a problem hiding this comment.
Overall good. Could you address the comment? and then I can approve and merge it.
Signed-off-by: Guilherme Caponetto <638737+caponetto@users.noreply.github.com>
|
@WeichenXu123 Thanks for the review! Requested changes are in. |
Signed-off-by: Guilherme Caponetto <638737+caponetto@users.noreply.github.com>
Signed-off-by: Guilherme Caponetto <638737+caponetto@users.noreply.github.com>
Signed-off-by: Guilherme Caponetto <638737+caponetto@users.noreply.github.com>
Signed-off-by: Guilherme Caponetto <638737+caponetto@users.noreply.github.com>
Signed-off-by: Guilherme Caponetto <638737+caponetto@users.noreply.github.com>
Related Issues/PRs
Closes #21231
What changes are proposed in this pull request?
isValidHttpUrlingetJobSourceUrlandgetNotebookSourceUrlto reject non-http/httpsURI schemes, preventing DOM-based XSS (CWE-79) viajavascript:,data:, orvbscript:URLs in dynamichrefattributesrenderJobSourceandrenderNotebookSourceto fall back to plain text when the URL is unsafestring | nulltype annotation toworkspaceUrlparameters across all four affected functionsHow is this patch tested?
getJobSourceUrlandgetNotebookSourceUrlreturn empty string for unsafe workspace URLsrenderJobSourceandrenderNotebookSourcerender plain text (no anchor tag) when given a malicious workspace URLHow is this PR tested?
Does this PR require documentation update?
Does this PR require updating the MLflow Skills repository?
Release Notes
Is this a user-facing change?
Fixed a DOM-based Cross-Site Scripting (XSS) vulnerability (CWE-79) where unsanitized workspace URLs could be injected into
hrefattributes when rendering notebook and job source links. URLs are now validated to only allowhttpandhttpsprotocols; unsafe URLs are rendered as plain text instead of clickable links.What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow should the PR be classified in the release notes? Choose one:
rn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.What is a minor/patch release?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.