forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request github#16760 from owen-mc/java/reverse-dns-separat…
…e-threat-model-kind Java: make a separate threat model kind for reverse DNS sources
- Loading branch information
Showing
10 changed files
with
104 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
java/ql/lib/change-notes/2024-06-14-reverse-dns-separate-threat-model-kind.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: majorAnalysis | ||
--- | ||
* We previously considered reverse DNS resolutions (IP address -> domain name) as sources of untrusted data, since compromised/malicious DNS servers could potentially return malicious responses to arbitrary requests. We have now removed this source from the default set of untrusted sources and made a new threat model kind for them, called "reverse-dns". You can optionally include other threat models as appropriate when using the CodeQL CLI and in GitHub code scanning. For more information, see [Analyzing your code with CodeQL queries](https://docs.github.com/code-security/codeql-cli/getting-started-with-the-codeql-cli/analyzing-your-code-with-codeql-queries#including-model-packs-to-add-potential-sources-of-tainted-data>) and [Customizing your advanced setup for code scanning](https://docs.github.com/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#extending-codeql-coverage-with-threat-models). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
java/ql/test/library-tests/dataflow/taintsources/reversedns.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
failures | ||
testFailures |
47 changes: 47 additions & 0 deletions
47
java/ql/test/library-tests/dataflow/taintsources/reversedns.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import java | ||
import semmle.code.java.dataflow.FlowSources | ||
import TestUtilities.InlineExpectationsTest | ||
|
||
predicate isTestSink(DataFlow::Node n) { | ||
exists(MethodCall ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument()) | ||
} | ||
|
||
module ReverseDnsValueConfig implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { n instanceof ReverseDnsUserInput } | ||
|
||
predicate isSink(DataFlow::Node n) { isTestSink(n) } | ||
} | ||
|
||
module ReverseDnsValueFlow = DataFlow::Global<ReverseDnsValueConfig>; | ||
|
||
module ReverseDnsTaintConfig implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { n instanceof ReverseDnsUserInput } | ||
|
||
predicate isSink(DataFlow::Node n) { isTestSink(n) } | ||
} | ||
|
||
module ReverseDnsTaintFlow = TaintTracking::Global<ReverseDnsTaintConfig>; | ||
|
||
module ReverseDnsFlowTest implements TestSig { | ||
string getARelevantTag() { result = ["hasReverseDnsValueFlow", "hasReverseDnsTaintFlow"] } | ||
|
||
predicate hasActualResult(Location location, string element, string tag, string value) { | ||
tag = "hasReverseDnsValueFlow" and | ||
exists(DataFlow::Node sink | ReverseDnsValueFlow::flowTo(sink) | | ||
sink.getLocation() = location and | ||
element = sink.toString() and | ||
value = "" | ||
) | ||
or | ||
tag = "hasReverseDnsTaintFlow" and | ||
exists(DataFlow::Node src, DataFlow::Node sink | | ||
ReverseDnsTaintFlow::flow(src, sink) and not ReverseDnsValueFlow::flow(src, sink) | ||
| | ||
sink.getLocation() = location and | ||
element = sink.toString() and | ||
value = "" | ||
) | ||
} | ||
} | ||
|
||
import MakeTest<ReverseDnsFlowTest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters