Package: libgnutls30 Version: 3.5.14-3 Severity: normal If the %SAFE_RENEGOTIATION flag is enabled in the priorities string of a GnuTLS server, Client Hellos from OpenSSL clients attempting session resumption are rejected with a "safe renegotiation failed" error, even though the client does support safe renegotiation. Note that the handshake works as expected if the session cache entry or ticket has expired (without resumption, of course), so the bug only affects otherwise successful resumption.
I have initially observed this bug using mod_gnutls (package libapache2-mod-gnutls), but it is fully reproducible using only the GnuTLS and OpenSSL command line tools. The logs below have been produced by running a gnutls-serv server and connecting using openssl s_client and gnutls-cli (separated by three pings for clarity in client logs and packet capture), both set to immediately disconnect and resume after the initial handshake. The GnuTLS client can resume the TLS session as expected, while the OpenSSL client is rejected. Commands to reproduce: (server)$ gnutls-serv --priority="NORMAL:%SAFE_RENEGOTIATION" --x509keyfile=server/secret.key --x509certfile=server/x509-chain.pem -p 4433 (OpenSSL client)$ openssl s_client -connect localhost:4433 -reconnect (GnuTLS client)$ gnutls-cli -p 4433 --x509cafile=authority/x509.pem --resume localhost A packet capture taken during this process shows a difference in how GnuTLS and OpenSSL signal safe renegotiation support in the Client Hello: GnuTLS sends the renegotiation_info extension, OpenSSL includes the TLS_EMPTY_RENEGOTIATION_INFO_SCSV in the list of cipher suites. According to RFC 5746 both are equally valid for both full and session-resumption handshakes, but the GnuTLS server appears to ignore the SCSV during session resumption. *** safe_renegotiation_resume.server $ gnutls-serv --priority="NORMAL:%SAFE_RENEGOTIATION" --x509keyfile=server/secret.key --x509certfile=server/x509-chain.pem -p 4433 HTTP Server listening on IPv4 0.0.0.0 port 4433...done HTTP Server listening on IPv6 :: port 4433...done * Accepted connection from IPv6 ::1 port 58956 on Wed Aug 23 13:59:33 2017 - Description: (TLS1.2)-(ECDHE-RSA-SECP256R1)-(AES-256-GCM) - Session ID: 78:EE:E1:54:AD:C3:EF:35:52:6D:B3:1A:51:8B:45:96:72:8D:50:A0:42:06:22:45:8E:F9:46:6A:23:B3:B7:A3 No certificates found! - Ephemeral EC Diffie-Hellman parameters - Using curve: SECP256R1 - Curve size: 256 bits - Version: TLS1.2 - Key Exchange: ECDHE-RSA - Server Signature: RSA-SHA512 - Cipher: AES-256-GCM - MAC: AEAD - Compression: NULL - Options: extended master secret, safe renegotiation, - Channel binding 'tls-unique': 3019c6c0c2a491101e3a4a1e * Accepted connection from IPv6 ::1 port 58958 on Wed Aug 23 13:59:33 2017 Error in handshake Error: Safe renegotiation failed. * Accepted connection from IPv6 ::1 port 58960 on Wed Aug 23 13:59:35 2017 - Description: (TLS1.2)-(ECDHE-RSA-SECP256R1)-(AES-256-GCM) - Session ID: 0B:B5:29:05:D5:E0:56:DD:76:95:F3:D1:2B:C0:83:05:85:CD:D0:1E:48:CA:FB:63:7F:06:8B:BC:8E:0C:95:C7 - Given server name[1]: localhost No certificates found! - Ephemeral EC Diffie-Hellman parameters - Using curve: SECP256R1 - Curve size: 256 bits - Version: TLS1.2 - Key Exchange: ECDHE-RSA - Server Signature: RSA-SHA256 - Cipher: AES-256-GCM - MAC: AEAD - Compression: NULL - Options: extended master secret, safe renegotiation, - Channel binding 'tls-unique': 0be4e24d6efda699b2af69df * Accepted connection from IPv6 ::1 port 58962 on Wed Aug 23 13:59:35 2017 *** This is a resumed session - Description: (TLS1.2)-(ECDHE-RSA-SECP256R1)-(AES-256-GCM) - Session ID: AD:2C:A9:E9:5C:C3:9A:4A:FC:F6:F6:01:A4:2A:42:FD:52:51:FF:94:60:70:2A:93:62:C9:3E:A2:6C:DD:DD:B4 - Given server name[1]: localhost No certificates found! - Ephemeral EC Diffie-Hellman parameters - Using curve: SECP256R1 - Curve size: 256 bits - Version: TLS1.2 - Key Exchange: ECDHE-RSA - Cipher: AES-256-GCM - MAC: AEAD - Compression: NULL - Options: extended master secret, safe renegotiation, - Channel binding 'tls-unique': 62489fad3554606b907fd7dc *** safe_renegotiation_resume.client $ openssl s_client -connect localhost:4433 -reconnect; ping -c 3 localhost; gnutls-cli -p 4433 --x509cafile=authority/x509.pem --resume localhost CONNECTED(00000003) depth=1 CN = Testing Authority verify error:num=19:self signed certificate in certificate chain --- Certificate chain 0 s:/CN=localhost i:/CN=Testing Authority 1 s:/CN=Testing Authority i:/CN=Testing Authority --- Server certificate -----BEGIN CERTIFICATE----- MIIEozCCAwugAwIBAgIEIv/w2TANBgkqhkiG9w0BAQsFADAcMRowGAYDVQQDExFU ZXN0aW5nIEF1dGhvcml0eTAeFw0xNzA4MjMxMTA5MjBaFw0xODA4MjMxMTA5MjBa MBQxEjAQBgNVBAMTCWxvY2FsaG9zdDCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCC AYoCggGBALt5LnvO+Y1b024IRaIlX8gQqRlDTTl42SBb1XyRvRLfqZbxsyVXL+k2 4PSG2PltF/6QLxpGDhNUk4Qh//B3i/Q0q1F1QH62Png6T18U/vtD+5lQOhwH+2RT x8Nm3X4JPZaDrm29oKmt7OSk+Kv4rQIyfI6X1DJ1+pHRUjZAmBgOeSQCSaOUDCny mxxfFdp3936xIQ6Uyw2fKjgxD1FZf7XNcPVh/HCTUk8yhcOFn1yRUCMBDHHsrY5e rQVqxQ2J3yyTj5CAqEApeQz6wyo3M2LhKWsvaWYZNpsDNYjeo1h0mlt8Zepq7H3/ taGRWhp6aan7mknroM44I0nSATctjxAKg4sfEy0OntsGo1l3ErqHKIiEFw797vzG XRkFZ5wINu9Ke7xuonyBY4xP26cxLyEONrmST/+xqP2r7hc/Fo78bUWTzyd4u0DJ UQGCAE1Dr4rUJRZ9mle4r/k4TpBsun1eATMkcE4uad0XLeV2vEjkOOLpkKZDEi7t JuBV/d/ODwIDAQABo4H0MIHxMAwGA1UdEwEB/wQCMAAwFAYDVR0RBA0wC4IJbG9j YWxob3N0MBMGA1UdJQQMMAoGCCsGAQUFBwMBMDcGCCsGAQUFBwEBBCswKTAnBggr BgEFBQcwAYYbaHR0cDovL2xvY2FsaG9zdDo5OTM2L29jc3AvMA8GA1UdDwEB/wQF AwMHoAAwHQYDVR0OBBYEFCnAxfqOXJ+yirrB6auhK3vPp2qEMB8GA1UdIwQYMBaA FKfs/1VdHky/Zyk/MuDFPibYbgs5MCwGA1UdHwQlMCMwIaAfoB2GG2h0dHA6Ly93 d3cuZXhhbXBsZS5jb20vY3JsLzANBgkqhkiG9w0BAQsFAAOCAYEAioGz2guR/pWu Rh/pZYEjaC1YpU+RDMxsmUismivmtQCxJ2HWkHCwX9od4BFu5xNW4eHlDSuUnl6K Dsq7b7O1aGHcF9ofr3JJlEcRzyy9rIRMWHRoSX7lKLvOH2DMdgko2aJ+enDA9CE3 IW1wjil27GvcoiFW3wKzZsy5UKSFH94hPK74urO60HaKBV6dILROgM6fz/+Xg/Le bEQXFX4tDuJSNVojAgvM07LAOsTOoIz5YKjvKQIAZba4VaS33RLZ08IaIiJX+Qgb Y1X9dw2z0NLvkRFkVp8vvFEDr46bsK0STjrLdTGLCOuEixnr+ZJsVI5OFOMukuBi xaApWz4eJjIfnk6AvbZAYZiQeUwp6ckoePjFHxwRsM8uhsAHW/4bACfwL3mG2/gM 33H39vosfkm19ne1/ROMijdwfAjCrJ6U3GO2Yq2FPgeOB2nPtnOAkv4J6LNeJk4M Mek4ossPT93fEKlVcVQ3rsbcV+71h0xbvIgAMa8aNPP0lUIi838R -----END CERTIFICATE----- subject=/CN=localhost issuer=/CN=Testing Authority --- No client certificate CA names sent Client Certificate Types: RSA sign, DSA sign, ECDSA sign Requested Signature Algorithms: RSA+SHA256:ECDSA+SHA256:RSA+SHA384:ECDSA+SHA384:RSA+SHA512:ECDSA+SHA512:RSA+SHA224:ECDSA+SHA224:RSA+SHA1:ECDSA+SHA1 Shared Requested Signature Algorithms: RSA+SHA256:ECDSA+SHA256:RSA+SHA384:ECDSA+SHA384:RSA+SHA512:ECDSA+SHA512:RSA+SHA224:ECDSA+SHA224:RSA+SHA1:ECDSA+SHA1 Peer signing digest: SHA512 Server Temp Key: ECDH, P-256, 256 bits --- SSL handshake has read 3341 bytes and written 314 bytes Verification error: self signed certificate in certificate chain --- New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384 Server public key is 3072 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : ECDHE-RSA-AES256-GCM-SHA384 Session-ID: 558954B73526457F4AD9EB1D92E2417FE6EE30D6D5FC07B264F6DFFD250927B1 Session-ID-ctx: Master-Key: 226556C46A0572FFE07215592FB65AF2BAC5AEA461401C9333857419056937A272ABC7DC3582B2D6A60873984D100C85 PSK identity: None PSK identity hint: None SRP username: None TLS session ticket lifetime hint: 3600 (seconds) TLS session ticket: 0000 - e2 c9 95 c4 3c cc 4c 13-f5 3b 9d 0b 71 12 57 08 ....<.L..;..q.W. 0010 - 25 6e 9d 59 73 d6 d0 5f-c0 f3 92 53 6a ff 01 ad %n.Ys.._...Sj... 0020 - 01 50 9f 5e ff c2 ee e0-51 42 ed 8d bd 8a 27 4c .P.^....QB....'L 0030 - 89 ac 08 cf c0 75 9e 28-2c 1d 56 98 f2 1c 40 cc .....u.(,.V...@. 0040 - 3f 47 0b 92 f3 2b b7 cf-b4 ed 61 3e b4 7f 46 c0 ?G...+....a>..F. 0050 - 3c c8 af 9d 35 b4 b6 f4-81 2f 23 79 7b aa dd 56 <...5..../#y{..V 0060 - 5e 90 c8 ac 0f 48 fd 51-1f ae 8f b4 6b 3a 3c 52 ^....H.Q....k:<R 0070 - 31 c4 d9 8a fc 0e 77 3a-ab 99 c6 db 85 b2 ec dd 1.....w:........ 0080 - b1 18 6d 32 bd 59 93 24-b1 b6 41 33 89 7c 17 48 ..m2.Y.$..A3.|.H 0090 - 75 4d 79 1b ad f4 75 6c-dd a7 44 f7 57 5d 65 4b uMy...ul..D.W]eK 00a0 - 33 39 32 87 c4 b2 f9 cf-0d 99 f0 30 57 7d 1e dd 392........0W}.. 00b0 - 78 f8 a8 6f 6d d5 a8 ed-8f 08 61 e7 29 0e 7d 4b x..om.....a.).}K 00c0 - 05 b1 b8 ce d8 fa 9d 8e-f7 c6 f4 b6 9b 8b 17 d6 ................ 00d0 - bb 6d 40 1a cc 07 8c db-01 fe 35 6d bb ec 89 29 .m@.......5m...) 00e0 - e2 42 54 bd 8a 08 94 96-cc 4d 18 15 65 ac 2c c7 .BT......M..e.,. 00f0 - 60 d9 37 8b c7 cc 4b 6a-88 9d 9b e3 8e 54 69 eb `.7...Kj.....Ti. 0100 - b9 8a 3b 67 70 df a3 79-3b eb c5 59 11 c1 7a 54 ..;gp..y;..Y..zT 0110 - 99 d2 46 1f e7 c3 2e eb-39 46 5a ad 5f 90 d7 0a ..F.....9FZ._... 0120 - c1 16 16 1d 31 b3 d7 b5-f8 63 e5 04 d1 6c a7 0f ....1....c...l.. 0130 - ba 00 12 79 e3 70 66 0f-aa 8f e3 87 0d 95 42 d5 ...y.pf.......B. 0140 - 15 bb 89 f0 90 40 44 93-19 54 d2 10 f9 16 4b 44 .....@D..T....KD 0150 - 79 9a 81 7a a9 4b db 2a-13 9e f7 cb f0 af b8 35 y..z.K.*.......5 0160 - c0 6d c3 5e cd 65 0c 4f-fa be d4 bb ae d0 90 75 .m.^.e.O.......u 0170 - b0 e0 3b 2c 06 a9 f6 85-4a 10 81 4e f8 c8 54 2f ..;,....J..N..T/ 0180 - f1 c6 ee 32 a3 31 ...2.1 Start Time: 1503489573 Timeout : 7200 (sec) Verify return code: 19 (self signed certificate in certificate chain) Extended master secret: yes --- drop connection and then reconnect CONNECTED(00000003) 140386064696576:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:../ssl/record/rec_layer_s3.c:1399:SSL alert number 40 Verification error: self signed certificate in certificate chain --- New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384 Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : ECDHE-RSA-AES256-GCM-SHA384 Session-ID: 558954B73526457F4AD9EB1D92E2417FE6EE30D6D5FC07B264F6DFFD250927B1 Session-ID-ctx: Master-Key: 226556C46A0572FFE07215592FB65AF2BAC5AEA461401C9333857419056937A272ABC7DC3582B2D6A60873984D100C85 PSK identity: None PSK identity hint: None SRP username: None TLS session ticket lifetime hint: 3600 (seconds) TLS session ticket: 0000 - e2 c9 95 c4 3c cc 4c 13-f5 3b 9d 0b 71 12 57 08 ....<.L..;..q.W. 0010 - 25 6e 9d 59 73 d6 d0 5f-c0 f3 92 53 6a ff 01 ad %n.Ys.._...Sj... 0020 - 01 50 9f 5e ff c2 ee e0-51 42 ed 8d bd 8a 27 4c .P.^....QB....'L 0030 - 89 ac 08 cf c0 75 9e 28-2c 1d 56 98 f2 1c 40 cc .....u.(,.V...@. 0040 - 3f 47 0b 92 f3 2b b7 cf-b4 ed 61 3e b4 7f 46 c0 ?G...+....a>..F. 0050 - 3c c8 af 9d 35 b4 b6 f4-81 2f 23 79 7b aa dd 56 <...5..../#y{..V 0060 - 5e 90 c8 ac 0f 48 fd 51-1f ae 8f b4 6b 3a 3c 52 ^....H.Q....k:<R 0070 - 31 c4 d9 8a fc 0e 77 3a-ab 99 c6 db 85 b2 ec dd 1.....w:........ 0080 - b1 18 6d 32 bd 59 93 24-b1 b6 41 33 89 7c 17 48 ..m2.Y.$..A3.|.H 0090 - 75 4d 79 1b ad f4 75 6c-dd a7 44 f7 57 5d 65 4b uMy...ul..D.W]eK 00a0 - 33 39 32 87 c4 b2 f9 cf-0d 99 f0 30 57 7d 1e dd 392........0W}.. 00b0 - 78 f8 a8 6f 6d d5 a8 ed-8f 08 61 e7 29 0e 7d 4b x..om.....a.).}K 00c0 - 05 b1 b8 ce d8 fa 9d 8e-f7 c6 f4 b6 9b 8b 17 d6 ................ 00d0 - bb 6d 40 1a cc 07 8c db-01 fe 35 6d bb ec 89 29 .m@.......5m...) 00e0 - e2 42 54 bd 8a 08 94 96-cc 4d 18 15 65 ac 2c c7 .BT......M..e.,. 00f0 - 60 d9 37 8b c7 cc 4b 6a-88 9d 9b e3 8e 54 69 eb `.7...Kj.....Ti. 0100 - b9 8a 3b 67 70 df a3 79-3b eb c5 59 11 c1 7a 54 ..;gp..y;..Y..zT 0110 - 99 d2 46 1f e7 c3 2e eb-39 46 5a ad 5f 90 d7 0a ..F.....9FZ._... 0120 - c1 16 16 1d 31 b3 d7 b5-f8 63 e5 04 d1 6c a7 0f ....1....c...l.. 0130 - ba 00 12 79 e3 70 66 0f-aa 8f e3 87 0d 95 42 d5 ...y.pf.......B. 0140 - 15 bb 89 f0 90 40 44 93-19 54 d2 10 f9 16 4b 44 .....@D..T....KD 0150 - 79 9a 81 7a a9 4b db 2a-13 9e f7 cb f0 af b8 35 y..z.K.*.......5 0160 - c0 6d c3 5e cd 65 0c 4f-fa be d4 bb ae d0 90 75 .m.^.e.O.......u 0170 - b0 e0 3b 2c 06 a9 f6 85-4a 10 81 4e f8 c8 54 2f ..;,....J..N..T/ 0180 - f1 c6 ee 32 a3 31 ...2.1 Start Time: 1503489573 Timeout : 7200 (sec) Verify return code: 19 (self signed certificate in certificate chain) Extended master secret: yes --- PING localhost(localhost (::1)) 56 data bytes 64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.032 ms 64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.094 ms 64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.040 ms --- localhost ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2049ms rtt min/avg/max/mdev = 0.032/0.055/0.094/0.028 ms Processed 1 CA certificate(s). Resolving 'localhost:4433'... Connecting to '::1:4433'... - Certificate type: X.509 - Got a certificate list of 2 certificates. - Certificate[0] info: - subject `CN=localhost', issuer `CN=Testing Authority', serial 0x22fff0d9, RSA key 3072 bits, signed using RSA-SHA256, activated `2017-08-23 11:09:20 UTC', expires `2018-08-23 11:09:20 UTC', pin-sha256="uvF4lYvlpdPy2idD4xy1Lx8+mvwBPktt9Wek6Fw+dhI=" Public Key ID: sha1:29c0c5fa8e5c9fb28abac1e9aba12b7bcfa76a84 sha256:baf178958be5a5d3f2da2743e31cb52f1f3e9afc013e4b6df567a4e85c3e7612 Public Key PIN: pin-sha256:uvF4lYvlpdPy2idD4xy1Lx8+mvwBPktt9Wek6Fw+dhI= Public key's random art: +--[ RSA 3072]----+ | .. | | . .. | | o. | | .. . | | . .. S | |E o o. | |o+ . + . . | |+oooo + o | |XX+o=+.o | +-----------------+ - Certificate[1] info: - subject `CN=Testing Authority', issuer `CN=Testing Authority', serial 0x01, RSA key 3072 bits, signed using RSA-SHA256, activated `2017-08-23 11:09:20 UTC', expires `2018-08-23 11:09:20 UTC', pin-sha256="X0eflXB+9JCs/WRfLGQImsHyHGGl4QNw91IFdSyxvMo=" - Status: The certificate is trusted. - Successfully sent 0 certificate(s) to server. - Description: (TLS1.2)-(ECDHE-RSA-SECP256R1)-(AES-256-GCM) - Session ID: AD:2C:A9:E9:5C:C3:9A:4A:FC:F6:F6:01:A4:2A:42:FD:52:51:FF:94:60:70:2A:93:62:C9:3E:A2:6C:DD:DD:B4 - Ephemeral EC Diffie-Hellman parameters - Using curve: SECP256R1 - Curve size: 256 bits - Version: TLS1.2 - Key Exchange: ECDHE-RSA - Server Signature: RSA-SHA256 - Cipher: AES-256-GCM - MAC: AEAD - Compression: NULL - Options: extended master secret, safe renegotiation, - Handshake was completed - Disconnecting - Connecting again- trying to resume previous session Resolving 'localhost:4433'... Connecting to '::1:4433'... - Certificate type: X.509 - Got a certificate list of 2 certificates. - Certificate[0] info: - subject `CN=localhost', issuer `CN=Testing Authority', serial 0x22fff0d9, RSA key 3072 bits, signed using RSA-SHA256, activated `2017-08-23 11:09:20 UTC', expires `2018-08-23 11:09:20 UTC', pin-sha256="uvF4lYvlpdPy2idD4xy1Lx8+mvwBPktt9Wek6Fw+dhI=" Public Key ID: sha1:29c0c5fa8e5c9fb28abac1e9aba12b7bcfa76a84 sha256:baf178958be5a5d3f2da2743e31cb52f1f3e9afc013e4b6df567a4e85c3e7612 Public Key PIN: pin-sha256:uvF4lYvlpdPy2idD4xy1Lx8+mvwBPktt9Wek6Fw+dhI= Public key's random art: +--[ RSA 3072]----+ | .. | | . .. | | o. | | .. . | | . .. S | |E o o. | |o+ . + . . | |+oooo + o | |XX+o=+.o | +-----------------+ - Certificate[1] info: - subject `CN=Testing Authority', issuer `CN=Testing Authority', serial 0x01, RSA key 3072 bits, signed using RSA-SHA256, activated `2017-08-23 11:09:20 UTC', expires `2018-08-23 11:09:20 UTC', pin-sha256="X0eflXB+9JCs/WRfLGQImsHyHGGl4QNw91IFdSyxvMo=" - Status: The certificate is trusted. - Description: (TLS1.2)-(ECDHE-RSA)-(AES-256-GCM) - Session ID: AD:2C:A9:E9:5C:C3:9A:4A:FC:F6:F6:01:A4:2A:42:FD:52:51:FF:94:60:70:2A:93:62:C9:3E:A2:6C:DD:DD:B4 - Ephemeral EC Diffie-Hellman parameters - Using curve: (null) - Curve size: 0 bits - Version: TLS1.2 - Key Exchange: ECDHE-RSA - Cipher: AES-256-GCM - MAC: AEAD - Compression: NULL - Options: extended master secret, safe renegotiation, - Resume Handshake was completed *** This is a resumed session - Simple Client Mode: -- System Information: Debian Release: buster/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 4.12.0-1-amd64 (SMP w/1 CPU core) Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages libgnutls30 depends on: ii libc6 2.24-15 ii libgmp10 2:6.1.2+dfsg-1 ii libhogweed4 3.3-1+b1 ii libidn2-0 2.0.2-3 ii libnettle6 3.3-1+b1 ii libp11-kit0 0.23.7-3 ii libtasn1-6 4.12-2.1 ii libunistring2 0.9.7-2 ii zlib1g 1:1.2.8.dfsg-5 libgnutls30 recommends no packages. Versions of packages libgnutls30 suggests: ii gnutls-bin 3.5.14-3 -- no debconf information