Last active
June 3, 2025 13:38
-
-
Save sethmlarson/52398e33eff261329a0180ac1d54f42f to your computer and use it in GitHub Desktop.
Mitigation for CVE-2025-4517, CVE-2025-4330, CVE-2025-4138, and CVE-2024-12718
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
import pathlib | |
# Avoid insecure segments in link names. | |
# 'tar' is a tarfile open for reading. | |
for member in tar.getmembers(): | |
if member.linkname and '..' in pathlib.Path(member.linkname).parts: | |
raise OSError("Tarfile with insecure segment ('..') in linkname") | |
# Now safe to extract members with the data filter. | |
tar.extractall(filter="data") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment