Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit d0e86f7

Browse files
committed
SSH host checking: Expand definition of a host-key checking function to include calls with multiple return types
For example, https://godoc.org/golang.org/x/crypto/ssh/knownhosts#New returns a host-key checker and an error value, and we previously didn't consider the first return value a candidate checker function.
1 parent f162a5b commit d0e86f7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ql/src/Security/CWE-322/InsecureHostKeyCallback.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ class HostKeyCallbackFunc extends DataFlow::Node {
3131
(
3232
this instanceof DataFlow::FunctionNode
3333
or
34-
this instanceof DataFlow::CallNode and
35-
not exists(this.(DataFlow::CallNode).getACallee().getBody())
34+
exists(DataFlow::CallNode call | not exists(call.getACallee().getBody()) |
35+
this = call.getAResult()
36+
)
3637
)
3738
}
3839
}
@@ -41,7 +42,7 @@ class HostKeyCallbackFunc extends DataFlow::Node {
4142
class InsecureHostKeyCallbackFunc extends HostKeyCallbackFunc {
4243
InsecureHostKeyCallbackFunc() {
4344
// Either a call to InsecureIgnoreHostKey(), which we know returns an insecure callback.
44-
this = any(InsecureIgnoreHostKey f).getACall()
45+
this = any(InsecureIgnoreHostKey f).getACall().getAResult()
4546
or
4647
// Or a callback function in the source code (named or anonymous) that always returns nil.
4748
forex(DataFlow::ResultNode returnValue |

0 commit comments

Comments
 (0)