Skip to content

Commit 6bcc93a

Browse files
authored
Merge pull request #22822 from owen-mc/python/fix-query-active-sources
Python: fix 3 queries to use sources for the active threat model
2 parents 6b16b0b + ce648b3 commit 6bcc93a

34 files changed

Lines changed: 106 additions & 109 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Updated the `py/xxe`, `py/xml-bomb`, and `py/nosql-injection` queries to respect the configured threat model when selecting untrusted data sources. The default behavior remains unchanged and uses remote flow sources. As a side effect, these queries now correctly include sources modeled using data extensions.

‎python/ql/lib/semmle/python/security/dataflow/CodeInjectionCustomizations.qll‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ module CodeInjection {
3737
*/
3838
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
3939

40-
/**
41-
* An active threat-model source, considered as a flow source.
42-
*/
43-
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
40+
/** An active threat-model source, considered as a flow source. */
41+
private class ActiveThreatModelSourceAsSource extends Source instanceof ActiveThreatModelSource {
42+
}
4443

4544
/**
4645
* A code execution, considered as a flow sink.

‎python/ql/lib/semmle/python/security/dataflow/CommandInjectionCustomizations.qll‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ module CommandInjection {
3737
*/
3838
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
3939

40-
/**
41-
* An active threat-model source, considered as a flow source.
42-
*/
43-
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
40+
/** An active threat-model source, considered as a flow source. */
41+
private class ActiveThreatModelSourceAsSource extends Source instanceof ActiveThreatModelSource {
42+
}
4443

4544
/**
4645
* A command execution, considered as a flow sink.

‎python/ql/lib/semmle/python/security/dataflow/CookieInjectionCustomizations.qll‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ module CookieInjection {
3535
*/
3636
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
3737

38-
/**
39-
* An active threat-model source, considered as a flow source.
40-
*/
41-
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
38+
/** An active threat-model source, considered as a flow source. */
39+
private class ActiveThreatModelSourceAsSource extends Source instanceof ActiveThreatModelSource {
40+
}
4241

4342
/**
4443
* A write to a cookie, considered as a sink.

‎python/ql/lib/semmle/python/security/dataflow/HttpHeaderInjectionCustomizations.qll‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ module HttpHeaderInjection {
3636
*/
3737
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
3838

39-
/**
40-
* An active threat-model source, considered as a flow source.
41-
*/
42-
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
39+
/** An active threat-model source, considered as a flow source. */
40+
private class ActiveThreatModelSourceAsSource extends Source instanceof ActiveThreatModelSource {
41+
}
4342

4443
/**
4544
* A HTTP header write, considered as a flow sink.

‎python/ql/lib/semmle/python/security/dataflow/LdapInjectionCustomizations.qll‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ module LdapInjection {
4646
*/
4747
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
4848

49-
/**
50-
* An active threat-model source, considered as a flow source.
51-
*/
52-
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
49+
/** An active threat-model source, considered as a flow source. */
50+
private class ActiveThreatModelSourceAsSource extends Source instanceof ActiveThreatModelSource {
51+
}
5352

5453
/**
5554
* A logging operation, considered as a flow sink.

‎python/ql/lib/semmle/python/security/dataflow/LogInjectionCustomizations.qll‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ module LogInjection {
3737
*/
3838
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
3939

40-
/**
41-
* An active threat-model source, considered as a flow source.
42-
*/
43-
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
40+
/** An active threat-model source, considered as a flow source. */
41+
private class ActiveThreatModelSourceAsSource extends Source instanceof ActiveThreatModelSource {
42+
}
4443

4544
/**
4645
* A logging operation, considered as a flow sink.

‎python/ql/lib/semmle/python/security/dataflow/NoSqlInjectionCustomizations.qll‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import python
88
import semmle.python.dataflow.new.DataFlow
9-
import semmle.python.dataflow.new.RemoteFlowSources
109
import semmle.python.Concepts
1110

1211
/**
@@ -63,8 +62,14 @@ module NoSqlInjection {
6362
abstract DataFlow::Node getOutput();
6463
}
6564

66-
/** A remote flow source considered a source of user controlled strings. */
67-
class RemoteFlowSourceAsStringSource extends RemoteFlowSource, StringSource { }
65+
/**
66+
* DEPRECATED: Use `ActiveThreatModelSource` from Concepts instead!
67+
*/
68+
deprecated class RemoteFlowSourceAsStringSource = ActiveThreatModelSourceAsStringSource;
69+
70+
/** An active threat-model source considered a source of user controlled strings. */
71+
private class ActiveThreatModelSourceAsStringSource extends StringSource instanceof ActiveThreatModelSource
72+
{ }
6873

6974
/** A NoSQL query that is vulnerable to user controlled strings. */
7075
class NoSqlExecutionAsStringSink extends StringSink {

‎python/ql/lib/semmle/python/security/dataflow/PamAuthorizationCustomizations.qll‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ module PamAuthorizationCustomizations {
4444
*/
4545
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
4646

47-
/**
48-
* An active threat-model source, considered as a flow source.
49-
*/
50-
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
47+
/** An active threat-model source, considered as a flow source. */
48+
private class ActiveThreatModelSourceAsSource extends Source instanceof ActiveThreatModelSource {
49+
}
5150

5251
/**
5352
* A vulnerable `pam_authenticate` call considered as a flow sink.

‎python/ql/lib/semmle/python/security/dataflow/PathInjectionCustomizations.qll‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ module PathInjection {
4747
*/
4848
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
4949

50-
/**
51-
* An active threat-model source, considered as a flow source.
52-
*/
53-
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
50+
/** An active threat-model source, considered as a flow source. */
51+
private class ActiveThreatModelSourceAsSource extends Source instanceof ActiveThreatModelSource {
52+
}
5453

5554
/**
5655
* A file system access, considered as a flow sink.

0 commit comments

Comments
 (0)