Skip to content

TLSv1.3 causes panic on certified FIPS 140-3 linux instances #1626

Closed
@michel-laterman

Description

@michel-laterman

Using an ubuntu certified AMI (which has a FIPS 140-3 certification), and the latest microsoft/go (v1.24.2 at the time of reporting), operations that require TLSv1.3 cause a panic.

This can be tested with the following program:

package main

import (
        "crypto/tls"
        "log"
        "net/http"
)

func main() {
        client := http.Client{
                Transport: &http.Transport{
                        TLSClientConfig: &tls.Config{
                                MinVersion: tls.VersionTLS13,
                        },
                },
        }

        resp, err := client.Get("https://www.google.com")
        if err != nil {
                panic(err)
        }
        log.Default().Printf("Request status: %d\n", resp.StatusCode)
}

When executed with GOEXPERIMENT=systemcrypto CGO_ENABLED=1 go run main.go, the following panic occurs:

panic: EVP_KDF_derive
    openssl error(s):
    error:1C800069:Provider routines::invalid key length
        ../providers/implementations/kdfs/hkdf.c:163

goroutine 5 [running]:
crypto/tls/internal/tls13.ExpandLabel[...](0xc0000258c8, {0xc0000b4620, 0x20, 0x20}, {0x72c473, 0x2}, {0x0, 0x0, 0x0}, 0xc)
    /usr/local/go/src/crypto/tls/internal/tls13/tls13.go:41 +0x27f
crypto/tls.(*cipherSuiteTLS13).trafficKey(0x9b7540, {0xc0000b4620, 0x20, 0x20})
    /usr/local/go/src/crypto/tls/key_schedule.go:29 +0x10d
crypto/tls.(*halfConn).setTrafficSecret(0xc000190220, 0x9b7540, 0xc0000b45e0?, {0xc0000b4620?, 0x20?, 0x72e255?})
    /usr/local/go/src/crypto/tls/conn.go:234 +0x67
crypto/tls.(*clientHandshakeStateTLS13).establishHandshakeKeys(0xc000025c48)
    /usr/local/go/src/crypto/tls/handshake_client_tls13.go:525 +0x374
crypto/tls.(*clientHandshakeStateTLS13).handshake(0xc000025c48)
    /usr/local/go/src/crypto/tls/handshake_client_tls13.go:134 +0x73e
crypto/tls.(*Conn).clientHandshake(0xc000190008, {0x7a3c40, 0xc000192000})
    /usr/local/go/src/crypto/tls/handshake_client.go:379 +0x810
crypto/tls.(*Conn).handshakeContext(0xc000190008, {0x7a3c40, 0xc0000dc0f0})
    /usr/local/go/src/crypto/tls/conn.go:1568 +0x39a
crypto/tls.(*Conn).HandshakeContext(...)
    /usr/local/go/src/crypto/tls/conn.go:1508
net/http.(*persistConn).addTLS.func2()
    /usr/local/go/src/net/http/transport.go:1703 +0x6e
created by net/http.(*persistConn).addTLS in goroutine 20
    /usr/local/go/src/net/http/transport.go:1699 +0x309
exit status 2

Where the key length check from the OpenSSL provider is:

int ossl_kdf_check_keylen(OSSL_LIB_CTX *ctx, size_t len)
{
#if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
    if (ossl_securitycheck_enabled(ctx))
        return len >= 14;
#endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
    return 1;
}

but the nonce length is hard coded to 12 bytes.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions