ecdsa-sha2-nistp521 Signature verification failed
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.8k
- Forks
- 734
- PR merge metrics
- No merged PRs in 30d
Description
I tried to connect to the switch, but encountered a signature verification error. By adjusting the DEFAULT_SERVER_HOST_KEY constant and moving the ecdsa-sha2-nistp521 algorithm to the end, I was able to pass the verification. It seems that there is an issue with the verification step for the ecdsa-sha2-nistp521 algorithm? Additionally, I also noticed two other issues where connection attempts to Huawei switches failed verification, and similarly, the failures occurred when the ecdsa-sha2-nistp521 algorithm was matched. I used Terminus to connect to this switch, and the verification passed, also using ecdsa-sha2-nistp521.
#925
#904
Custom crypto binding not available
Local ident: 'SSH-2.0-ssh2js1.16.0'
Client: Trying x.xx.xx.xxx on port xxx ...
Socket connected
Remote ident: 'SSH-2.0--'
Outbound: Sending KEXINIT
Inbound: Handshake in progress
Handshake: (local) KEX method: curve25519-sha256@libssh.org,curve25519-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group15-sha512,diffie-hellman-group16-sha512,diffie-hellman-group17-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,ext-info-c,kex-strict-c-v00@openssh.com
Handshake: (remote) KEX method: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
Handshake: KEX algorithm: diffie-hellman-group-exchange-sha1
Handshake: (local) Host key format: ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa
Handshake: (remote) Host key format: ecdsa-sha2-nistp521,ssh-dss,ssh-rsa
Handshake: Host key format: ecdsa-sha2-nistp521
Handshake: (local) C->S cipher: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
Handshake: (remote) C->S cipher: aes256-ctr,aes128-ctr,aes256-cbc,aes128-cbc,3des-cbc
Handshake: C->S Cipher: aes128-ctr
Handshake: (local) S->C cipher: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
Handshake: (remote) S->C cipher: aes256-ctr,aes128-ctr,aes256-cbc,aes128-cbc,3des-cbc
Handshake: S->C cipher: aes128-ctr
Handshake: (local) C->S MAC: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
Handshake: (remote) C->S MAC: hmac-sha2-256,hmac-sha2-256-96,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96
Handshake: C->S MAC: hmac-sha2-256
Handshake: (local) S->C MAC: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
Handshake: (remote) S->C MAC: hmac-sha2-256,hmac-sha2-256-96,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96
Handshake: S->C MAC: hmac-sha2-256
Handshake: (local) C->S compression: zlib@openssh.com,zlib
Handshake: (remote) C->S compression: none,zlib
Handshake: C->S compression: zlib
Handshake: (local) S->C compression: zlib@openssh.com,zlib
Handshake: (remote) S->C compression: none,zlib
Handshake: S->C compression: zlib
Outbound: Sending KEXDH_GEX_REQUEST
Received DH GEX Group
Outbound: Sending KEXDH_GEX_INIT
Received DH GEX Reply
Received DH Reply
Host accepted by default (no verification)
Host accepted (verified)
Outbound: Sending NEWKEYS
Inbound: NEWKEYS
Verifying signature ...
Signature verification failed
Outbound: Sending DISCONNECT (3)
Uncaught Error Error: Handshake failed: signature verification failed
at makeError (/xx/ssh2/lib/protocol/utils.js:142:15)
at doFatalError (/xx/ssh2/lib/protocol/utils.js:184:13)
at finish (/xx/ssh2/lib/protocol/kex.js:709:18)
at parse (/xx/ssh2/lib/protocol/kex.js:1267:23)
at onKEXPayload (/xx/ssh2/lib/protocol/kex.js:1828:20)
at decrypt (/xx/ssh2/lib/protocol/crypto.js:612:26)
at parsePacket (/xx/ssh2/lib/protocol/Protocol.js:2028:25)
at parse (/xx/ssh2/lib/protocol/Protocol.js:313:16)
. ..
Process exited with code 1
Terminus Logs:
👤 Starting a new connection to: "xxx" port "xxx"
⚙️ Address resolution finished
⚙️ Starting SSH session
⚙️ Remote server: SSH-2.0--
⚙️ Agreed KEX algorithm: diffie-hellman-group14-sha1
⚙️ Agreed Host Key algorithm: ecdsa-sha2-nistp521
⚙️ Agreed server-to-client cipher: aes256-ctr MAC: hmac-sha2-256
⚙️ Agreed client-to-server cipher: aes256-ctr MAC: hmac-sha2-256
⚙️ Agreed client-to-server compression: none
⚙️ Agreed server-to-client compression: none
⚙️ Handshake finished
👤 Checking host key: SHA256:c+YEbnDPsGL5tJBUQRn05uZBg2v4Q/Zj9UggaxvabBg
❗ Host xx is unknown
👤 Connection to "xx accepted
👤 Authenticating to xx as "xx"
In the other two cases, the issue could be circumvented by adjusting the algorithm, but my algorithm may need to connect to many devices. I'm not sure if this is a general problem. Are there any better solutions to address this?
node version: v24.12.0 ,I don't think Node is the culprit here. It's likely something else.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start in lib/protocol/kex.js at the signature verification path shown in the stack trace, then trace the related cryptographic handling through lib/protocol/crypto.js and lib/protocol/Protocol.js. Reproduce the ecdsa-sha2-nistp521 handshake with the reported server behavior and determine why verification fails; done means identifying a reliable fix that does not require moving the algorithm in DEFAULT_SERVER_HOST_KEY.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- networking, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100