Improve host key verification
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by tracing MakeConfig into crypto/ssh ClientConfig and reviewing how fingerprint verification is wired to the host-key callback. Compare the available HostKeyAlgorithms configuration and FixedHostKey callback options; done means callers can constrain host-key selection or verify the full public key without relying on changing defaults.
Written by the indexing model from the issue text.
Description
Currently host key verification is done by checking if the host key fingerprint matches the expected one. This has a flaw in that it assumes that the server host key type will always be the one we are expecting. Servers can have multiple different host keys of different types. The host key selection is done based on the SSH protocol specification, from RFC4253 section 7.1:
server_host_key_algorithms
A name-list of the algorithms supported for the server host
key. The server lists the algorithms for which it has host
keys; the client lists the algorithms that it is willing to
accept. There MAY be multiple host keys for a host, possibly
with different algorithms.
Some host keys may not support both signatures and encryption
(this can be determined from the algorithm), and thus not all
host keys are valid for all key exchange methods.
Algorithm selection depends on whether the chosen key exchange
algorithm requires a signature or an encryption-capable host
key. It MUST be possible to determine this from the public key
algorithm name. The first algorithm on the client's name-list
that satisfies the requirements and is also supported by the
server MUST be chosen. If there is no such algorithm, both
sides MUST disconnect.
This means that the client can choose which host key will be selected based on the sorted list of host key algorithms it sends to the server. This is also described here: https://www.bitvise.com/ssh-server-guide-host-keys
crypto/ssh has a way to set this list in ClientConfig:
// HostKeyAlgorithms lists the key types that the client will
// accept from the server as host key, in order of
// preference. If empty, a reasonable default is used. Any
// string returned from PublicKey.Type method may be used, or
// any of the CertAlgoXxxx and KeyAlgoXxxx constants.
HostKeyAlgorithms []string
easyssh doesn't set this list so it relies on crypto/ssh defaults which may change in the future. This means a crypto/ssh version update may break existing programs that use easyssh with fingerprint verification.
An easy improvement would be to allow specifying this list via MakeConfig. "Any string returned from PublicKey.Type method may be used", these are probably constant. Thus the host key type would always be guaranteed to match the key fingerprint.
Another improvement would be to be able to use func FixedHostKey as HostKeyCallback to allow specifying the full host public key to verify, not just the fingerprint, which would also be more secure.
- Dominant language
- Go
- Stars
- 349
- Forks
- 64
- Avg merge
- 2h 29m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from appleboy/easyssh-proxy
-
ReadFile or ScpGetOpen
Difficulty 4/5 3-5 days Newbie friendliness 42/100
appleboy/easyssh-proxy#100 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
appleboy/easyssh-proxy#92 ·
-
Is that a way to close proxyClient when using a connection with proxy?Possibly taken @appleboy claimed this 360 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
appleboy/easyssh-proxy#88 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
appleboy/easyssh-proxy#71 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
appleboy/easyssh-proxy#69 · 1 comment ·
All issues in appleboy/easyssh-proxy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
golang/go#82033 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
FootprintAI/Containarium#2338 ·
Maintainers usually reply within 1 day
-
[Bug]: core doesn't build standalone on dev since a17068054 (go-mp3 require dropped, go.sum pruned)Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
SagerNet/sing-openvpn#11 ·
-
priority: P3 type: devops
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jiegui2025/hwspec#57 ·
Maintainers usually reply within 1 day