Skip to content

Commit 87e0b08

Browse files
authored
Merge branch 'main' into jb1/upstream-zipslip
2 parents 81f9e88 + 8cd58aa commit 87e0b08

22 files changed

+202
-60
lines changed

powershell/ql/lib/semmle/code/powershell/ast/internal/Raw/ChildIndex.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ newtype ChildIndex =
1414
CatchClauseBody() or
1515
CatchClauseType(int i) { exists(any(CatchClause c).getCatchType(i)) } or
1616
CmdElement_(int i) { exists(any(Cmd cmd).getElement(i)) } or // TODO: Get rid of this?
17+
CmdParameterExpr() or
1718
CmdCallee() or
1819
CmdRedirection(int i) { exists(any(Cmd cmd).getRedirection(i)) } or
1920
CmdExprExpr() or
@@ -127,6 +128,8 @@ string stringOfChildIndex(ChildIndex i) {
127128
or
128129
i = CmdElement_(_) and result = "CmdElement"
129130
or
131+
i = CmdParameterExpr() and result = "CmdParameterExpr"
132+
or
130133
i = CmdCallee() and result = "CmdCallee"
131134
or
132135
i = CmdRedirection(_) and result = "CmdRedirection"

powershell/ql/lib/semmle/code/powershell/ast/internal/Raw/CommandParameter.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ class CmdParameter extends @command_parameter, CmdElement {
55

66
string getName() { command_parameter(this, result) }
77

8-
Ast getExpr() {
9-
command_parameter_argument(this, result)
8+
Ast getExpr() { command_parameter_argument(this, result) }
9+
10+
final override Ast getChild(ChildIndex i) {
11+
i instanceof CmdParameterExpr and
12+
result = this.getExpr()
1013
}
1114

1215
Cmd getCmd() { result.getElement(_) = this }

powershell/ql/lib/semmle/code/powershell/dataflow/internal/TaintTrackingPublic.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ predicate localTaint(DataFlow::Node source, DataFlow::Node sink) { localTaintSte
1515
* local (intra-procedural) steps.
1616
*/
1717
pragma[inline]
18-
predicate localExprTaint(CfgNodes::ExprCfgNode e1, CfgNodes::ExprCfgNode e2) { none() }
18+
predicate localExprTaint(CfgNodes::ExprCfgNode e1, CfgNodes::ExprCfgNode e2) {
19+
localTaintStep*(DataFlow::exprNode(e1), DataFlow::exprNode(e2))
20+
}
1921

2022
predicate localTaintStep = localTaintStepCached/2;

powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.PowerShell.Utility.model.yml renamed to powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.PowerShell.model.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ extensions:
66
- ["microsoft.powershell.utility!", "Method[read-host].ReturnValue", "stdin"]
77
- ["microsoft.powershell.utility!", "Method[select-xml].ReturnValue[path]", "file"]
88
- ["microsoft.powershell.utility!", "Method[format-hex].ReturnValue[path]", "file"]
9+
- ["microsoft.powershell.utility!", "Method[invoke-webrequest].ReturnValue", "remote"]
10+
- ["microsoft.powershell.utility!", "Method[iwr].ReturnValue", "remote"]
11+
- ["microsoft.powershell.utility!", "Method[wget].ReturnValue", "remote"]
12+
- ["microsoft.powershell.utility!", "Method[curl].ReturnValue", "remote"]
13+
- ["microsoft.powershell.utility!", "Method[invoke-restmethod].ReturnValue", "remote"]
14+
- ["microsoft.powershell.utility!", "Method[irm].ReturnValue", "remote"]
915

1016
- addsTo:
1117
pack: microsoft/powershell-all

powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.Win32.RegistryKey.model.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

powershell/ql/lib/semmle/code/powershell/frameworks/System.Management.Automation.Language.model.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
extensions:
2+
- addsTo:
3+
pack: microsoft/powershell-all
4+
extensible: summaryModel
5+
data:
6+
- ["system.management.automation.language.codegeneration!", "Method[escapesinglequotedstringcontent]", "Argument[0]", "ReturnValue", "taint"]
7+
28
- addsTo:
39
pack: microsoft/powershell-all
410
extensible: sinkModel

powershell/ql/lib/semmle/code/powershell/frameworks/System.Net.Sockets.model.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
extensions:
2+
- addsTo:
3+
pack: microsoft/powershell-all
4+
extensible: sourceModel
5+
data:
6+
- ["system.net.sockets.tcpclient", "Method[getstream].ReturnValue", "remote"]
7+
- ["system.net.sockets.udpclient", "Method[endreceive].ReturnValue", "remote"]
8+
- ["system.net.sockets.udpclient", "Method[receive].ReturnValue", "remote"]
9+
- ["system.net.sockets.udpclient", "Method[receiveasync].ReturnValue", "remote"]
10+
- ["system.net.webclient", "Method[downloaddata].ReturnValue", "remote"]
11+
- ["system.net.webclient", "Method[downloaddataasync].ReturnValue", "remote"]
12+
- ["system.net.webclient", "Method[downloaddatataskasync].ReturnValue", "remote"]
13+
- ["system.net.webclient", "Method[downloadfile].ReturnValue", "remote"]
14+
- ["system.net.webclient", "Method[downloadfileasync].ReturnValue", "remote"]
15+
- ["system.net.webclient", "Method[downloadfiletaskasync].ReturnValue", "remote"]
16+
- ["system.net.webclient", "Method[downloadstring].ReturnValue", "remote"]
17+
- ["system.net.webclient", "Method[downloadstringasync].ReturnValue", "remote"]
18+
- ["system.net.webclient", "Method[downloadstringtaskasync].ReturnValue", "remote"]

powershell/ql/lib/semmle/code/powershell/security/CommandInjectionCustomizations.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ module CommandInjection {
142142
class InvokeSink extends Sink {
143143
InvokeSink() {
144144
exists(InvokeMemberExpr ie |
145-
this.asExpr().getExpr() = ie.getCallee() or
146-
this.asExpr().getExpr() = ie.getQualifier().getAChild*()
145+
this.asExpr().getExpr() = ie.getCallee()
146+
or
147+
ie.getAName() = "Invoke" and
148+
ie.getQualifier().(MemberExprReadAccess).getMemberExpr() = this.asExpr().getExpr()
147149
)
148150
}
149151

0 commit comments

Comments
 (0)