From 7d8e598b9213e83e0db48939c9800fe6ea56996b Mon Sep 17 00:00:00 2001
From: Petr Viktorin <encukou@gmail.com>
Date: Mon, 29 Jun 2026 17:41:26 +0200
Subject: [PATCH] [CVE-2026-4360] Pass filter_function to
 TarFile._extract_one() during .extract()

This patch ensures TarFile.extract() properly passes the filter
parameter to _extract_one() when fallback extraction occurs for missing
hardlink targets.

Fixes: bsc#1269959 (CVE-2026-4360)
Fixes: gh#python/cpython#151987
From-PR: gh#python/cpython!151988
Patch: CVE-2026-4360-filter_function-TarFile-extractone.patch
---
 Lib/tarfile.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 2a2b9d7b050..3d0e26a0200 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2346,7 +2346,8 @@ class TarFile(object):
         tarinfo, unfiltered = self._get_extract_tarinfo(
             member, filter_function, path)
         if tarinfo is not None:
-            self._extract_one(tarinfo, path, set_attrs, numeric_owner)
+            self._extract_one(tarinfo, path, set_attrs, numeric_owner,
+                              filter_function=filter_function)
 
     def _get_extract_tarinfo(self, member, filter_function, path):
         """Get (filtered, unfiltered) TarInfos from *member*
-- 
2.55.0
