github / github/codeql

Java: static field access of unknown class breaks dataflow (build-mode=none)

未关闭
#19,597 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

This is another issue we encountered when analysing databases created with `build-mode=none`.
It appears that dataflow graphs are broken when static fields are accessed on unknown classes.
Please take a look [codeql_issue2.zip](https://github.com/user-attachments/files/20458091/codeql_issue2.zip) for more information.

Here is the example java code:
```
// This import is from a dependency that is not resolved
import com.foo.mycompany.UnknownClass;

public class DataFlowNotConnected {
static class MyClass {
public static String staticField = "static";
}

private int run() {
// data source 1 should flow to sink e and f, but dataflow is broken by UnknownClass.staticField
int a = 1;
int b = a;

// static class field access from known class
String staticField1 = MyClass.staticField;

int c = b;
int d = c;

// static class field access from unknown class breaks dataflow
String staticField2 = UnknownClass.staticField;

int e = d;
int f = e;

return f;
}
}
```

贡献指南

打开贡献指南

调研方向

Start by reproducing the example from codeql_issue2.zip with build-mode=none, focusing on the Java dataflow graph around UnknownClass.staticField. Compare the graph with and without that static access; done means the flow from a through d remains connected to sinks e and f.

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
devtools, security
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

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