cloud-barista / cb-tumblebug

Cloud-Barista Multi-Cloud Infra Management Framework
Apache License 2.0
56 stars 51 forks source link

Fix code scanning alert no. 507: Use of insecure HostKeyCallback implementation #1853

Open seokho-son opened 1 month ago

seokho-son commented 1 month ago

Fixes https://github.com/cloud-barista/cb-tumblebug/security/code-scanning/507

To fix the problem, we need to replace the insecure HostKeyCallback implementation with a secure one. The best way to do this is to use the ssh.FixedHostKey function, which validates the host key against a predefined allow list. This involves reading the allowed host key from a file and using it to create the ssh.ClientConfig.

  1. Read the allowed host key from a file.
  2. Parse the host key using ssh.ParsePublicKey.
  3. Use the parsed key with ssh.FixedHostKey to set the HostKeyCallback field in ssh.ClientConfig.

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