|
| 1 | +/** |
| 2 | + * @name Cleartext transmission of sensitive information |
| 3 | + * @description Transmitting sensitive information across a network in |
| 4 | + * cleartext can expose it to an attacker. |
| 5 | + * @kind path-problem |
| 6 | + * @problem.severity warning |
| 7 | + * @security-severity 7.5 |
| 8 | + * @precision high |
| 9 | + * @id rust/cleartext-transmission |
| 10 | + * @tags security |
| 11 | + * external/cwe/cwe-319 |
| 12 | + */ |
| 13 | + |
| 14 | +import rust |
| 15 | +import codeql.rust.dataflow.DataFlow |
| 16 | +import codeql.rust.security.SensitiveData |
| 17 | +import codeql.rust.dataflow.TaintTracking |
| 18 | +import codeql.rust.security.CleartextTransmissionExtensions |
| 19 | + |
| 20 | +/** |
| 21 | + * A taint configuration from sensitive information to expressions that are |
| 22 | + * transmitted over a network. |
| 23 | + */ |
| 24 | +module CleartextTransmissionConfig implements DataFlow::ConfigSig { |
| 25 | + predicate isSource(DataFlow::Node node) { node instanceof SensitiveData } |
| 26 | + |
| 27 | + predicate isSink(DataFlow::Node node) { node instanceof CleartextTransmissionSink } |
| 28 | + |
| 29 | + predicate isBarrier(DataFlow::Node barrier) { barrier instanceof CleartextTransmissionBarrier } |
| 30 | + |
| 31 | + predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { |
| 32 | + any(CleartextTransmissionAdditionalFlowStep s).step(nodeFrom, nodeTo) |
| 33 | + } |
| 34 | + |
| 35 | + predicate isBarrierIn(DataFlow::Node node) { |
| 36 | + // make sources barriers so that we only report the closest instance |
| 37 | + isSource(node) |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +module CleartextTransmissionFlow = TaintTracking::Global<CleartextTransmissionConfig>; |
| 42 | + |
| 43 | +import CleartextTransmissionFlow::PathGraph |
| 44 | + |
| 45 | +from CleartextTransmissionFlow::PathNode sourceNode, CleartextTransmissionFlow::PathNode sinkNode |
| 46 | +where CleartextTransmissionFlow::flowPath(sourceNode, sinkNode) |
| 47 | +select sinkNode.getNode(), sourceNode, sinkNode, |
| 48 | + "The operation '" + sinkNode.getNode().toString() + |
| 49 | + "', transmits data which may contain unencrypted sensitive data from $@.", sourceNode, |
| 50 | + sourceNode.getNode().toString() |
0 commit comments