-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathExposureInTransmittedData.ql
More file actions
54 lines (49 loc) · 1.83 KB
/
ExposureInTransmittedData.ql
File metadata and controls
54 lines (49 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* @name Information exposure through transmitted data
* @description Transmitting sensitive information to the user is a potential security risk.
* @kind problem
* @problem.severity error
* @precision high
* @id cs/sensitive-data-transmission
* @tags security
* external/cwe/cwe-201
*/
import csharp
import semmle.code.csharp.security.SensitiveActions
import semmle.code.csharp.security.dataflow.XSS
import semmle.code.csharp.security.dataflow.Email
import semmle.code.csharp.frameworks.system.data.Common
import semmle.code.csharp.frameworks.System
class TaintTrackingConfiguration extends TaintTracking::Configuration {
TaintTrackingConfiguration() {
this = "Exposure through transmitted data"
}
override predicate isSource(DataFlow::Node source) {
// `source` may contain a password
source.asExpr() instanceof PasswordExpr
or
// `source` is from a `DbException` property
exists(PropertyRead pr, Property prop |
source.asExpr() = pr and
pr.getQualifier().getType() = any(SystemDataCommon::DbException de).getASubType*() and
prop = pr.getTarget() |
prop.getName() = "Message" or
prop.getName() = "Data"
)
or
// `source` is from `DbException.ToString()`
exists(MethodCall mc |
source.asExpr() = mc and
mc.getQualifier().getType() = any(SystemDataCommon::DbException de).getASubType*() and
mc.getTarget() = any(SystemObjectClass c).getToStringMethod().getAnOverrider*()
)
}
override predicate isSink(DataFlow::Node sink) {
sink instanceof XSS::Sink
or
sink instanceof Email::Sink
}
}
from TaintTrackingConfiguration configuration, DataFlow::Node source, DataFlow::Node sink
where configuration.hasFlow(source, sink)
select sink, "Sensitive information from $@ flows to here, and is transmitted to the user.", source, source.toString()