mirror of
https://github.com/slackhq/nebula.git
synced 2026-06-30 18:40:29 +02:00
improve rejection of malformed handshakes (#1756)
smoke-extra / freebsd-amd64 (push) Failing after 18s
smoke-extra / linux-amd64-ipv6disable (push) Failing after 17s
smoke-extra / netbsd-amd64 (push) Failing after 15s
smoke-extra / openbsd-amd64 (push) Failing after 16s
smoke-extra / linux-386 (push) Failing after 16s
smoke / Run multi node smoke test (push) Failing after 1m28s
Build and test / Static checks (push) Successful in 1m42s
Build and test / Test linux (push) Failing after 1m31s
Build and test / Test linux-boringcrypto (push) Failing after 2m54s
Build and test / Test linux-pkcs11 (push) Failing after 3m7s
Build and test / Cross-build linux-arm (push) Successful in 3m5s
Build and test / Cross-build linux-mips (push) Successful in 3m48s
Build and test / Cross-build linux-other (push) Successful in 3m12s
Build and test / Cross-build windows (push) Successful in 1m1s
Build and test / Cross-build freebsd (push) Successful in 1m34s
Build and test / Cross-build netbsd (push) Successful in 1m35s
Build and test / Cross-build openbsd (push) Successful in 1m35s
Build and test / Cross-build mobile (push) Successful in 3m22s
smoke-extra / Run windows smoke test (push) Has been cancelled
Build and test / Test macos (push) Has been cancelled
Build and test / Test windows (push) Has been cancelled
Build and test / CI status (push) Has been cancelled
smoke-extra / freebsd-amd64 (push) Failing after 18s
smoke-extra / linux-amd64-ipv6disable (push) Failing after 17s
smoke-extra / netbsd-amd64 (push) Failing after 15s
smoke-extra / openbsd-amd64 (push) Failing after 16s
smoke-extra / linux-386 (push) Failing after 16s
smoke / Run multi node smoke test (push) Failing after 1m28s
Build and test / Static checks (push) Successful in 1m42s
Build and test / Test linux (push) Failing after 1m31s
Build and test / Test linux-boringcrypto (push) Failing after 2m54s
Build and test / Test linux-pkcs11 (push) Failing after 3m7s
Build and test / Cross-build linux-arm (push) Successful in 3m5s
Build and test / Cross-build linux-mips (push) Successful in 3m48s
Build and test / Cross-build linux-other (push) Successful in 3m12s
Build and test / Cross-build windows (push) Successful in 1m1s
Build and test / Cross-build freebsd (push) Successful in 1m34s
Build and test / Cross-build netbsd (push) Successful in 1m35s
Build and test / Cross-build openbsd (push) Successful in 1m35s
Build and test / Cross-build mobile (push) Successful in 3m22s
smoke-extra / Run windows smoke test (push) Has been cancelled
Build and test / Test macos (push) Has been cancelled
Build and test / Test windows (push) Has been cancelled
Build and test / CI status (push) Has been cancelled
This commit is contained in:
@@ -13,6 +13,7 @@ var (
|
|||||||
ErrUnknownSubtype = errors.New("unknown handshake subtype")
|
ErrUnknownSubtype = errors.New("unknown handshake subtype")
|
||||||
ErrMissingContent = errors.New("expected handshake content but message was empty")
|
ErrMissingContent = errors.New("expected handshake content but message was empty")
|
||||||
ErrUnexpectedContent = errors.New("received unexpected handshake content")
|
ErrUnexpectedContent = errors.New("received unexpected handshake content")
|
||||||
|
ErrInvalidRemoteIndex = errors.New("peer sent an invalid index in handshake payload")
|
||||||
ErrIndexAllocation = errors.New("failed to allocate local index")
|
ErrIndexAllocation = errors.New("failed to allocate local index")
|
||||||
ErrNoCredential = errors.New("no handshake credential available for cert version")
|
ErrNoCredential = errors.New("no handshake credential available for cert version")
|
||||||
ErrAsymmetricCipherKeys = errors.New("noise produced only one cipher key")
|
ErrAsymmetricCipherKeys = errors.New("noise produced only one cipher key")
|
||||||
|
|||||||
+10
-2
@@ -312,11 +312,19 @@ func (m *Machine) processPayload(msg []byte, flags msgFlags) error {
|
|||||||
|
|
||||||
// Process payload
|
// Process payload
|
||||||
if flags.expectsPayload {
|
if flags.expectsPayload {
|
||||||
|
var remoteIndex uint32
|
||||||
if m.result.Initiator {
|
if m.result.Initiator {
|
||||||
m.result.RemoteIndex = payload.ResponderIndex
|
remoteIndex = payload.ResponderIndex
|
||||||
} else {
|
} else {
|
||||||
m.result.RemoteIndex = payload.InitiatorIndex
|
remoteIndex = payload.InitiatorIndex
|
||||||
}
|
}
|
||||||
|
// The payload presence check above can be satisfied by Time alone, so a payload
|
||||||
|
// could still carry a zero index here. We need to reject it.
|
||||||
|
if remoteIndex == 0 {
|
||||||
|
m.failed = true
|
||||||
|
return ErrInvalidRemoteIndex
|
||||||
|
}
|
||||||
|
m.result.RemoteIndex = remoteIndex
|
||||||
m.result.HandshakeTime = payload.Time
|
m.result.HandshakeTime = payload.Time
|
||||||
m.payloadSet = true
|
m.payloadSet = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,6 +229,24 @@ func TestMachineProcessPayload(t *testing.T) {
|
|||||||
require.ErrorIs(t, err, ErrUnexpectedContent)
|
require.ErrorIs(t, err, ErrUnexpectedContent)
|
||||||
assert.True(t, m.Failed())
|
assert.True(t, m.Failed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("zero initiator index on responder is fatal", func(t *testing.T) {
|
||||||
|
m := newTestMachine(t, cs, v, false, 100)
|
||||||
|
bytes := MarshalPayload(nil, Payload{InitiatorIndex: 0, Time: 1})
|
||||||
|
err := m.processPayload(bytes, msgFlags{expectsPayload: true})
|
||||||
|
require.ErrorIs(t, err, ErrInvalidRemoteIndex)
|
||||||
|
assert.True(t, m.Failed())
|
||||||
|
assert.Zero(t, m.result.RemoteIndex)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("zero responder index on initiator is fatal", func(t *testing.T) {
|
||||||
|
m := newTestMachine(t, cs, v, true, 100)
|
||||||
|
bytes := MarshalPayload(nil, Payload{InitiatorIndex: 100, ResponderIndex: 0, Time: 1})
|
||||||
|
err := m.processPayload(bytes, msgFlags{expectsPayload: true})
|
||||||
|
require.ErrorIs(t, err, ErrInvalidRemoteIndex)
|
||||||
|
assert.True(t, m.Failed())
|
||||||
|
assert.Zero(t, m.result.RemoteIndex)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestMachineRequireComplete checks the fail-on-incomplete-handshake path
|
// TestMachineRequireComplete checks the fail-on-incomplete-handshake path
|
||||||
|
|||||||
Reference in New Issue
Block a user