GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add warning to `xml.sax.saxutils.XMLGenerator` about untrusted inputs · Issue #139478 · python/cpython

Add warning to xml.sax.saxutils.XMLGenerator about untrusted inputs #139478

New issue
Copy link
New issue
Copy link
Open
Open
Add warning to xml.sax.saxutils.XMLGenerator about untrusted inputs#139478
Copy link
Assignees
sethmlarson
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-XMLtype-securityA security issueA security issue

Description

@sethmlarson
sethmlarson
opened on Oct 1, 2025
Issue body actions

The xml.sax.saxutils.XMLGenerator class doesn't warn users that inputs are not validated and therefore validation, if required due to untrusted input, is the user responsibility.

Linked PRs

  • gh-139478: Add warning about lack of validation for xml.sax.saxutils.XMLGenerator #139479

Activity

  1. sethmlarson
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Oct 1, 2025
  2. github-project-automation
    added this to docs issueson Oct 1, 2025
  3. sethmlarson
    self-assigned this
    on Oct 1, 2025
  4. github-project-automation
    moved this to Todo in docs issueson Oct 1, 2025
  5. StanFromIreland
    added
    type-securityA security issueA security issue
    topic-XML
    on Oct 1, 2025
  6. serhiy-storchaka commented on Oct 1, 2025

    @serhiy-storchaka
    serhiy-storchaka
    on Oct 1, 2025
    Member
    More actions

    I do not think that placing such loud warning before the class description is a good idea.

    First, the purpose of this class is to reproduce the equivalent XML document from the sequence of SAX events. SAX events produced by the XML parser do not need validation. Any other use of this class is not intended use.

    If add any note, it should be after the class description. And I doubt about the use of the warning directive, it should be reserved for more serious cases. The note directive or the plain text should be enough. Be careful not to add incorrect signal about the intended use of XMLGenerator.

    Second, there is a larger elephant in the room. There are several other XML generators in the stdlib: minidom, ElementTree, xmlrpc, plistlib, libregrtest, maybe more. And almost no one of them validate the user data, even if they are purposed to be used with arbitrary user data (unlike to XMLGenerator).

  7. sethmlarson commented on Oct 1, 2025

    @sethmlarson
    sethmlarson
    on Oct 1, 2025
    ContributorAuthor
    More actions

    First, the purpose of this class is to reproduce the equivalent XML document from the sequence of SAX events. SAX events produced by the XML parser do not need validation. Any other use of this class is not intended use.

    This seems like a good reason to modify the warning (and change it to a note). If you have specifics you can propose them in the pull request, otherwise I'll try my best.

    Second, there is a larger elephant in the room. There are several other XML generators in the stdlib: minidom, ElementTree, xmlrpc, plistlib, libregrtest, maybe more. And almost no one of them validate the user data, even if they are purposed to be used with arbitrary user data (unlike to XMLGenerator).

    If arbitrary user data is being processed then someone needs to do the validation. If we intend that someone to be the user, and it's probable that a user might mistakenly think we're doing the validation when we're not, then we should be documenting that fact somewhere.

  8. sethmlarson commented on Oct 1, 2025

    @sethmlarson
    sethmlarson
    on Oct 1, 2025
    ContributorAuthor
    More actions

    @serhiy-storchaka It does seem that the xml.sax module globally references the "XML Security" documentation page: https://docs.python.org/3/library/xml.html#xml-security

  9. serhiy-storchaka commented on Oct 1, 2025

    @serhiy-storchaka
    serhiy-storchaka
    on Oct 1, 2025
    Member
    More actions

    I suggest to look at global picture. What other modules have such issue? Then we should add standardized notes/warnings for all modules.

    Even if use of XMLGenerator for XML generation is not intended, people use it for this (at least one case), so it makes sense to add such note/warning here too. But only after other modules.

    cc @vstinner which added a workaround for similar issue in regrtest (#121188).

  10. serhiy-storchaka commented on Sep 1, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Sep 1, 2026
    Member
    More actions

    See also

    • gh-57092: Add the validate option to xml.sax.saxutils.XMLGenerator #156800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sethmlarson
    sethmlarson

Labels

docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-XMLtype-securityA security issueA security issue

Projects

  • docs issues
    Status
    Todo
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.