Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Stop using deprecated ssl.wrap_socket (Default version of SSL/TLS may be insecure) #470

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

amotl
Copy link
Member

@amotl amotl commented Nov 21, 2022

TLDR;

Stop using deprecated ssl.wrap_socket(), use SSL context factory and context.wrap_socket() instead.

Problem report

This was reported as a check failure by CodeQL code scanning (#467) with id py/insecure-default-protocol 1, which translates to »Default version of SSL/TLS may be insecure«.

image

Solution

Use modern alternative SSL context factory methods instead. While ssl.create_default_context() was too restrictive, ssl._create_unverified_context() was just right, as advertised:

The configuration is less restrict than create_default_context()'s to increase backward compatibility.

On this SSL context, use a minimum version to restrict to secure TLS protocol variants only.

With kind regards,
Andreas.

Footnotes

  1. https://github.com/github/codeql/blob/main/python/ql/src/Security/CWE-327/InsecureDefaultProtocol.qhelp

Use `context.wrap_socket` instead. On this context, use a minimum
version to restrict to secure TLS protocol variants only.

This was reported as a check failure by CodeQL code scanning with id
`py/insecure-default-protocol`.

https://github.com/github/codeql/blob/main/python/ql/src/Security/CWE-327/InsecureDefaultProtocol.qhelp
@amotl amotl force-pushed the amo/fix-codeql-tls branch from 088e8ee to 1dd3dd2 Compare November 21, 2022 18:19
@amotl amotl requested review from matriv and seut November 21, 2022 18:53
@amotl amotl marked this pull request as ready for review November 21, 2022 18:53
@amotl amotl merged commit 2742729 into master Nov 22, 2022
@amotl amotl deleted the amo/fix-codeql-tls branch November 22, 2022 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants