github / github/codeql

Taint Tracking to a LocalVariable

未关闭
#16,438 2 条评论 0 个 reaction 已指派 1 人 已被 @MathiasVP 认领 在 GitHub 查看
C++ question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

Hello,

I'm trying my query on a simple code before moving to my main codebase. Basically, I would like to track all the local taints from all the function arguments to the LocalVariables in that function. This is the simplest version but eventually I want to find all such taints that are coming from an assignment in a loop.

Here's my simple C code:

```
#include
#include

void call1(char* in) {
char buff[10];
char a;
a = in[3];
for (int i = 0; i < 10; i++) {
buff[i] = in[i];
}
printf("%s\n", buff);
}

int main() {
char *input = "Hello!!!!";
call1(input);
return 0;
}
```
Here's my simple CodeQL query:
```
from DataFlow::Node source, DataFlow::Node sink, LocalVariable lv, Function f
where
f.getAParameter() = source.asParameter() and
lv.getAnAccess() = sink.asExpr() and
lv.getFunction() = f and
TaintTracking::localTaint(source, sink)
select source, sink
```
I want to find the following taints:
in -> buff, in -> a

For now the query returns nothing. But if I comment the `TaintTracking::localTaint(source, sink)` line it would return the following:
```
Result set: edges
| a | b |
+---+---+

Result set: nodes
| n | key | val |
+---+-----+-----+

Result set: subpaths
| arg | par | ret | out |
+-----+-----+-----+-----+

Result set: #select
| source | sink |
+--------+------+
| in | a |
| in | i |
| in | i |
| in | buff |
| in | i |
| in | i |
| in | buff |
```
I'm not really sure why this happens and if I should probably define an additional taint step. I'd appreciate any help.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。