Skip to content

xml.sax.handler.feature_external_ges documentation fails to warn users of getting themselves into XXE territory #141994

@hartwork

Description

@hartwork

Documentation

The current documentation on xml.sax.handler.feature_external_ges

Image

…fails to warn that enabling feature_external_ges will make the XML parser vulnerable to external entity attacks.

For a demo:

# Copyright (c) 2025 Sebastian Pipping <sebastian@pipping.org>
# SPDX-License-Identifier: 0BSD

from io import StringIO
from textwrap import dedent
from xml.sax.expatreader import create_parser
from xml.sax.handler import feature_external_ges

parser = create_parser()

parser.setFeature(feature_external_ges, 1)

content = dedent("""\
    <!DOCTYPE root SYSTEM "https://host.invalid/404.dtd">
    <root/>
""")

parser.parse(StringIO(content))

CC @picnixz @hannob

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirtopic-XML

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions