Skip to content

Commit

Permalink
supported groups extension with a truncated array element
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Aug 27, 2016
1 parent 08b19bb commit 7f22c8d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
5 changes: 4 additions & 1 deletion prober.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@
CertTypeOverflow12PFS(),
SupportedGroupsNull(),
SupportedGroupsNull12(),
SupportedGroupsNull12PFS()
SupportedGroupsNull12PFS(),
SupportedGroupsOddLen(),
SupportedGroupsOddLen12(),
SupportedGroupsOddLen12PFS()
]

def probe(ipaddress, port, starttls, specified_probe):
Expand Down
20 changes: 20 additions & 0 deletions probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,3 +1778,23 @@ class SupportedGroupsNull12(SupportedGroupsNull, NormalHandshake12):
class SupportedGroupsNull12PFS(SupportedGroupsNull, NormalHandshake12PFS):
'''Send empty supported groups extension in PFS TLSv1.2 hello'''
pass


class SupportedGroupsOddLen(SupportedGroupsNull):
'''Send supported groups extension with invalid length in hello'''

def test(self, sock):
logging.debug('Sending Client Hello...')
# normal extension has a two byte length and two byte elements,
# truncate the second element
sock.write(self.make_supported_groups_hello(b'\x00\x03\x00\x17\x00'))


class SupportedGroupsOddLen12(SupportedGroupsOddLen, NormalHandshake12):
'''Send supported groups extension with invalid length in TLSv1.2 hello'''
pass


class SupportedGroupsOddLen12PFS(SupportedGroupsOddLen, NormalHandshake12PFS):
'''As with SupportedGroupsOddLen but in PFS TLSv1.2 hello'''
pass
65 changes: 65 additions & 0 deletions tests/test_probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3578,3 +3578,68 @@ def test_test(self):
b'\x01\x00'
b'\x00\x04'
b'\x00\x0a\x00\x00'])


class TestSupportedGroupsOddLen(unittest.TestCase):
def test_test(self):
probe = SupportedGroupsOddLen()
sock = MockSock()

probe.test(sock)

self.maxDiff = None
self.assertEqual(sock.sent_data,
[b'\x16\x03\x01\x00D'
b'\x01\x00\x00@'
b'\x03\x01' +
RANDOM_STR +
b'\x00'
b'\x00\x0e' +
DEFAULT_CIPHERS_STR +
b'\x01\x00'
b'\x00\x09'
b'\x00\x0a\x00\x05'
b'\x00\x03\x00\x17\x00'])


class TestSupportedGroupsOddLen12(unittest.TestCase):
def test_test(self):
probe = SupportedGroupsOddLen12()
sock = MockSock()

probe.test(sock)

self.assertEqual(sock.sent_data,
[b'\x16\x03\x01\x00\\'
b'\x01\x00\x00X'
b'\x03\x03' +
RANDOM_STR +
b'\x00'
b'\x00&' +
DEFAULT_12_CIPHERS_STR +
b'\x01\x00'
b'\x00\x09'
b'\x00\x0a\x00\x05'
b'\x00\x03\x00\x17\x00'])


class TestSupportedGroupsOddLen12PFS(unittest.TestCase):
def test_test(self):
probe = SupportedGroupsOddLen12PFS()
sock = MockSock()

probe.test(sock)

self.maxDiff = None
self.assertEqual(sock.sent_data,
[b"\x16\x03\x01\x00\x94"
b"\x01\x00\x00\x90"
b"\x03\x03" +
RANDOM_STR +
b"\x00"
b"\x00^" +
DEFAULT_PFS_CIPHERS_STR +
b"\x01\x00"
b'\x00\x09'
b'\x00\x0a\x00\x05'
b'\x00\x03\x00\x17\x00'])

0 comments on commit 7f22c8d

Please sign in to comment.