Skip to content

Commit 6d5b84f

Browse files
author
Esben Sparre Andreasen
committed
JS: split XmlBomb.qll
1 parent 5163ccf commit 6d5b84f

File tree

2 files changed

+56
-41
lines changed

2 files changed

+56
-41
lines changed
Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
/**
2-
* Provides a taint tracking configuration for reasoning about XML-bomb
3-
* vulnerabilities.
2+
* Provides a taint tracking configuration for reasoning about
3+
* XML-bomb vulnerabilities.
4+
*
5+
* Note, for performance reasons: only import this file if
6+
* `XmlBomb::Configuration` is needed, otherwise
7+
* `XmlBombCustomizations` should be imported instead.
48
*/
59

610
import javascript
7-
import semmle.javascript.security.dataflow.DOM
811

912
module XmlBomb {
10-
/**
11-
* A data flow source for XML-bomb vulnerabilities.
12-
*/
13-
abstract class Source extends DataFlow::Node { }
14-
15-
/**
16-
* A data flow sink for XML-bomb vulnerabilities.
17-
*/
18-
abstract class Sink extends DataFlow::Node { }
19-
20-
/**
21-
* A sanitizer for XML-bomb vulnerabilities.
22-
*/
23-
abstract class Sanitizer extends DataFlow::Node { }
13+
import XmlBombCustomizations::XmlBomb
2414

2515
/**
2616
* A taint-tracking configuration for reasoning about XML-bomb vulnerabilities.
@@ -37,28 +27,4 @@ module XmlBomb {
3727
node instanceof Sanitizer
3828
}
3929
}
40-
41-
/** A source of remote user input, considered as a flow source for XML bomb vulnerabilities. */
42-
class RemoteFlowSourceAsSource extends Source {
43-
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
44-
}
45-
46-
/**
47-
* An access to `document.location`, considered as a flow source for XML bomb vulnerabilities.
48-
*/
49-
class LocationAsSource extends Source, DataFlow::ValueNode {
50-
LocationAsSource() { isLocation(astNode) }
51-
}
52-
53-
/**
54-
* A call to an XML parser that performs internal entity expansion, viewed
55-
* as a data flow sink for XML-bomb vulnerabilities.
56-
*/
57-
class XmlParsingWithEntityResolution extends Sink, DataFlow::ValueNode {
58-
XmlParsingWithEntityResolution() {
59-
exists(XML::ParserInvocation parse | astNode = parse.getSourceArgument() |
60-
parse.resolvesEntities(XML::InternalEntity())
61-
)
62-
}
63-
}
6430
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Provides default sources, sinks and sanitisers for reasoning about
3+
* XML-bomb vulnerabilities, as well as extension points for adding
4+
* your own.
5+
*/
6+
7+
import javascript
8+
import semmle.javascript.security.dataflow.DOM
9+
10+
module XmlBomb {
11+
/**
12+
* A data flow source for XML-bomb vulnerabilities.
13+
*/
14+
abstract class Source extends DataFlow::Node { }
15+
16+
/**
17+
* A data flow sink for XML-bomb vulnerabilities.
18+
*/
19+
abstract class Sink extends DataFlow::Node { }
20+
21+
/**
22+
* A sanitizer for XML-bomb vulnerabilities.
23+
*/
24+
abstract class Sanitizer extends DataFlow::Node { }
25+
26+
/** A source of remote user input, considered as a flow source for XML bomb vulnerabilities. */
27+
class RemoteFlowSourceAsSource extends Source {
28+
RemoteFlowSourceAsSource() { this instanceof RemoteFlowSource }
29+
}
30+
31+
/**
32+
* An access to `document.location`, considered as a flow source for XML bomb vulnerabilities.
33+
*/
34+
class LocationAsSource extends Source, DataFlow::ValueNode {
35+
LocationAsSource() { isLocation(astNode) }
36+
}
37+
38+
/**
39+
* A call to an XML parser that performs internal entity expansion, viewed
40+
* as a data flow sink for XML-bomb vulnerabilities.
41+
*/
42+
class XmlParsingWithEntityResolution extends Sink, DataFlow::ValueNode {
43+
XmlParsingWithEntityResolution() {
44+
exists(XML::ParserInvocation parse | astNode = parse.getSourceArgument() |
45+
parse.resolvesEntities(XML::InternalEntity())
46+
)
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)