Skip to content

[try] fix possible XXE vulnerabilities #10193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tools/vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

import xml.etree.ElementTree as etree
from xml.etree.ElementTree import SubElement
from defusedxml.ElementTree import parse
from defusedxml.common import DefusedXmlException
from utils import _make_path_relative
from utils import xml_indent
fs_encoding = sys.getfilesystemencoding()
Expand Down Expand Up @@ -86,7 +88,8 @@ def VS_AddHeadFilesGroup(program, elem, project_path):
def VSProject(target, script, program):
project_path = os.path.dirname(os.path.abspath(target))

tree = etree.parse('template_vs2005.vcproj')
# tree = etree.parse('template_vs2005.vcproj')
tree = parse('template_vs2005.vcproj', forbid_dtd=False, forbid_external=True)
Comment on lines +91 to +92
Copy link
Preview

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented-out legacy parsing code may lead to confusion; consider removing it if it's no longer needed.

Suggested change
# tree = etree.parse('template_vs2005.vcproj')
tree = parse('template_vs2005.vcproj', forbid_dtd=False, forbid_external=True)

Copilot uses AI. Check for mistakes.

Copy link
Preview

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current configuration allows DTDs (forbid_dtd=False) which may still enable XXE attacks; if the intent is to fully mitigate XXE vulnerabilities, consider setting forbid_dtd to True.

Suggested change
tree = parse('template_vs2005.vcproj', forbid_dtd=False, forbid_external=True)
tree = parse('template_vs2005.vcproj', forbid_dtd=True, forbid_external=True)

Copilot uses AI. Check for mistakes.

root = tree.getroot()

out = open(target, 'w')
Expand Down