openssl/openssl
wrong server behaviour with different encodings in ECPointFormatList
Aperta
#26.007 aperta il 20 nov 2024
branch: masterhelp wantedtriaged: bug
Metriche repository
- Star
- (30.157 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
Describe the bug The server does not abort the connection when:
-
- the client sends an ECPointFormatList without the uncompressed format in it;
The server sends ServerHello, Certificate, Server Key Exchange and Server Hello Done. While the ServerHello and the Certificate might be acceptable as a response with the following alert, the Server Key Exchange cannot be provided without checking the client's preferences.
The server sends the wrong alert with 'raw' and 'hybrid' encoding:
-
- the server aborts the connection but sends the "internal_error" alert.
To Reproduce
openssl req -x509 -newkey rsa -keyout /tmp/localhost.key -out /tmp/localhost.crt -subj /CN=localhost -nodes -batch
openssl s_server -key localhost.key -cert localhost.crt -www
git clone https://github.com/tomato42/tlslite-ng .tlslite-ng
ln -s .tlslite-ng/tlslite tlslite
git clone https://github.com/warner/python-ecdsa .python-ecdsa
ln -s .python-ecdsa/src/ecdsa ecdsa
git clone https://github.com/gstarovo/tlsfuzzer.git
git checkout test_extension
PYTHONPATH=. python scripts/test-point-extension.py --compressed-f
009E73DCE57F0000:error:0A000126:SSL routines:ssl3_read_n:unexpected eof while reading:ssl/record/rec_layer_s3.c:303:
009E73DCE57F0000:error:0A00006E:SSL routines:tls_parse_ctos_ec_pt_formats:bad extension:ssl/statem/extensions_srvr.c:231:
009E73DCE57F0000:error:0A000126:SSL routines:ssl3_read_n:unexpected eof while reading:ssl/record/rec_layer_s3.c:303:
009E73DCE57F0000:error:08000066:elliptic curve routines:ossl_ec_GFp_simple_oct2point:invalid encoding:crypto/ec/ecp_oct.c:295:
009E73DCE57F0000:error:0A080010:SSL routines:tls_process_cke_ecdhe:EC lib:ssl/statem/statem_srvr.c:3043:
sanity ...
OK
ECDHE uncompressed extension missing ...
Error encountered while processing node ExpectAlert(level=2, description=47) (child: <tlsfuzzer.expect.ExpectClose object at 0x7fe7b1b949b0>) with last message being: <tlslite.messages.Message object at 0x7fe7b1b955b0>
Error while processing
Traceback (most recent call last):
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/scripts/test-point-extension.py", line 361, in main
runner.run()
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlsfuzzer/runner.py", line 235, in run
raise AssertionError("Unexpected message from peer: " +
AssertionError: Unexpected message from peer: Handshake(server_key_exchange)
Unexpected message from peer: Handshake(server_key_exchange)
ECDHE empty list extension ...
OK
ECDHE compressed point extension ...
OK
ECDHE hybrid encoding ...
Error encountered while processing node ExpectAlert(level=2, description=47) (child: <tlsfuzzer.expect.ExpectClose object at 0x7fe7b1b954c0>) with last message being: None
Error while processing
Traceback (most recent call last):
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlsfuzzer/runner.py", line 202, in run
recvMessageBlocking()
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlslite/messagesocket.py", line 102, in recvMessageBlocking
for res in self.recvMessage():
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlslite/messagesocket.py", line 84, in recvMessage
for ret in self.recvRecord():
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlslite/recordlayer.py", line 900, in recvRecord
for result in self._recordSocket.recv():
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlslite/recordlayer.py", line 210, in recv
for record in self._recvHeader():
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlslite/recordlayer.py", line 144, in _recvHeader
for result in self._sockRecvAll(1):
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlslite/recordlayer.py", line 121, in _sockRecvAll
socketBytes = self.sock.recv(length - len(buf))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlslite/bufferedsocket.py", line 56, in recv
self._read_buffer += self.socket.recv(max(4096, bufsize))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/scripts/test-point-extension.py", line 361, in main
runner.run()
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlsfuzzer/runner.py", line 224, in run
raise AssertionError(
AssertionError: Timeout when waiting for peer message
Timeout when waiting for peer message
ECDHE raw encoding ...
Error encountered while processing node ExpectAlert(level=2, description=(47,)) (child: <tlsfuzzer.expect.ExpectClose object at 0x7fe7b1b95250>) with last message being: <tlslite.messages.Message object at 0x7fe7b1b95eb0>
Error while processing
Traceback (most recent call last):
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/scripts/test-point-extension.py", line 361, in main
runner.run()
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlsfuzzer/runner.py", line 242, in run
node.process(self.state, msg)
File "/home/gstarovo/Documents/forked_tlsfuzzer/tlsfuzzer/tlsfuzzer/expect.py", line 1997, in process
raise AssertionError(problem_desc)
AssertionError: Expected alert description "illegal_parameter" does not match received "internal_error"
Expected alert description "illegal_parameter" does not match received "internal_error"
ECDHE uncompressed point extension ...
OK
sanity ...
OK
Test to verify that server's ec point extension
negotiation in TLS 1.2 is according the to the guidlines.
Test end
====================
version: 1
====================
TOTAL: 8
SKIP: 0
PASS: 5
XFAIL: 0
FAIL: 3
XPASS: 0
====================
FAILED:
'ECDHE hybrid encoding'
'ECDHE raw encoding'
'ECDHE uncompressed extension missing'
Expected behavior
- The server should check the client sends uncompressed point format in the ClientHello; failure in that should generate
illegal_parameteralert and abort the connection. rfc8422 - The server should check the validity of the client ECDH key share; in case of failure the server should generate
illegal_parameteralert
Screenshots n/a
Environment (please complete the following information):
- OS: Fedora 39
- OpenSSL version: 3.1.4 24 Oct 2023