feed password to weave via env var, possibly via a file
The latter is the most secure route since it keeps the password
completely out of any command lines, and the permissions on the file
can be very restrictive, e.g. 0400.
It would be somewhat nicer if the password file contained just
<password>
rather than
WEAVE_PASSWORD=<password>
but then we'd have to transit the password via a temporary file with
0600 permissions.
This commit is contained in:
1 parent
2386e75cc1
commit
e2ec460752
3 files changed
+35
-18
No files matched your search
+10
-2
@@ -129,11 +129,19 @@ sharing it between applications:
|
|||||||
### <a name="security"></a>Security
|
### <a name="security"></a>Security
|
||||||
|
|
||||||
In order to connect containers across untrusted networks, weave peers
|
In order to connect containers across untrusted networks, weave peers
|
||||||
can be told to encrypt traffic by supplying a `-password` option when
|
can be told to encrypt traffic by supplying a `-password` or
|
||||||
launching weave, e.g.
|
`-passwordfile` option when launching weave, e.g.
|
||||||
|
|
||||||
host1# weave launch -password wEaVe
|
host1# weave launch -password wEaVe
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
host1# weave launch -passwordfile /path/to/file
|
||||||
|
|
||||||
|
where the file must contain a single line like this:
|
||||||
|
|
||||||
|
WEAVE_PASSWORD=wEaVe
|
||||||
|
|
||||||
The same password must be specified for all weave peers; it is a
|
The same password must be specified for all weave peers; it is a
|
||||||
component in the creation of ephemeral session keys for connections
|
component in the creation of ephemeral session keys for connections
|
||||||
between peers. See the
|
between peers. See the
|
||||||
|
|||||||
+14
-14
@@ -117,27 +117,27 @@ poorly documented, and easily used wrongly.
|
|||||||
For every connection between peers, a fresh public/private key pair is
|
For every connection between peers, a fresh public/private key pair is
|
||||||
created at both ends, using NaCl's `GenerateKey` function. The public
|
created at both ends, using NaCl's `GenerateKey` function. The public
|
||||||
key portion is sent to the other end as part of the initial handshake
|
key portion is sent to the other end as part of the initial handshake
|
||||||
performed over TCP. Peers that were started with `-password` do not
|
performed over TCP. Peers that were started with a password do not
|
||||||
continue with connection establishment unless they receive a public
|
continue with connection establishment unless they receive a public
|
||||||
key from the remote peer. Thus either all peers in a weave network
|
key from the remote peer. Thus either all peers in a weave network
|
||||||
must be started with `-password`, or none of them.
|
must be supplied with a password, or none.
|
||||||
|
|
||||||
When a peer has received a public key from the remote peer, it uses
|
When a peer has received a public key from the remote peer, it uses
|
||||||
this to form the ephemeral session key for this connection. The public
|
this to form the ephemeral session key for this connection. The public
|
||||||
key from the remote peer is combined with the private key for the
|
key from the remote peer is combined with the private key for the
|
||||||
local peer in the usual Diffie-Hellman way, resulting in both peers
|
local peer in the usual Diffie-Hellman way, resulting in both peers
|
||||||
arriving at the same shared key. To this is appended the password from
|
arriving at the same shared key. To this is appended the supplied
|
||||||
the command line `-password` option, and the result is hashed through
|
password, and the result is hashed through SHA256, to form the final
|
||||||
SHA256, to form the final ephemeral session key. Thus the supplied
|
ephemeral session key. Thus the supplied password is never exchanged
|
||||||
password is never exchanged directly, and is thoroughly mixed into the
|
directly, and is thoroughly mixed into the shared secret. The shared
|
||||||
shared secret. The shared key formed by Diffie-Hellman is 256 bits
|
key formed by Diffie-Hellman is 256 bits long, appending the password
|
||||||
long, appending the password to this obviously makes it longer by an
|
to this obviously makes it longer by an unknown amount, and the use of
|
||||||
unknown amount, and the use of SHA256 reduces this back to 256 bits,
|
SHA256 reduces this back to 256 bits, to form the final ephemeral
|
||||||
to form the final ephemeral session key. This late combination with
|
session key. This late combination with the password eliminates "Man
|
||||||
the password eliminates "Man In The Middle" attacks: sniffing the
|
In The Middle" attacks: sniffing the public key exchange between the
|
||||||
public key exchange between the two peers and faking their responses
|
two peers and faking their responses will not grant an attacker
|
||||||
will not grant an attacker knowledge of the password, and so an
|
knowledge of the password, and so an attacker would not be able to
|
||||||
attacker would not be able to form valid ephemeral session keys.
|
form valid ephemeral session keys.
|
||||||
|
|
||||||
The same ephemeral session key is used for both TCP and UDP traffic
|
The same ephemeral session key is used for both TCP and UDP traffic
|
||||||
between two peers.
|
between two peers.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ set -e
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "weave launch [-password <password>] <peer> ..."
|
echo "weave launch [-password <password> | -passwordfile <path>] <peer> ..."
|
||||||
echo "weave launch-dns <cidr>"
|
echo "weave launch-dns <cidr>"
|
||||||
echo "weave connect <peer>"
|
echo "weave connect <peer>"
|
||||||
echo "weave run [--with-dns] <cidr> <docker run args> ..."
|
echo "weave run [--with-dns] <cidr> <docker run args> ..."
|
||||||
@@ -421,10 +421,19 @@ case "$COMMAND" in
|
|||||||
echo "WARNING: $1 parameter ignored; 'weave launch' no longer takes a CIDR as the first parameter" >&2
|
echo "WARNING: $1 parameter ignored; 'weave launch' no longer takes a CIDR as the first parameter" >&2
|
||||||
shift 1
|
shift 1
|
||||||
fi
|
fi
|
||||||
|
if [ "$1" = "-password" ] ; then
|
||||||
|
[ $# -gt 1 ] || usage
|
||||||
|
PASSWORD=$2
|
||||||
|
shift 2
|
||||||
|
elif [ "$1" = "-passwordfile" ] ; then
|
||||||
|
[ $# -gt 1 ] || usage
|
||||||
|
PASSWORDFILE=$2
|
||||||
|
shift 2
|
||||||
|
fi
|
||||||
# Set WEAVE_DOCKER_ARGS in the environment in order to supply
|
# Set WEAVE_DOCKER_ARGS in the environment in order to supply
|
||||||
# additional parameters, such as resource limits, to docker
|
# additional parameters, such as resource limits, to docker
|
||||||
# when launching the weave container.
|
# when launching the weave container.
|
||||||
CONTAINER=$(docker run --privileged -d --name=$CONTAINER_NAME -p $PORT:$PORT/tcp -p $PORT:$PORT/udp $WEAVE_DOCKER_ARGS $IMAGE -name $MACADDR "$@")
|
CONTAINER=$(docker run --privileged -d --name=$CONTAINER_NAME -p $PORT:$PORT/tcp -p $PORT:$PORT/udp ${PASSWORD:+-e WEAVE_PASSWORD="$PASSWORD"} ${PASSWORDFILE:+--env-file="$PASSWORDFILE"} $WEAVE_DOCKER_ARGS $IMAGE -name $MACADDR "$@")
|
||||||
with_container_netns $CONTAINER launch >/dev/null
|
with_container_netns $CONTAINER launch >/dev/null
|
||||||
echo $CONTAINER
|
echo $CONTAINER
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in new issue
Block a user