X Tutup
The Wayback Machine - https://web.archive.org/web/20260305001223/https://github.com/github/codeql-go/pull/261
Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Polish CWE-322: detect and exclude cases where host-checking is optional#261

Merged
max-schaefer merged 4 commits intogithub:masterfrom
smowton:smowton/admin/cleanup-cwe-322
Jul 30, 2020
Merged

Polish CWE-322: detect and exclude cases where host-checking is optional#261
max-schaefer merged 4 commits intogithub:masterfrom
smowton:smowton/admin/cleanup-cwe-322

Conversation

@smowton
Copy link
Contributor

@smowton smowton commented Jul 17, 2020

No description provided.

@smowton smowton requested a review from a team July 17, 2020 15:27
Copy link
Contributor

@owen-mc owen-mc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good, except CI failing

Copy link
Contributor

@intrigus-lgtm intrigus-lgtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some minor things for which I'll add suggestions soon.

}

/**
* Identifies HostKeyCallbackFunc instances that reach CoientConfig.HostKeyCallback fields.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Identifies HostKeyCallbackFunc instances that reach CoientConfig.HostKeyCallback fields.
* Identifies `HostKeyCallbackFunc` instances that reach `ClientConfig.HostKeyCallback` fields.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I vaguely remember thinking "Coient - what a weird word" as I read that. I didn't realise it was a typo! 😆

import go
import DataFlow::PathGraph

/** ssh.InsecureIgnoreHostKey, which allows connecting to any host regardless of its host key. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** ssh.InsecureIgnoreHostKey, which allows connecting to any host regardless of its host key. */
/** The `ssh.InsecureIgnoreHostKey` function, which allows connecting to any host regardless of its host key. */

@smowton smowton force-pushed the smowton/admin/cleanup-cwe-322 branch 2 times, most recently from a13a1f7 to 5101933 Compare July 20, 2020 15:45
Copy link
Contributor

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit, otherwise LGTM. Is it intentional that this is still in experimental? If we want to move it out of there, we'll need to evaluate performance.

}

/**
* Identifies HostKeyCallbackFunc instances that reach `ClientConfig.HostKeyCallback` fields.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Identifies HostKeyCallbackFunc instances that reach `ClientConfig.HostKeyCallback` fields.
* A data-flow configuration for identifying `HostKeyCallbackFunc` instances that reach `ClientConfig.HostKeyCallback` fields.

@smowton smowton force-pushed the smowton/admin/cleanup-cwe-322 branch from 5101933 to 1981e86 Compare July 28, 2020 14:44
@smowton
Copy link
Contributor Author

smowton commented Jul 28, 2020

@max-schaefer amended and promoted out of experimental status. Also did the same to CWE-327.

Copy link
Contributor

@max-schaefer max-schaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more minor things. I can't quite tell from the diff whether you added a test for the newly added logic to detect optional host checks?

Once the performance evaluation is in, this should be good to merge.

* @name Use of insecure HostKeyCallback implementation
* @description Detects insecure SSL client configurations with an implementation of the `HostKeyCallback` that accepts all host keys.
* @kind path-problem
* @problem.severity error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a @precision now.

// Either a call to InsecureIgnoreHostKey(), which we know returns an insecure callback.
this = any(InsecureIgnoreHostKey f).getACall()
or
// Or a callback function in the source code (named or anonymous) that always returns nil.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Or a callback function in the source code (named or anonymous) that always returns nil.
// Or a callback function in the source code (named or anonymous) that always returns nil.

@smowton smowton force-pushed the smowton/admin/cleanup-cwe-322 branch from 1981e86 to 0a6239f Compare July 29, 2020 13:23
@smowton
Copy link
Contributor Author

smowton commented Jul 29, 2020

@max-schaefer all suggestions applied, and re: the test it already covered one case but not another, which I've added. It also turned out I'd partly broken the test without noticing :/ the results are now as expected, and I'm rerunning the LGTM tests to check if that's had any unexpected impact.

@smowton smowton force-pushed the smowton/admin/cleanup-cwe-322 branch from f611221 to 3fabd2e Compare July 29, 2020 13:40
@smowton
Copy link
Contributor Author

smowton commented Jul 29, 2020

Btw if you look at the diff commit-by-commit you get a much nicer diff than the whole thing piled together

@smowton smowton force-pushed the smowton/admin/cleanup-cwe-322 branch from 3fabd2e to f162a5b Compare July 29, 2020 13:43
smowton added 2 commits July 29, 2020 16:06
…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.
This produces a secure host-key checker; we assume by default that an opaque function not otherwise specified returns an acceptable checker, but we need to particularly cope with its multiple return values to handle this factory function.
@max-schaefer max-schaefer merged commit 2134757 into github:master Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup