[False Negative/Question] Taint steps added by `isAdditionalFlowStep` ignore tainted content

未关闭
#22,596 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
领域
devtools, security

调研方向

从 isAdditionalFlowStep 谓词开始,将其行为与 CodeQL 数据流文档中的流摘要进行比较。复现 Go Container 示例,并确定嵌套的 tainted 内容是否是有意排除的,还是应该支持。行为和理由得到澄清,并且有记录或已实现的解决方案,即表示完成。

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

描述

question

When modelling a gRPC library in Go, I noticed that steps added to global taint tracking via the isAdditionalFlowStep predicate do not cover cases where the object passed to the step has tainted content, but is not considered tainted itself.

Example code for the issue below:

type Container = struct{ Value int }

func link_in(Container) {
	// magic CodeQL does not understand
}

func link_out() Container {
	// more magic
	// returns the argument of link_in
	panic(0)
}

func main() {
	a := Container{Value: taint()}

	link_in(a)
	a_ := link_out()

	sink(a_.Value)
}

The link_in and link_out functions represent two places that pass data between them, but which CodeQL does not connect out of the box. Adding an additional flow step to establish this connection will only work if we consider the entire Container struct to be tainted; the taint on Container.Value in the example above is ignored.

After experimenting a bit, this behaviour seems consistent across different languages, which leads me to believe it was an intentional decision. However, I do not fully understand the reasoning behind it. Many libraries wrap their data in some kind of container (for example, the code emitted by the Go gRPC tooling generates custom structs for the message types in the protobuf), and the mechanisms provided by flow summaries are not always sufficient to model this (The above example can be solved by introducing a write/read to a synthetic global variable unique to this function pair, however that only works if the functions with this special behaviour are known in advance).

Since flow summaries can handle tainted content, would it be possible to do the same for isAdditionalFlowStep? Dropping the taint to the level of the entire containing struct is not always a worthwhile option, so this mechanism would be very helpful when modelling more complex library behaviour.

If this is a deliberate design decision, I feel like it should be mentioned in the data-flow tutorial.

主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 11 小时
30 天内合并 PR
129

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/codeql 的其他 Issue

查看 github/codeql 的全部 Issue

相似的 Issue

更多 DevTools Issue

把新 issue 发到你的邮箱

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