mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Merge pull request #18466 from asgerf/js/view-component-inputs
JS: Add view-component-input threat model
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
category: majorAnalysis
|
||||
---
|
||||
* Added a new threat model kind called `view-component-input`, which can enabled with [advanced setup](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#extending-codeql-coverage-with-threat-models).
|
||||
When enabled, all React props, Vue props, and input fields in an Angular component are seen as taint sources, even if none of the corresponding instantiation sites appear to pass in a tainted value.
|
||||
Some users may prefer this as a "defense in depth" option but note that it may result in false positives.
|
||||
Regardless of whether the threat model is enabled, CodeQL will propagate taint from the instantiation sites of such components into the components themselves.
|
||||
@@ -11,13 +11,6 @@
|
||||
import javascript
|
||||
import meta.internal.TaintMetrics
|
||||
|
||||
string getName(DataFlow::Node node) {
|
||||
result = node.(RemoteFlowSource).getSourceType()
|
||||
or
|
||||
not node instanceof RemoteFlowSource and
|
||||
result = "Taint source"
|
||||
}
|
||||
|
||||
from DataFlow::Node node
|
||||
where node = relevantTaintSource()
|
||||
select node, getName(node)
|
||||
from ThreatModelSource node
|
||||
where node = relevantTaintSource() and node.getThreatModel() = "remote"
|
||||
select node, getTaintSourceName(node)
|
||||
|
||||
19
javascript/ql/src/meta/alerts/ThreatModelSources.ql
Normal file
19
javascript/ql/src/meta/alerts/ThreatModelSources.ql
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @name Threat model sources
|
||||
* @description Sources of possibly untrusted input that can be configured via threat models.
|
||||
* @kind problem
|
||||
* @problem.severity recommendation
|
||||
* @id js/meta/alerts/threat-model-sources
|
||||
* @tags meta
|
||||
* @precision very-low
|
||||
*/
|
||||
|
||||
import javascript
|
||||
import meta.internal.TaintMetrics
|
||||
|
||||
from ThreatModelSource node, string threatModel
|
||||
where
|
||||
node = relevantTaintSource() and
|
||||
threatModel = node.getThreatModel() and
|
||||
threatModel != "remote" // "remote" is reported by TaintSources.ql
|
||||
select node, getTaintSourceName(node) + " (\"" + threatModel + "\" threat model)"
|
||||
@@ -75,9 +75,9 @@ DataFlow::Node relevantTaintSink(string kind) {
|
||||
DataFlow::Node relevantTaintSink() { result = relevantTaintSink(_) }
|
||||
|
||||
/**
|
||||
* Gets a relevant remote flow source.
|
||||
* Gets a relevant threat model source.
|
||||
*/
|
||||
RemoteFlowSource relevantTaintSource() { not result.getFile() instanceof IgnoredFile }
|
||||
ThreatModelSource relevantTaintSource() { not result.getFile() instanceof IgnoredFile }
|
||||
|
||||
/**
|
||||
* Gets the output of a call that shows intent to sanitize a value
|
||||
@@ -100,3 +100,10 @@ DataFlow::Node relevantSanitizerInput() {
|
||||
result = any(HtmlSanitizerCall call).getInput() and
|
||||
not result.getFile() instanceof IgnoredFile
|
||||
}
|
||||
|
||||
string getTaintSourceName(DataFlow::Node node) {
|
||||
result = node.(ThreatModelSource).getSourceType()
|
||||
or
|
||||
not node instanceof ThreatModelSource and
|
||||
result = "Taint source"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user