Security and Encryption in Weave Net

July 18, 2017

Securing a network with full end-to-end encryption can be complicated and overlay networks add another level of difficulty. However, with Weave Net we’ve worked very hard to simplify the set-up process and make managing the whole thing as straightforward as possible.

Related posts

Multi-cluster Application Deployment Made Easy with GitOpsSets

Close the Cloud-Native Skills Gap and Use Automation to Boost Developer Productivity with Weave GitOps Release 2023.04

Create Safe Perimeter Boundaries for Development Teams with Workspaces

Weaveworks started by providing networking solutions for containers, in the form of Weave Net. Since then we’ve evolved to offer Weave Cloud - a commercial product providing a comprehensive set of capabilities for container continuous deployment, troubleshooting, monitoring, and security. Weave Cloud enhances and builds on several open source Weave projects, including Weave Net. 

Security is an important aspect of any product particularly one that is handling all the aspects of connecting and communicating between systems in a network. Weave Net has provides network security as follows:

Application Isolation

Users can create virtual networks for tenant isolation with Weave Net: in other words we can use it to separate different services onto different networks. Each virtual network has its own layer two broadcast domain. Virtual networks can talk to each other only when an IP address is assigned and traffic between the virtual networks can be routed. Weaveworks uses an “isolation-through-subnets” technique, which is covered in further detail in the Weaveworks docs.

Network Policy

Introduced in Weave Net 1.7, this feature is specific to Kubernetes. With the use of a Network Policy Controller, Weave Net is implemented as a Kubernetes Addon for controlling container traffic. 

Security

Weave Net users can enable encryption on traffic between nodes that are part of an overlay network. To enable this feature, you simply pass a password string using the password option:

    $ weave launch --password wfvAwt7sj

Get details about enabling encryption for Weave Net in this doc.

Weave Net’s ease of use and minimal configuration requirements are the product of our design philosophy. As our project page says, we strive to create strong, out-of-the-box security without a complex setup or the need to wade your way through the configuration of cipher suite negotiation, certificate generation or any of the other things needed to properly secure an IPsec or TLS installation.  

Weave Net employs a variety of encryption techniques to balance speed, convenience and security.  Asymmetric encryption is used to create the public-private key pair for the communication parties to derive a session key.  This session key is valid only for a single session. With the session key, another symmetric key is derived for encryption and decryption of data traffic. Weave Net appends other information to the session key to generate this symmetric key and needs to use a hashing algorithm, in this case SHA-256 to create a 32-bit/4 bytes symmetric key.

Sleeve mode vs Fast Datapath mode

Before looking into how encryption is done in Weave Net, we need to understand the different packet forwarding approaches in Weave Net. There are two approaches and starting from Weave Net version 1.2 the default mode is “Fast Datapath.” The other, which is the fallback mode, is called the “sleeve” mode.  Encryption is done differently in these two modes.

This documentation Using Fast Datapath has a detailed description of the two approaches for packet forwarding in Weave Net.

Ephemeral Session Key

Both packet forwarding approaches rely on the establishment of the Ephemeral Session Key.  This key is generated for each connection between each host for each session.

A simple way to look at Ephemeral Session Key is this formula:

Ephemeral Session Key  = Shared Key + Password

*where Password is user supplied when starting Weave Net.

A longer version of Ephemeral Session Key generation is:

  1. Create a public/private key pair at both ends with the NaCl library
  2. Public key is sent to the other end
  3. Public key from the remote + private key on local using Diffie-Hellman to generate the Shared Key (256 bit long), which is same and known to both ends.
  4. Shared Key + Password become the Ephemeral Session Key and is greater than 256 bits long, need to use SHA256 to reduce back to 256 bit long.

You can find a detailed version of Ephemeral Session Key generation here.

Since “Fast Datapath” is the default mode, let’s look at this first.  

Encryption in Fast Datapath mode

Fast Datapath builds on overlay technology and, in this case, VXLAN. Overlay technologies do not have encryption built in. Weave Net leverages the Encapsulating Security Payload (ESP) protocol suite of IPSec in transport mode to provide encryption of the data plane.  

Weave Net uses the Ephemeral Session Key for the AES-GCM to authenticate and encrypt the payload.

image00.png

Encryption in Sleeve mode

In this mode, TCP connections are used for topology information between peers and UDP connections are used for data traffic between peers.

The Ephemeral Session Key is derived the same way as the Fast Datapath mode.  The symmetric key used for encryption and decryption is the Ephemeral Session Key plus a nonce. A nonce is added to the Ephemeral Session Key for additional security against attacks such as Man-in-the-middle or message playback. The nonce chosen is the packet’s sequence number and the connection polarity.

Weave Net Security Summarized

Securing a network with full end-to-end encryption can be complicated and overlay networks add another level of difficulty. However, with Weave Net we’ve worked very hard to simplify the set-up process and make managing the whole thing as straightforward as possible. 


If you have questions about security and how to use Weave Net then check out our online user group for free talks and workshops about security and other microservices related topics. And as always, join the conversation on Slack at #weave-community.



Related posts

Multi-cluster Application Deployment Made Easy with GitOpsSets

Close the Cloud-Native Skills Gap and Use Automation to Boost Developer Productivity with Weave GitOps Release 2023.04

Create Safe Perimeter Boundaries for Development Teams with Workspaces