Skip to content

Commit c9fadd9

Browse files
committed
Support CommandInjectionAdditionalFlowStep and fix doc errors
1 parent d7d9ffc commit c9fadd9

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

swift/ql/lib/codeql/swift/security/CommandInjectionExtensions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ private class ProcessSink extends CommandInjectionSink instanceof DataFlow::Node
6262
* A sink defined in a CSV model.
6363
*/
6464
private class DefaultCommandInjectionSink extends CommandInjectionSink {
65-
DefaultCommandInjectionSink() { sinkNode(this, "command-line-injection") }
65+
DefaultCommandInjectionSink() { sinkNode(this, "command-injection") }
6666
}

swift/ql/lib/codeql/swift/security/CommandInjectionQuery.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ module CommandInjectionConfig implements DataFlow::ConfigSig {
1919
predicate isSink(DataFlow::Node node) { node instanceof CommandInjectionSink }
2020

2121
predicate isBarrier(DataFlow::Node barrier) { barrier instanceof CommandInjectionBarrier }
22+
23+
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
24+
any(CommandInjectionAdditionalFlowStep s).step(nodeFrom, nodeTo)
25+
}
2226
}
2327

2428
/**

swift/ql/src/queries/Security/CWE-078/CommandInjection.qhelp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<overview>
77
<p>
88
Constructing a system command with unsanitized user input is dangerous,
9-
since a malicious user to execute code.
9+
since a malicious user may be able to craft input that executes arbitrary code.
1010
</p>
1111
</overview>
1212

@@ -29,7 +29,7 @@ sanitizing it first:
2929
</p>
3030
<sample src="CommandInjectionBad.swift" />
3131
<p>
32-
If user input is used to construct a regular expression it should be checked
32+
If user input is used to construct a command it should be checked
3333
first. This ensures that the user cannot insert characters that have special
3434
meanings.
3535
</p>

swift/ql/src/queries/Security/CWE-078/CommandInjection.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @id swift/command-line-injection
99
* @tags security
1010
* external/cwe/cwe-078
11+
* external/cwe/cwe-088
1112
*/
1213

1314
import swift

0 commit comments

Comments
 (0)