🔒 fix: mitigate XXE vulnerability in XML BOM parser - #7
Conversation
Replaced xml.etree.ElementTree with defusedxml.ElementTree in fetch_sourcing_bom.py to prevent XML External Entity (XXE) injection vulnerabilities during BOM parsing. Updated CI workflow files to install the new defusedxml dependency to ensure compatibility in downstream pipelines. Co-authored-by: aman-katyal <181611364+aman-katyal@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What: The vulnerability fixed
An XML External Entity (XXE) injection vulnerability was present in
scripts/fetch_sourcing_bom.pydue to the use of the standard libraryxml.etree.ElementTreeparser for processing KiCad XML Bill of Materials (BOM) files.If an attacker could control the contents of the KiCad XML BOM file being processed, they could exploit the XXE vulnerability to perform Server-Side Request Forgery (SSRF), read local files on the system running the script (such as the CI server), or potentially cause a Denial of Service (DoS) through entity expansion attacks (billion laughs).
🛡️ Solution: How the fix addresses the vulnerability
The standard library
xml.etree.ElementTreeimport was replaced withdefusedxml.ElementTree. Thedefusedxmlpackage is specifically designed to safely parse untrusted XML data by disabling the processing of external entities and DTDs by default, thereby entirely mitigating the XXE attack vector while maintaining API compatibility. Additionally, GitHub Actions workflow files (.github/workflows/devops-ci.ymland.github/workflows/run-kicad-ci.yml) were updated to install the newdefusedxmldependency.PR created automatically by Jules for task 10196404447633928831 started by @aman-katyal