stchris / untangle

Converts XML to Python objects
MIT License
612 stars 83 forks source link

xml.sax package is vulnerable to XML External Entities (XXE) injection #60

Closed morenopc closed 2 years ago

morenopc commented 5 years ago

I'd like to mention that xml.sax package is vulnerable to XML External Entities (XXE) injection.

The feature_external_ges is True by default true: Include all external general (text) entities which means vulnerable to XXE injection.

For example, a possible solution could be set to False at untangle.py#L185

from xml.sax import make_parser, SAXException
from xml.sax.handler import feature_external_ges

parser = make_parser()
parser.setFeature(feature_external_ges, False)

Please check:

stchris commented 5 years ago

Thanks, @morenopc ! I will consider that change and maybe release a security fix soon.

stchris commented 2 years ago

I tried to prevent some of this in #90 but in the end I made another release (1.2.1) which switches to defusedxml instead of xml.sax.