Skip to content

Commit

Permalink
Merge pull request #896 from tlsfuzzer/bleichenbacher-sni
Browse files Browse the repository at this point in the history
bleichenbacher-timing - allow server to reply with server_name ext
  • Loading branch information
tomato42 committed Jan 3, 2024
2 parents 749f769 + b4bc732 commit 2848adf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
28 changes: 20 additions & 8 deletions scripts/test-bleichenbacher-timing-marvin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Author: Hubert Kario, (c) 2021-2022
# Released under Gnu GPL v2.0, see LICENSE file for details
"""Bleichenbacher attack test for Marvin workaround."""
"""Bleichenbacher attack test for servers employing the Marvin workaround."""
from __future__ import print_function
import traceback
import sys
Expand Down Expand Up @@ -36,7 +36,7 @@
from tlsfuzzer.utils.rsa import MarvinCiphertextGenerator


version = 5
version = 6


def help_msg():
Expand Down Expand Up @@ -72,8 +72,12 @@ def help_msg():
print(" /tmp by default")
print(" --repeat rep How many timing samples should be gathered for each test")
print(" 100 by default")
print(" --no-safe-renego Allow the server not to support safe")
print(" renegotiation extension")
print(" --require-safe-renego Require the server to support safe renegotiation")
print(" extension. If any --require-* is used, they must specify")
print(" all extensions sent by server")
print(" --require-sni Require the server to echo server name extension.")
print(" If any --require-* is used, they must specify all")
print(" extensions sent by the server")
print(" --no-sni do not send server name extension.")
print(" Sends extension by default if the hostname is a")
print(" valid DNS name, not an IP address")
Expand Down Expand Up @@ -115,7 +119,7 @@ def main():
last_exp_tmp = None
alert = AlertDescription.bad_record_mac
level = AlertLevel.fatal
srv_extensions = {ExtensionType.renegotiation_info: None}
srv_extensions = dict()
no_sni = False
repetitions = 100
interface = None
Expand All @@ -136,7 +140,8 @@ def main():
opts, args = getopt.getopt(argv,
"h:p:e:x:X:n:a:l:o:i:C:",
["help",
"no-safe-renego",
"require-safe-renego",
"require-sni",
"no-sni",
"repeat=",
"cpu-list=",
Expand Down Expand Up @@ -183,8 +188,10 @@ def main():
outdir = arg
elif opt == "--repeat":
repetitions = int(arg)
elif opt == "--no-safe-renego":
srv_extensions = None
elif opt == "--require-safe-renego":
srv_extensions[ExtensionType.renegotiation_info] = None
elif opt == "--require-sni":
srv_extensions[ExtensionType.server_name] = None
elif opt == "--no-sni":
no_sni = True
elif opt == "--cpu-list":
Expand Down Expand Up @@ -236,6 +243,11 @@ def main():
else:
run_only = None

if not srv_extensions:
# None for extensions means "expect RFC compliant behaviour for the
# ClientHello sent"
srv_extensions = None

cln_extensions = {ExtensionType.renegotiation_info: None}
if is_valid_hostname(host) and not no_sni:
cln_extensions[ExtensionType.server_name] = \
Expand Down
27 changes: 20 additions & 7 deletions scripts/test-bleichenbacher-timing-pregenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from tlsfuzzer.utils.log import Log


version = 5
version = 6


def help_msg():
Expand Down Expand Up @@ -71,8 +71,12 @@ def help_msg():
print(" /tmp by default")
print(" --repeat rep How many timing samples should be gathered for each test")
print(" 100 by default")
print(" --no-safe-renego Allow the server not to support safe")
print(" renegotiation extension")
print(" --require-safe-renego Require the server to support safe renegotiation")
print(" extension. If any --require-* is used, they must specify")
print(" all extensions sent by server")
print(" --require-sni Require the server to echo server name extension.")
print(" If any --require-* is used, they must specify all")
print(" extensions sent by the server")
print(" --no-sni do not send server name extension.")
print(" Sends extension by default if the hostname is a")
print(" valid DNS name, not an IP address")
Expand Down Expand Up @@ -133,7 +137,7 @@ def main():
timeout = 1.0
alert = AlertDescription.bad_record_mac
level = AlertLevel.fatal
srv_extensions = {ExtensionType.renegotiation_info: None}
srv_extensions = dict()
no_sni = False
repetitions = 100
interface = None
Expand All @@ -157,7 +161,8 @@ def main():
opts, args = getopt.getopt(argv,
"h:p:e:x:X:t:n:a:l:l:o:i:C:",
["help",
"no-safe-renego",
"require-safe-renego",
"require-sni",
"no-sni",
"repeat=",
"cpu-list=",
Expand Down Expand Up @@ -207,8 +212,10 @@ def main():
outdir = arg
elif opt == "--repeat":
repetitions = int(arg)
elif opt == "--no-safe-renego":
srv_extensions = None
elif opt == "--require-safe-renego":
srv_extensions[ExtensionType.renegotiation_info] = None
elif opt == "--require-sni":
srv_extensions[ExtensionType.server_name] = None
elif opt == "--no-sni":
no_sni = True
elif opt == "--cpu-list":
Expand Down Expand Up @@ -245,6 +252,11 @@ def main():
else:
run_only = None

if not srv_extensions:
# None for extensions means "expect RFC compliant behaviour for the
# ClientHello sent"
srv_extensions = None

if run_only and test_set:
raise ValueError("Can't specify test set and individual tests together")

Expand Down Expand Up @@ -343,6 +355,7 @@ def main():
runner.run()
server_cert_state = runner.state
except Exception as exp:
print(traceback.format_exc())
# Exception means the server rejected the ciphersuite
print("Failing on {0} because server does not support it. ".format(CipherSuite.ietfNames[cipher]))
print(20 * '=')
Expand Down

0 comments on commit 2848adf

Please sign in to comment.