Skip to content

Commit 2b28deb

Browse files
committed
Rust: Do not use types to limit lifting of reads to taint steps
1 parent c362d2f commit 2b28deb

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

rust/ql/lib/codeql/rust/dataflow/internal/TaintTrackingImpl.qll

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ private import codeql.rust.frameworks.stdlib.Builtins as Builtins
1818
*/
1919
extensible predicate excludeFieldTaintStep(string field);
2020

21+
/**
22+
* Holds if the content `c` corresponds to a field that has explicitly been
23+
* excluded as a taint step.
24+
*/
2125
private predicate excludedTaintStepContent(Content c) {
2226
exists(string arg | excludeFieldTaintStep(arg) |
2327
FlowSummaryImpl::encodeContentStructField(c, arg) or
@@ -59,19 +63,9 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> {
5963
or
6064
// Read steps give rise to taint steps. This has the effect that if `foo`
6165
// is tainted and an operation reads from `foo` (e.g., `foo.bar`) then
62-
// taint is propagated. We limit this to not apply if the type of the
63-
// operation is a small primitive type as these are often uninteresting
64-
// (for instance in the case of an injection query).
66+
// taint is propagated.
6567
exists(Content c |
6668
RustDataFlow::readContentStep(pred, c, succ) and
67-
forex(Type::Type t | t = TypeInference::inferType(succ.asExpr()) |
68-
not exists(Struct s | s = t.(Type::StructType).getStruct() |
69-
s instanceof Builtins::NumericType or
70-
s instanceof Builtins::Bool or
71-
s instanceof Builtins::Char
72-
) and
73-
not t.(Type::EnumType).getEnum().isFieldless()
74-
) and
7569
not excludedTaintStepContent(c)
7670
)
7771
or

0 commit comments

Comments
 (0)