|
21 | 21 | from sslyze.server_connectivity import ServerConnectivityInfo, TlsVersionEnum |
22 | 22 |
|
23 | 23 |
|
| 24 | +@dataclass(frozen=True) |
| 25 | +class SessionRenegotiationExtraArgument(ScanCommandExtraArgument): |
| 26 | + """Additional configuration for testing a server for client-initiated renegotiation. |
| 27 | +
|
| 28 | + Attributes: |
| 29 | + client_renegotiation_attempts: The number of attempts to make when testing the client initiated |
| 30 | + renegotiation DoS vector. If the server accepts this many attempts, |
| 31 | + is_vulnerable_to_client_renegotiation_dos is set. Default: 10. |
| 32 | + """ |
| 33 | + |
| 34 | + client_renegotiation_attempts: int |
| 35 | + |
| 36 | + |
24 | 37 | @dataclass(frozen=True) |
25 | 38 | class SessionRenegotiationScanResult(ScanCommandResult): |
26 | 39 | """The result of testing a server for insecure TLS renegotiation and client-initiated renegotiation. |
@@ -82,14 +95,13 @@ class SessionRenegotiationImplementation(ScanCommandImplementation[SessionRenego |
82 | 95 |
|
83 | 96 | @classmethod |
84 | 97 | def scan_jobs_for_scan_command( |
85 | | - cls, server_info: ServerConnectivityInfo, extra_arguments: Optional[ScanCommandExtraArgument] = None |
| 98 | + cls, server_info: ServerConnectivityInfo, extra_arguments: Optional[SessionRenegotiationExtraArgument] = None |
86 | 99 | ) -> List[ScanJob]: |
87 | | - if extra_arguments: |
88 | | - raise ScanCommandWrongUsageError("This plugin does not take extra arguments") |
| 100 | + client_renegotiation_attempts = extra_arguments.client_renegotiation_attempts if extra_arguments else 10 |
89 | 101 |
|
90 | 102 | return [ |
91 | 103 | ScanJob(function_to_call=_test_secure_renegotiation, function_arguments=[server_info]), |
92 | | - ScanJob(function_to_call=_test_client_renegotiation, function_arguments=[server_info]), |
| 104 | + ScanJob(function_to_call=_test_client_renegotiation, function_arguments=[server_info, client_renegotiation_attempts]), |
93 | 105 | ] |
94 | 106 |
|
95 | 107 | @classmethod |
@@ -147,7 +159,7 @@ def _test_secure_renegotiation(server_info: ServerConnectivityInfo) -> Tuple[_Sc |
147 | 159 | return _ScanJobResultEnum.SUPPORTS_SECURE_RENEG, supports_secure_renegotiation |
148 | 160 |
|
149 | 161 |
|
150 | | -def _test_client_renegotiation(server_info: ServerConnectivityInfo) -> Tuple[_ScanJobResultEnum, bool]: |
| 162 | +def _test_client_renegotiation(server_info: ServerConnectivityInfo, client_renegotiation_attempts: int) -> Tuple[_ScanJobResultEnum, bool]: |
151 | 163 | """Check whether the server honors session renegotiation requests.""" |
152 | 164 | # Try with TLS 1.2 even if the server supports TLS 1.3 or higher as there is no reneg with TLS 1.3 |
153 | 165 | if server_info.tls_probing_result.highest_tls_version_supported.value >= TlsVersionEnum.TLS_1_3.value: |
@@ -180,7 +192,7 @@ def _test_client_renegotiation(server_info: ServerConnectivityInfo) -> Tuple[_Sc |
180 | 192 | try: |
181 | 193 | # Do a reneg multiple times in a row to be 100% sure that the server has no mitigations in place |
182 | 194 | # https://github.com/nabla-c0d3/sslyze/issues/473 |
183 | | - for i in range(10): |
| 195 | + for i in range(client_renegotiation_attempts): |
184 | 196 | ssl_connection.ssl_client.do_renegotiate() |
185 | 197 | accepts_client_renegotiation = True |
186 | 198 |
|
|
0 commit comments