Fix zip slip vulnerability in unzip utility#10944
Open
th555555 wants to merge 1 commit intomicrosoft:developfrom
Open
Fix zip slip vulnerability in unzip utility#10944th555555 wants to merge 1 commit intomicrosoft:developfrom
th555555 wants to merge 1 commit intomicrosoft:developfrom
Conversation
Enhanced the unzip method to validate entry paths and prevent zip slip attacks by ensuring extracted files remain within the destination directory. Also improved directory creation and resource management using try-with-resources. references: dylwedma11748/JTegraNX@dd5c2e1 https://cwe.mitre.org/data/definitions/22.html
Contributor
|
@th555555 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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
Fixed a critical XML External Entity (XXE) vulnerability in the
newDocumentmethod that could allow attackers to read local files, perform SSRF attacks, or cause denial of service.Vulnerability Details
CVE Impact: High - XML External Entity (XXE) Injection (CWE-611)
CVSS Score: 8.8 (High - Information disclosure and SSRF possible)
Related CVEs: CVE-2021-42550, CVE-2020-25649
Issue Description
The original implementation created a
DocumentBuilderFactorywithout security configurations, making it vulnerable to XXE attacks:This allows malicious XML input to:
file://protocolAttack Example
Malicious XML could exploit this vulnerability:
Security Fix Applied
XXE Prevention Measures:
Key Security Improvements:
Disable External DTD Access:
XMLConstants.ACCESS_EXTERNAL_DTDset to empty stringDisable External Schema Access:
XMLConstants.ACCESS_EXTERNAL_SCHEMAset to empty stringAdded Required Imports:
javax.xml.XMLConstantsfor security constantsBefore (Vulnerable)
After (Secure)