-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.ql
29 lines (27 loc) · 982 Bytes
/
query.ql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @name DTrace Out-of-bounds Read
* @description DTrace uses user-controllable value as list index.
* @kind problem
* @problem.severity warning
* @id apple-xnu/cpp/dtrace-unsafe-index-cve-2023-28200
*/
import cpp
from Variable arg, ArrayExpr ae
where
exists(LTExpr le |
le.getLeftOperand() = arg.getAnAccess() and
le.getParent() instanceof IfStmt and
le.getLeftOperand().getExplicitlyConverted().getUnderlyingType().(IntegralType).isSigned()
) and
not exists(RelationalOperation ro |
ro.getLeftOperand() = arg.getAnAccess() and
ro.getParent() instanceof ForStmt
) and
not exists(RelationalOperation ro |
ro.getLeftOperand() = arg.getAnAccess() and
ro.getRightOperand().getValue() = "0"
) and
ae.getArrayOffset() = arg.getAnAccess() and
ae.getFile().getAbsolutePath().matches("%/xnu-build/xnu/%") and
not ae.getFile().getAbsolutePath().matches("%/xnu-build/xnu/SETUP/%")
select ae.getArrayOffset(), ae.getEnclosingFunction()