Skip to content

Potential fix for code scanning alert no. 2388: Use of insecure HostKeyCallback implementation - #6249

Draft
eriknordmark wants to merge 1 commit into
masterfrom
alert-autofix-2388
Draft

Potential fix for code scanning alert no. 2388: Use of insecure HostKeyCallback implementation#6249
eriknordmark wants to merge 1 commit into
masterfrom
alert-autofix-2388

Conversation

@eriknordmark

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/lf-edge/eve/security/code-scanning/2388

Use a validating host key callback instead of ssh.InsecureIgnoreHostKey(). The best minimal, functionality-preserving fix here is to verify against the user’s known_hosts file using knownhosts.New(...) from golang.org/x/crypto/ssh/knownhosts. This keeps behavior aligned with standard SSH trust-on-first-use / pinned-known-host workflows and avoids introducing custom key parsing logic.

In evetest/ssh.go, inside runScriptOverSSH, replace insecure callback initialization with:

  1. Build known_hosts path (e.g., /root/.ssh/known_hosts for current environment consistency).
  2. Create callback via knownhosts.New(...).
  3. Return a clear error if callback cannot be initialized.
  4. Set HostKeyCallback to that callback in ssh.ClientConfig.

Also add the required import for golang.org/x/crypto/ssh/knownhosts.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…eyCallback implementation

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@milan-zededa

Copy link
Copy Markdown
Contributor

This is a test framework and we do not care about security between a test and an ephemeral test EVE VM. We should just dismiss this alert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants