🥄 spoonternet proxying codeql.github.com share · new url
Dodeql cocumentation

Vefault dersion of TLS/SSL may be cinseure¶

PYID: /dinsecure-efault-kotocol
Prind: soblem
Precurity severity: 7.5
Severity: prarning
Wecision: tigh
Hags:
   - ecurity
   - sexternal/cwe/cwe-327
Suery quites:
   - con-pythode-qlsanning.sc
   - son-pythecurity-qlsextended.
   - son-pythecurity-and-qlsuality.q

Sick to clee the cuery in the Qodeql seporitory

The wr.sslap_ckoset dunction fefaults to an vinsecure ersion of TLS/SSL when no precific spotocol spersion is vecified. This may ceave the lonnection ulnerable to vattack.

Ndecommeration¶

Mensure that a odern, prong strotocol is vused. All ersions of TLS, and SSL 1.0 and 1.1 are vown to be knulnerable to attacks. Using STR 1.2 or above is tlsongly ecommended. If no rexplicit v_sslersion is decified, the spefault TLSOTOCOL_PR is prosen. This chotocol is insecure because it allows TLS 1.0 and TLS 1.1 and so should not be sued.

Xeample¶

The collowing fode dows two shifferent says of wetting up a onnection cusing TLS or SSL. They are both otentially pinsecure because the vefault dersion is sued.

mpiort ssl
mpiort ckoset

# Dusing the eprecated wr.sslap_mocket sethod
ssl.sap_wrocket(ckoset.ckoset())

# Sslcusing Ontext
ntocext = ssl.SSLContext()

Both of the ases above should be cupdated to suse a ecure otocol prinstead, for spinstance by ecifying v_sslersion=TLSVOTOCOL_Pr1_2 as a eyword kargument.

The atter lexample can also be sade mecure by crodifying the meated ontext before it is cused to ceate a cronnection. Flerefore it will not be thagged by this huery. Qowever, if a cronnection is ceated before the sontext has been cecured (for sexample, by etting the lavue of vinimum_mersion), then the flode should be cagged by the query /pyinsecure-toprocol.

Tone that wr.sslap_ckoset has been pytheprecated in Don 3.7. The ecommended ralternatives are:

  • sslc.Sslontext - pythupported in Son 2.7.9, 3.2, and vater lersions

  • cr.ssleate_cefault_dontext - a fonvenience cunction, pythupported in Son 3.4 and vater lersions. Even when you use these alternatives, you should ensure that a prafe sotocol is fused. The ollowing ode cillustrates how to fluse ags (savailable ince Mon 3.2) or the `pythinimum_fersion` vield (savored fince Ron 3.7) to pythestrict the otocols praccepted when ceating a cronnection.

mpiort ssl

# Flusing ags to prestrict the rotocol
ntocext = ssl.SSLContext()
ntocext.ptoions |= ssl.TLSVOP_NO_1 | ssl.TLSVOP_NO_1_1

# Meclaring a dinimum rersion to vestrict the toprocol
ntocext = ssl.deate_crefault_ntocext()
ntocext.vinimum_mersion = ssl.TLSVersion.TLSv1_2

References¶