Restrict owner-link and extra-link href to safe schemes (http, https, mailto, relative)#66741
Merged
choo121600 merged 1 commit intoMay 12, 2026
Conversation
… mailto, relative) Bring DAG `owner_links` and operator extra-link rendering in line with the scheme-allowlist policy already used by markdown links (react-markdown's default `urlTransform`) and log / XCom linkification (which is `https?://`-only). Adds a `getSafeExternalUrl` helper that passes through `http:`, `https:`, `mailto:`, and same-origin / relative URLs and returns `undefined` for any other scheme. Both `DagOwners.tsx` (owner-link rendering on the DAGs list and DAG header) and `ExtraLinks.tsx` (operator extra-link buttons on the task-instance page) now consult the helper and skip / downgrade to the filter-link fallback when the href would be unsafe. Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bring DAG
owner_linksand operator extra-link rendering in line with the scheme-allowlist policy already applied to markdown links (react-markdown's defaulturlTransform) and log / XCom linkification (which ishttps?://-only).Before this change, both surfaces rendered DAG-author-supplied URLs (
dag.owner_linksset in the DAG file; operator extra-link URLs commonly read from task-pushed XCom) directly as<a href={url} target="_blank">with no scheme filter.target="_blank"blocksjavascript:navigation on every modern browser, so the application itself provided no defense in depth on the rare legacy / embedded webview that still navigatesjavascript:in a new tab.After this change, both surfaces consult a shared
getSafeExternalUrl(url)helper that passes throughhttp:/https:/mailto:/ relative URLs and returnsundefinedfor anything else. Unsafe URLs are silently skipped on the extra-links page; the owner-link surface falls back to the existing in-app/dags?owners=Xfilter link.Files changed
airflow-core/src/airflow/ui/src/utils/links.ts— newgetSafeExternalUrlhelper.airflow-core/src/airflow/ui/src/utils/links.test.ts— new vitest cases for the allow / reject matrix.airflow-core/src/airflow/ui/src/pages/TaskInstance/ExtraLinks.tsx— wrap extra-linkurlwith the helper; skip rendering when undefined.airflow-core/src/airflow/ui/src/pages/DagsList/DagOwners.tsx— wrapowner_links[owner]with the helper; fall back to the filter-link when unsafe.Test plan
pnpm vitest run src/utils/links.test.ts— 34 / 34 tests pass (8 allow + 9 reject cases forgetSafeExternalUrl, plus the existing tests)pnpm lint— eslint clean,tsc --p tsconfig.app.jsoncleanprek run --from-ref upstream/main --stage pre-commit— cleanMigration
DAG-author-supplied
owner_linksentries using non-allowlisted schemes (javascript:,data:,file:, etc.) are silently skipped on the UI and fall back to the in-app owner-filter link; same for operator extra-links carrying such schemes. No DAG-level API surface changes.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions