False positive: Insecure Direct Object Reference (cs/web/insecure-direct-object-reference) and Missing function level access control (cs/web/missing-function-level-access-control)
- 主要語言
- CodeQL
- 星號
- 10.1k
- 分支
- 2.1k
- 平均合併
- 2 天 15 小時
- 30 天內合併 PR
- 141
描述
**Description of the false positive**
In a C# project, we have dozens of potential false positives for "Insecure Direct Object Reference (cs/web/insecure-direct-object-reference)" and "Missing function level access control (cs/web/missing-function-level-access-control)" due to the custom authorization that we use via an attribute. Please see the code example below.
What would you suggest as a mitigation in this situation?
**Code samples or links to source code**
```
[Function(Functions.Event.Add)]
public void PublicFunction() {
Function1();
}
private void Function1() {
Function2();
}
private void Function2(id) {
// load object id <= Insecure Direct Object Reference (cs/web/insecure-direct-object-reference)
}
```
where the `[Function]` attribute takes the user's identity and looks if it is authorized for a specific system function. This checks for both authentication and authorization.
The "Missing function level access control (cs/web/missing-function-level-access-control)" is often reported directly on the function declaration:
```
[Function(Functions = new[] { Functions.Location.Edit })]
public async Task Edit(string name) // <= scanner reports insecure function
```
貢獻指南
研究方向
Start with the cs/web/insecure-direct-object-reference and cs/web/missing-function-level-access-control query entry points, then compare their findings with the [Function] attribute examples in this issue. A useful outcome would be a maintainer-approved mitigation or a clearly scoped query change that accounts for the custom authentication and authorization checks.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp
- 領域
- security
- Issue 類型
- 缺陷
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100