Explorar o código

p2p: verify protocol handshake node ID

Felix Lange %!s(int64=10) %!d(string=hai) anos
pai
achega
21649100b1
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      p2p/handshake.go

+ 3 - 0
p2p/handshake.go

@@ -89,6 +89,9 @@ func setupInboundConn(fd net.Conn, prv *ecdsa.PrivateKey, our *protoHandshake) (
 	if err != nil {
 		return nil, err
 	}
+	if rhs.ID != secrets.RemoteID {
+		return nil, errors.New("node ID in protocol handshake does not match encryption handshake")
+	}
 	// TODO: validate that handshake node ID matches
 	if err := writeProtocolHandshake(rw, our); err != nil {
 		return nil, fmt.Errorf("protocol write error: %v", err)