Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea8c6f0

Browse files
committed
Python: Update old test and qlhelp
1 parent 87e1a06 commit ea8c6f0

3 files changed

Lines changed: 31 additions & 7 deletions

File tree

python/ql/src/Security/CWE-327/InsecureProtocol.qhelp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
<p>
1515
Ensure that a modern, strong protocol is used. All versions of SSL,
16-
and TLS 1.0 are known to be vulnerable to attacks. Using TLS 1.1 or
17-
above is strongly recommended.
16+
and TLS versions 1.0 and 1.1 are known to be vulnerable to attacks.
17+
Using TLS 1.2 or above is strongly recommended.
1818
</p>
1919

2020
</recommendation>
@@ -30,7 +30,7 @@
3030

3131
<p>
3232
All cases should be updated to use a secure protocol, such as
33-
<code>PROTOCOL_TLSv1_1</code>.
33+
<code>PROTOCOL_TLSv1_2</code>.
3434
</p>
3535
<p>
3636
Note that <code>ssl.wrap_socket</code> has been deprecated in
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Current status (Feb 2021)
2+
3+
This should be kept up to date; the world is moving fast and protocols are being broken.
4+
5+
## Protocols
6+
7+
- All versions of SSL are insecure
8+
- TLS 1.0 and TLS 1.1 are insecure
9+
- TLS 1.2 have some issues. but TLS 1.3 is not widely supported
10+
11+
## Conection methods
12+
13+
- `ssl.wrap_socket` is creating insecure connections, use `SSLContext.wrap_socket` instead. [link](https://docs.python.org/3/library/ssl.html#ssl.wrap_socket)
14+
> Deprecated since version 3.7: Since Python 3.2 and 2.7.9, it is recommended to use the `SSLContext.wrap_socket()` instead of `wrap_socket()`. The top-level function is limited and creates an insecure client socket without server name indication or hostname matching.
15+
- Default consteructors are fine, a sluent api is used to constrain possible protocols later.
16+
17+
## Current recomendation
18+
19+
TLS 1.2 or TLS 1.3
20+
21+
## Queries
22+
23+
- `InsecureProtocol` detects uses of insecure protocols.
24+
- `InsecureDefaultProtocol` detect default constructions, this is no longer unsafe.

python/ql/test/query-tests/Security/CWE-327/InsecureProtocol.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ssl
2-
from pyOpenSSL import SSL
2+
from OpenSSL import SSL
33
from ssl import SSLContext
44

55
# true positives
@@ -33,9 +33,9 @@
3333

3434
# secure versions
3535

36-
ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_1)
37-
SSLContext(protocol=ssl.PROTOCOL_TLSv1_1)
38-
SSL.Context(SSL.TLSv1_1_METHOD)
36+
ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_2)
37+
SSLContext(protocol=ssl.PROTOCOL_TLSv1_2)
38+
SSL.Context(SSL.TLSv1_2_METHOD)
3939

4040
# possibly insecure default
4141
ssl.wrap_socket()

0 commit comments

Comments
 (0)