mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 18:16:52 +01:00
Reject v2 cert names and groups at signing the parser rejects (#1967)
smoke-extra / freebsd-amd64 (push) Failing after 18s
smoke-extra / linux-amd64-ipv6disable (push) Failing after 18s
smoke-extra / netbsd-amd64 (push) Failing after 16s
smoke-extra / openbsd-amd64 (push) Failing after 17s
smoke-extra / linux-386 (push) Failing after 17s
smoke / Run multi node smoke test (push) Failing after 1m41s
Build and test / Static checks (push) Successful in 45s
Build and test / Test linux (push) Failing after 1m19s
Build and test / Test linux-pkcs11 (push) Failing after 2m5s
Build and test / Test linux-boringcrypto (push) Failing after 2m56s
Build and test / Test linux-fips140 (push) Failing after 2m51s
Build and test / Cross-build linux-arm (push) Successful in 3m0s
Build and test / Cross-build linux-mips (push) Successful in 3m43s
Build and test / Cross-build linux-other (push) Successful in 3m7s
Build and test / Cross-build windows (push) Successful in 1m2s
Build and test / Cross-build freebsd (push) Successful in 1m32s
Build and test / Cross-build netbsd (push) Successful in 1m33s
Build and test / Cross-build openbsd (push) Successful in 1m32s
Build and test / Cross-build mobile (push) Successful in 3m23s
smoke-extra / Run windows smoke test (push) Canceled after 0s
smoke / Run self traffic smoke test on macOS (push) Canceled after 0s
Build and test / Test macos (push) Canceled after 0s
Build and test / Test windows (push) Canceled after 0s
Build and test / CI status (push) Canceled after 0s
smoke-extra / freebsd-amd64 (push) Failing after 18s
smoke-extra / linux-amd64-ipv6disable (push) Failing after 18s
smoke-extra / netbsd-amd64 (push) Failing after 16s
smoke-extra / openbsd-amd64 (push) Failing after 17s
smoke-extra / linux-386 (push) Failing after 17s
smoke / Run multi node smoke test (push) Failing after 1m41s
Build and test / Static checks (push) Successful in 45s
Build and test / Test linux (push) Failing after 1m19s
Build and test / Test linux-pkcs11 (push) Failing after 2m5s
Build and test / Test linux-boringcrypto (push) Failing after 2m56s
Build and test / Test linux-fips140 (push) Failing after 2m51s
Build and test / Cross-build linux-arm (push) Successful in 3m0s
Build and test / Cross-build linux-mips (push) Successful in 3m43s
Build and test / Cross-build linux-other (push) Successful in 3m7s
Build and test / Cross-build windows (push) Successful in 1m2s
Build and test / Cross-build freebsd (push) Successful in 1m32s
Build and test / Cross-build netbsd (push) Successful in 1m33s
Build and test / Cross-build openbsd (push) Successful in 1m32s
Build and test / Cross-build mobile (push) Successful in 3m23s
smoke-extra / Run windows smoke test (push) Canceled after 0s
smoke / Run self traffic smoke test on macOS (push) Canceled after 0s
Build and test / Test macos (push) Canceled after 0s
Build and test / Test windows (push) Canceled after 0s
Build and test / CI status (push) Canceled after 0s
This commit is contained in:
1 parent
5bf666dd90
commit
428dad94b3
3 files changed
+57
-1
No files matched your search
+10
-1
@@ -389,7 +389,16 @@ func (c *certificateV2) fromTBSCertificate(t *TBSCertificate) error {
|
||||
}
|
||||
|
||||
func (c *certificateV2) validate() error {
|
||||
// Empty names are allowed
|
||||
// Mirror the name and group rules in unmarshalDetails so signing fails instead of producing an unparseable certificate
|
||||
if c.details.name == "" || len(c.details.name) > MaxNameLength {
|
||||
return NewErrInvalidCertificateProperties("name must be between 1 and %d bytes", MaxNameLength)
|
||||
}
|
||||
|
||||
for _, group := range c.details.groups {
|
||||
if group == "" {
|
||||
return NewErrInvalidCertificateProperties("groups may not be empty")
|
||||
}
|
||||
}
|
||||
|
||||
if len(c.publicKey) == 0 {
|
||||
return ErrInvalidPublicKey
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"net/netip"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -135,3 +136,47 @@ func TestCertificate_SignP256_AlwaysNormalized(t *testing.T) {
|
||||
assert.True(t, normie)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCertificateV2_SignRejectsUnparseable(t *testing.T) {
|
||||
_, priv, err := ed25519.GenerateKey(rand.Reader)
|
||||
require.NoError(t, err)
|
||||
var invalid *ErrInvalidCertificateProperties
|
||||
|
||||
newTBS := func() TBSCertificate {
|
||||
return TBSCertificate{
|
||||
Version: Version2,
|
||||
Name: "testing",
|
||||
Networks: []netip.Prefix{mustParsePrefixUnmapped("10.1.1.1/24")},
|
||||
Groups: []string{"test-group1"},
|
||||
NotBefore: time.Now().Add(-time.Minute),
|
||||
NotAfter: time.Now().Add(time.Minute),
|
||||
PublicKey: []byte("1234567890abcedfghij1234567890ab"),
|
||||
Curve: Curve_CURVE25519,
|
||||
IsCA: true,
|
||||
}
|
||||
}
|
||||
|
||||
tbs := newTBS()
|
||||
tbs.Name = strings.Repeat("a", MaxNameLength)
|
||||
c, err := tbs.Sign(nil, Curve_CURVE25519, priv)
|
||||
require.NoError(t, err)
|
||||
b, err := c.Marshal()
|
||||
require.NoError(t, err)
|
||||
_, err = unmarshalCertificateV2(b, nil, Curve_CURVE25519)
|
||||
require.NoError(t, err)
|
||||
|
||||
tbs = newTBS()
|
||||
tbs.Name = strings.Repeat("a", MaxNameLength+1)
|
||||
_, err = tbs.Sign(nil, Curve_CURVE25519, priv)
|
||||
require.ErrorAs(t, err, &invalid)
|
||||
|
||||
tbs = newTBS()
|
||||
tbs.Name = ""
|
||||
_, err = tbs.Sign(nil, Curve_CURVE25519, priv)
|
||||
require.ErrorAs(t, err, &invalid)
|
||||
|
||||
tbs = newTBS()
|
||||
tbs.Groups = []string{"test-group1", ""}
|
||||
_, err = tbs.Sign(nil, Curve_CURVE25519, priv)
|
||||
require.ErrorAs(t, err, &invalid)
|
||||
}
|
||||
Reference in new issue
Block a user