Fix XXE vulnerabilities in XML parsing#1364
Open
codingfrog wants to merge 1 commit intoarsenetar:masterfrom
Open
Fix XXE vulnerabilities in XML parsing#1364codingfrog wants to merge 1 commit intoarsenetar:masterfrom
codingfrog wants to merge 1 commit intoarsenetar:masterfrom
Conversation
Replace xml.etree.ElementTree.parse() with defusedxml safe parser in all XML loading operations. This prevents XML External Entity (XXE) attacks when loading user-provided XML files. - Add defusedxml dependency to requirements.txt - Use safe_parse() from defusedxml in directories.py - Use safe_parse() from defusedxml in results.py - Use safe_parse() from defusedxml in ignore.py - Use safe_parse() from defusedxml in exclude.py - Maintain xml.etree for XML writing (safe operations) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Context
During a security audit of dupeGuru, we identified XML External Entity (XXE) vulnerabilities in all 4 locations where XML files are parsed.
Vulnerability
dupeGuru uses
xml.etree.ElementTree.parse()to load user-editable XML files (saved results, ignore lists, exclusion lists, directory lists). The standard library's XML parser does not disable external entity processing by default, which means a crafted XML file could:/etc/passwd, SSH keys, browser cookies)Affected locations:
core/directories.py:249load_from_file()core/results.py:231load_from_xml()core/ignore.py:99load_from_xml()core/exclude.py:324load_from_xml()Attack scenario
Fix
defusedxml>=0.7.1,<1.0.0torequirements.txt— this is the standard Python library for safe XML parsingET.parse(infile)withdefusedxml.ElementTree.parse(infile)in all 4 filesxml.etree.ElementTreefor XML writing (Element, SubElement, etc.) which is not vulnerabledefusedxmldisables external entity processing, DTD fetching, and entity expansion by default.Test plan
pytest core/tests/directories_test.py core/tests/results_test.py core/tests/ignore_test.py core/tests/exclude_test.py— 167 tests passdefusedxmlinstalls cleanly🤖 Generated with Claude Code