Skip to content

Commit f0131af

Browse files
committed
Python: Fix huge_tree modeling
1 parent d6cbfec commit f0131af

File tree

2 files changed

+3
-2
lines changed
  • python/ql
    • src/experimental/semmle/python/frameworks
    • test/experimental/library-tests/frameworks/XML

2 files changed

+3
-2
lines changed

python/ql/src/experimental/semmle/python/frameworks/Xml.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ private module Lxml {
341341
)
342342
or
343343
(kind.isBillionLaughs() or kind.isQuadraticBlowup()) and
344-
this.getArgByName("huge_tree").getALocalSource().asExpr() = any(True t)
344+
this.getArgByName("huge_tree").getALocalSource().asExpr() = any(True t) and
345+
not this.getArgByName("resolve_entities").getALocalSource().asExpr() = any(False t)
345346
or
346347
kind.isDtdRetrieval() and
347348
this.getArgByName("load_dtd").getALocalSource().asExpr() = any(True t) and

python/ql/test/experimental/library-tests/frameworks/XML/lxml_etree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
# Safe for both Billion laughs and XXE
4949
parser = lxml.etree.XMLParser(resolve_entities=False, huge_tree=True)
50-
lxml.etree.fromstring(x, parser=parser) # $ input=x SPURIOUS: vuln='Billion Laughs' vuln='Quadratic Blowup'
50+
lxml.etree.fromstring(x, parser=parser) # $ input=x
5151

5252
# DTD retrival vuln (also XXE)
5353
parser = lxml.etree.XMLParser(load_dtd=True, no_network=False)

0 commit comments

Comments
 (0)