Skip to content

Commit a0ddf3a

Browse files
Potential fix for code scanning alert no. 3: Use of insecure SSL/TLS version
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 47ddea7 commit a0ddf3a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

start.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
SOCK_RAW, SOCK_STREAM, TCP_NODELAY, gethostbyname,
1616
gethostname, socket)
1717
from ssl import CERT_NONE, SSLContext, create_default_context
18+
import ssl
1819
from struct import pack as data_pack
1920
from subprocess import run, PIPE
2021
from sys import argv
@@ -44,7 +45,14 @@
4445
ctx: SSLContext = create_default_context(cafile=where())
4546
ctx.check_hostname = False
4647
ctx.verify_mode = CERT_NONE
47-
ctx.minimum_version = ctx.TLSVersion.TLSv1_2
48+
# Enforce only TLSv1.2+ (defense-in-depth: also disable older protocols explicitly)
49+
if hasattr(ctx, "minimum_version") and hasattr(ssl, "TLSVersion"):
50+
ctx.minimum_version = ssl.TLSVersion.TLSv1_2
51+
# Disable insecure TLS versions for additional safety
52+
if hasattr(ssl, "OP_NO_TLSv1"):
53+
ctx.options |= ssl.OP_NO_TLSv1
54+
if hasattr(ssl, "OP_NO_TLSv1_1"):
55+
ctx.options |= ssl.OP_NO_TLSv1_1
4856

4957
__version__: str = "2.4 SNAPSHOT"
5058
__dir__: Path = Path(__file__).parent

0 commit comments

Comments
 (0)