python3-click: fix CVE-2026-7246
PATCH v2 1/1 python3-click: fix CVE-2026-7246
From: Darsh Kelaiya <[email protected]>
This backports the click.edit() hardening identified as the fix in the public advisory [2], using upstream commit [1].
Upstream follow-up commit [3] adds regression-test coverage for editor command parsing and clarifies the related source comments. It does not change runtime behavior or provide an additional security fix. Carry it as a separate patch to preserve the upstream commit boundaries.
[1] https://github.com/pallets/click/commit/b96c2601af4e01341b4d2c0db494ebee4aef8f42
[2] https://github.com/tsigouris007/security-advisories/security/advisories/GHSA-47fr-3ffg-hgmw
[3] https://github.com/pallets/click/commit/b55294797ef32e22eb41e7d9657edb8faefa4976
--- .../CVE-2026-7246-regression.patch | 124 +++++++++++ .../python/python3-click/CVE-2026-7246.patch | 201 ++++++++++++++++++ .../python/python3-click_8.1.7.bb | 6 +- 3 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/python/python3-click/CVE-2026-7246-regression.patch create mode 100644 meta/recipes-devtools/python/python3-click/CVE-2026-7246.patch
meta/recipes-devtools/python/python3-click/CVE-2026-7246-regression.patch new file +124 -0
@@ -0,0 +1,124 @@ +From e3173ef521c287be53f1976b28c2fee28b6de5c7 Mon Sep 17 00:00:00 2001 +From: Kevin Deldycke <[email protected]> +Date: Fri, 10 Apr 2026 18:12:24 +0200 +Subject: [PATCH] Add path normalization edge-cases, verify `shlex.split` + behavior + +Also move to Python comments details relevant to developers instead of docstrings +Follow up to #3245 + +CVE: CVE-2026-7246 +Upstream-Status: Backport [https://github.com/pallets/click/commit/b55294797ef32e22eb41e7d9657edb8faefa4976] + +Backport Changes: +- Click 8.1.7 uses Editor.edit_file(filename), not the newer + Editor.edit_files(filenames) API. Apply the editor comment + follow-up and edge-case tests to the single-file API. +- Omit pager changes and pager-only follow-up tests because + Click 8.1.7 uses older pager APIs and CVE-2026-7246 affects + click.edit(), not pager execution. +- Omit cosmetic editor test ID renames. + +(cherry picked from commit b55294797ef32e22eb41e7d9657edb8faefa4976) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + src/click/_termui_impl.py | 12 ++++------ + tests/test_termui.py | 48 +++++++++++++++++++++++++++++++++++++++ + 2 files changed, 52 insertions(+), 8 deletions(-) + +diff --git a/src/click/_termui_impl.py b/src/click/_termui_impl.py +index c50b37b..3589160 100644 +--- a/src/click/_termui_impl.py ++++ b/src/click/_termui_impl.py +@@ -501,14 +501,7 @@ class Editor: + return "vi" + + def edit_file(self, filename: str) -> None: +- """Open a file in the user's editor. +- +- The editor command is split into an ``argv`` list with +- :func:`shlex.split` in POSIX mode; see :func:`pager` for rationale. +- +- .. seealso:: +- :issue:`1026` and :pr:`1477`. +- """ ++ """Open a file in the user's editor.""" + import shlex + import subprocess + +@@ -520,6 +513,9 @@ class Editor: + environ.update(self.env) + + try: ++ # Split in POSIX mode (the default) for the same reasons as ++ # upstream pager(): strips quotes from tokens and preserves ++ # quoted Windows paths. See issue #1026 and PR #1477. + c = subprocess.Popen( + args=shlex.split(editor) + [filename], + env=environ, +diff --git a/tests/test_termui.py b/tests/test_termui.py +index 7cea338..eda9a80 100644 +--- a/tests/test_termui.py ++++ b/tests/test_termui.py +@@ -421,6 +421,48 @@ def test_fast_edit(runner): + ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "f.txt"], + id="escaped space in unix path (issue 1026)", + ), ++ pytest.param( ++ " vim ", ++ "f.txt", ++ ["vim", "f.txt"], ++ id="leading and trailing whitespace", ++ ), ++ pytest.param( ++ "vim\t--clean", ++ "f.txt", ++ ["vim", "--clean", "f.txt"], ++ id="tab-separated tokens", ++ ), ++ pytest.param( ++ "'/Applications/My Editor.app/Contents/MacOS/editor'", ++ "f.txt", ++ ["/Applications/My Editor.app/Contents/MacOS/editor", "f.txt"], ++ id="single-quoted path with spaces", ++ ), ++ pytest.param( ++ '"my editor" --wait --new-window', ++ "file 1.txt", ++ ["my editor", "--wait", "--new-window", "file 1.txt"], ++ id="quoted editor with flags and filename with spaces", ++ ), ++ pytest.param( ++ "vim -u NONE -N", ++ "f.txt", ++ ["vim", "-u", "NONE", "-N", "f.txt"], ++ id="multiple short flags", ++ ), ++ pytest.param( ++ "editor", ++ 'file"name.txt', ++ ["editor", 'file"name.txt'], ++ id="filename with double quote", ++ ), ++ pytest.param( ++ "editor", ++ "file'name.txt", ++ ["editor", "file'name.txt"], ++ id="filename with single quote", ++ ), + ], + ) + def test_editor_path_normalization(editor_cmd, filename, expected_args): +@@ -484,6 +526,12 @@ def test_editor_nonexistent_exception(): + Editor(editor="nonexistent").edit_file("f.txt") + + ++def test_editor_unclosed_quote(): ++ """An unclosed quote in the editor command raises ValueError.""" ++ with pytest.raises(ValueError, match="No closing quotation"): ++ Editor(editor='"unclosed').edit_file("f.txt") ++ ++ + @pytest.mark.parametrize( + ("prompt_required", "required", "args", "expect"), + [
meta/recipes-devtools/python/python3-click/CVE-2026-7246.patch new file +201 -0
201 lines not on this page · raw message
meta/recipes-devtools/python/python3-click_8.1.7.bb +5 -1
@@ -12,7 +12,10 @@ SRC_URI[sha256sum] = "ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b inherit pypi setuptools3 ptest -SRC_URI += "file://run-ptest" +SRC_URI += "file://run-ptest \ + file://CVE-2026-7246.patch \ + file://CVE-2026-7246-regression.patch \ + " CVE_PRODUCT = "palletsprojects:click"
@@ -36,6 +39,7 @@ CLEANBROKEN = "1" RDEPENDS:${PN} += "\ python3-io \ python3-threading \ + python3-shell \ " BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.44.4
Quoted 41 lines · On Wed Sep 23, 2026 at 8:36 AM CEST, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…
From: Darsh Kelaiya <[email protected]>
This backports the
click.edit()hardening identified as the fix in the public advisory [2], using upstream commit [1].Upstream follow-up commit [3] adds regression-test coverage for editor command parsing and clarifies the related source comments. It does not change runtime behavior or provide an additional security fix. Carry it as a separate patch to preserve the upstream commit boundaries.
[1] https://github.com/pallets/click/commit/b96c2601af4e01341b4d2c0db494ebee4aef8f42
[2] https://github.com/tsigouris007/security-advisories/security/advisories/GHSA-47fr-3ffg-hgmw
[3] https://github.com/pallets/click/commit/b55294797ef32e22eb41e7d9657edb8faefa4976Signed-off-by Darsh Kelaiya <[email protected]>--- .../CVE-2026-7246-regression.patch | 124 +++++++++++ .../python/python3-click/CVE-2026-7246.patch | 201 ++++++++++++++++++ .../python/python3-click_8.1.7.bb | 6 +- 3 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/python/python3-click/CVE-2026-7246-regression.patch create mode 100644 meta/recipes-devtools/python/python3-click/CVE-2026-7246.patch[...]
meta/recipes-devtools/python/python3-click_8.1.7.bb +4
-1@@ -12,7 +12,10 @@ SRC_URI[sha256sum] = "ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b inherit pypi setuptools3 ptest -SRC_URI += "file://run-ptest" +SRC_URI += "file://run-ptest \ + file://CVE-2026-7246.patch \ + file://CVE-2026-7246-regression.patch \ + " CVE_PRODUCT = "palletsprojects:click"
meta/recipes-devtools/python/python3-click_8.1.7.bb CLEANBROKEN = "1" · line 41
Quoted 3 lines
meta/recipes-devtools/python/python3-click_8.1.7.bb +0
-0@@ -36,6 +39,7 @@ CLEANBROKEN = "1" RDEPENDS:${PN} += "\ python3-io \ python3-threading \
Hello,
meta/recipes-devtools/python/python3-click_8.1.7.bb CLEANBROKEN = "1" · line 42
Quoted 1 line
meta/recipes-devtools/python/python3-click_8.1.7.bb +1
-0+ python3-shell \
Why was this added? master does not have this RDEPENDS. If that is an issue to fix, then it should go through master (and other stables) first.
meta/recipes-devtools/python/python3-click_8.1.7.bb CLEANBROKEN = "1" · line 45
Quoted 3 lines
meta/recipes-devtools/python/python3-click_8.1.7.bb +0
-0" BBCLASSEXTEND = "native nativesdk"
FYI, the rest of the patch looks good to me. I've not found convincing reason to ignore the CVE. So the fix is the way forward.
Regards,
Signature · 2 lines
Yoann Congal Smile ECS
Hi Yoann,
Thanks for the review. I added python3-shell because the backported click.edit() fix imports shlex to split the editor command, and OE packages shlex.py in python3-shell. Without that runtime dependency, the fixed path can fail on a minimal image.
Click also imports shlex in master (8.5.0) and Wrynose (8.3.3). I’ve sent separate dependency patches for master [1] and Wrynose [2].
[1] https://lists.openembedded.org/g/openembedded-core/message/247148
[2] https://lists.openembedded.org/g/openembedded-core/message/247149
Best Regards,
Darsh
Quoted 77 lines · Yoann Congal
Quoted 48 lines · On Wed Sep 23, 2026 at 8:36 AM CEST, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…
From: Darsh Kelaiya <[email protected]>
This backports the
click.edit()hardening identified as the fix in the public advisory [2], using upstream commit [1].Upstream follow-up commit [3] adds regression-test coverage for editor command parsing and clarifies the related source comments. It does not change runtime behavior or provide an additional security fix. Carry it as a separate patch to preserve the upstream commit boundaries.
[1] https://github.com/pallets/click/commit/b96c2601af4e01341b4d2c0db494ebee4aef8f42
[2] https://github.com/tsigouris007/security-advisories/security/advisories/GHSA-47fr-3ffg-hgmw
[3] https://github.com/pallets/click/commit/b55294797ef32e22eb41e7d9657edb8faefa4976
Signed-off-by Darsh Kelaiya <[email protected]>---
.../CVE-2026-7246-regression.patch| 124 +++++++++++.../python/python3-click/CVE-2026-7246.patch| 201 ++++++++++++++++++ .../python/python3-click_8.1.7.bb | 6 +-3 files changed, 330 insertions(+), 1 deletion(-)create mode 100644
meta/recipes-devtools/python/python3-click/CVE-2026-7246-regression.patchcreate mode 100644meta/recipes-devtools/python/python3-click/CVE-2026-7246.patch[...]
meta/recipes-devtools/python/python3-click_8.1.7.bb +0
-0@@ -12,7 +12,10 @@ SRC_URI[sha256sum] ="
ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41binherit pypi setuptools3 ptest
meta/recipes-devtools/python/python3-click_8.1.7.bb +4
-1-SRC_URI += "file://run-ptest" +SRC_URI += "file://run-ptest \ + file://CVE-2026-7246.patch \ + file://CVE-2026-7246-regression.patch \ + "
CVE_PRODUCT= "palletsprojects:click"meta/recipes-devtools/python/python3-click_8.1.7.bb CLEANBROKEN = "1" · line 41
Quoted 3 lines
meta/recipes-devtools/python/python3-click_8.1.7.bb +0
-0@@ -36,6 +39,7 @@ CLEANBROKEN = "1" RDEPENDS:${PN} += "\ python3-io \ python3-threading \Hello,
meta/recipes-devtools/python/python3-click_8.1.7.bb CLEANBROKEN = "1" · line 42
Quoted 1 line
meta/recipes-devtools/python/python3-click_8.1.7.bb +1
-0+ python3-shell \Why was this added? master does not have this RDEPENDS. If that is an issue to fix, then it should go through master (and other stables) first.
Quoted 3 lines
"
BBCLASSEXTEND = "native nativesdk"
FYI, the rest of the patch looks good to me. I've not found convincing reason to ignore the CVE. So the fix is the way forward.
Regards,
--
Yoann Congal
Smile ECS