hyperledger-labs / go-perun

🌔 Perun's Blockchain-Agnostic State Channels Framework in Go.
https://perun.network/
Apache License 2.0
55 stars 18 forks source link

Add authentication to wire commmunication (handshake) #381

Open DragonDev1906 opened 1 year ago

DragonDev1906 commented 1 year ago

Location

Problem

Sender not authenticated

While each message currently contains a sender and recipient wire address in its Envelope, those are not yet authenticated, there is no signature in wire.proto. This means anyone can send a message coming from SENDER, without needing the private key, thus allowing to spoof any wire identity.

No TLS

As far as I can tell we're currently using TCP without TLS for the communication. This means that, even when there is a signature in the handshake message (AuthResponseMsg), an Adversary could eavesdrop the communication channel and use the AuthResponseMsg in his own session, thus stealing the wire identity. He could not send updates to the existing channel since he doesn't have the private key for the channel identity, but he could propose new channels (at least they (probably) won't be funded), but it still locks up some resources (time, computation, storage and ETH) for some time while waiting for the channel to be funded.

Proposal (all three are likely needed)

matthiasgeihs commented 1 year ago

It should be possible to implement a wire adapter that provides authentication. AFAIR, there is an implementation that utilizes libp2p to achieve encryption and authentication. @tinnendo should be able to point you to it.

RmbRT commented 1 year ago

You can send arbitrary Envelopes over any connection and afaik, there is no check that would bind a single connection to a single sender. Neither the wire/net.Bus nor the wire/net.ioConn check for the Sender field of the envelopes, and all received envelopes get multiplexed over a central wire.Publisher.