More secure file extraction#12394
Conversation
EntelligenceAI PR SummaryHardens
Confidence Score: 5/5 - Safe to MergeSafe to merge — this PR meaningfully hardens Key Findings:
Files requiring special attention
|
WalkthroughThis PR hardens the Changes
Sequence DiagramThis diagram shows the interactions between components: sequenceDiagram
participant Caller
participant safe_extract
participant __get_tar_members
participant __is_within_directory
participant archivefile
Caller->>safe_extract: safe_extract(archivefile, path, members, numeric_owner)
alt archivefile is ZipFile
loop each member in namelist()
safe_extract->>__is_within_directory: __is_within_directory(path, member_path)
__is_within_directory-->>safe_extract: bool (uses realpath + commonpath)
end
safe_extract->>archivefile: extractall(path)
else archivefile is TarFile (py < 3.12)
safe_extract->>__get_tar_members: __get_tar_members(archivefile, members)
Note over __get_tar_members: Returns all members if members=None,<br/>otherwise resolves strings to TarInfo objects
__get_tar_members-->>safe_extract: resolved_members[]
loop each member in resolved_members
safe_extract->>__is_within_directory: __is_within_directory(path, member_path)
__is_within_directory-->>safe_extract: bool
opt member passes all checks
safe_extract->>archivefile: extract(member, path, numeric_owner)
archivefile-->>safe_extract: done
end
end
end
safe_extract-->>Caller: extraction complete
🔗 Cross-Repository Impact AnalysisEnable automatic detection of breaking changes across your dependent repositories. → Set up now Learn more about Cross-Repository AnalysisWhat It Does
How to Enable
Benefits
|
Description
More secure file extraction
Fixes #12296
Type of change
(Please delete options that are not relevant)
Verification Process
To ensure the changes are working as expected:
Additional Media:
Checklist: