limit acceptance rate on peer connections

The main purpose of this is to set an upper bound on the rate at which
an attacker might execute a brute force attack on the weave password.

No need to get clever or precise here.

Closes #837.
This commit is contained in:
Matthias Radestock committed 2015-06-04 14:21:35 +01:00
1 parent 2a244e5699
commit 044992eea0
2 files changed
+22 -10

No files matched your search

+9 -1
View File
@@ -13,11 +13,18 @@ import (
"code.google.com/p/gopacket/layers" "code.google.com/p/gopacket/layers"
) )
const macMaxAge = 10 * time.Minute // [1] const (
macMaxAge = 10 * time.Minute // [1]
tcpAcceptDelay = 1 * time.Millisecond // [2]
)
// [1] should be greater than typical ARP cache expiries, i.e. > 3/2 * // [1] should be greater than typical ARP cache expiries, i.e. > 3/2 *
// /proc/sys/net/ipv4_neigh/*/base_reachable_time_ms on Linux // /proc/sys/net/ipv4_neigh/*/base_reachable_time_ms on Linux
// [2] time to wait between accepting tcp connections. This guards
// against brute-force attacks on the password when encryption is in
// use. It is also a basic DoS defence.
type LogFrameFunc func(string, []byte, *layers.Ethernet) type LogFrameFunc func(string, []byte, *layers.Ethernet)
type Config struct { type Config struct {
@@ -199,6 +206,7 @@ func (router *Router) listenTCP(localPort int) {
continue continue
} }
router.acceptTCP(tcpConn) router.acceptTCP(tcpConn)
time.Sleep(tcpAcceptDelay)
} }
}() }()
} }
+13 -9
View File
@@ -274,15 +274,19 @@ local peer in the usual Diffie-Hellman way, resulting in both peers
arriving at the same shared key. To this is appended the supplied arriving at the same shared key. To this is appended the supplied
password, and the result is hashed through SHA256, to form the final password, and the result is hashed through SHA256, to form the final
ephemeral session key. Thus the supplied password is never exchanged ephemeral session key. Thus the supplied password is never exchanged
directly, and is thoroughly mixed into the shared secret. The shared directly, and is thoroughly mixed into the shared secret. Furthermore,
key formed by Diffie-Hellman is 256 bits long, appending the password the rate at which TCP connections are accepted is limited by weave to
to this obviously makes it longer by an unknown amount, and the use of 1kHz, which twarts online dictionary attacks on reasonably strong
SHA256 reduces this back to 256 bits, to form the final ephemeral passwords.
session key. This late combination with the password eliminates "Man
In The Middle" attacks: sniffing the public key exchange between the The shared key formed by Diffie-Hellman is 256 bits long, appending
two peers and faking their responses will not grant an attacker the password to this obviously makes it longer by an unknown amount,
knowledge of the password, and so an attacker would not be able to and the use of SHA256 reduces this back to 256 bits, to form the final
form valid ephemeral session keys. ephemeral session key. This late combination with the password
eliminates "Man In The Middle" attacks: sniffing the public key
exchange between the two peers and faking their responses will not
grant an attacker knowledge of the password, and so an attacker would
not be able to 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.