fix: add XXE protection for XML parsing#623
Open
Correctover wants to merge 1 commit into
Open
Conversation
Add _xml_safety module with safe_fromstring() and safe_parse() functions that detect and block XML External Entity (XXE) attack patterns before parsing. Changes: - panos/_xml_safety.py: New module with XXE protection - panos/userid.py: Replace ET.fromstring() with safe_fromstring() - tests/test_xml_safety.py: 6 test cases covering safe/unsafe XML Defense-in-depth for Python < 3.11 (expat 2.6.0+ has built-in protection). Backward compatible - normal XML parsing unaffected. Resolves PaloAltoNetworks#617 (Finding 1: Unsafe XML parser)
Author
|
Still relevant — Adds critical XXE protection for XML parsing. Happy to rebase or adjust if needed. |
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.
Security fix for issue #617 Finding 1: Unsafe XML parser.
Added
panos/_xml_safety.pywithsafe_fromstring()that blocks XXE attacks (ENTITY/DOCTYPE with internal subset). Works on Python 2.7+ (defense-in-depth for < 3.11).Changes:
panos/_xml_safety.py: XXE protection modulepanos/userid.py: Use safe_fromstring() (2 locations)tests/test_xml_safety.py: 6 tests, all passBackward compatible, no new dependencies.
Note on Finding 2 (SHA-1): PAN-OS protocol constraint, not SDK-fixable.