Skip to content

Commit 64b305c

Browse files
committed
Add .qhelp along with its example
1 parent 786edb7 commit 64b305c

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE qhelp PUBLIC
2+
"-//Semmle//qhelp//EN"
3+
"qhelp.dtd">
4+
<qhelp>
5+
6+
<overview>
7+
<p>Failing to ensure the utilization of SSL in an LDAP connection can cause the entire communication
8+
to be sent in cleartext making it easier for an attacker to intercept it.</p>
9+
</overview>
10+
11+
<recommendation>
12+
<p>Always set <code>use_SSL</code> to <code>True</code>, call <code>start_tls_s()</code> or set a proper option flag (<code>ldap.OPT_X_TLS_XXXXXX</code>).</p>
13+
</recommendation>
14+
15+
<example>
16+
<p>This example shows both good and bad ways to deal with this issue under Python 3.</p>
17+
18+
<p>The first one sets <code>use_SSL</code> to true as a keyword argument whereas the second one fails to provide a value for it, so
19+
the default one is used (<code>False</code>).</p>
20+
<sample src="LDAPInsecureAuth.py" />
21+
</example>
22+
23+
</qhelp>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from ldap3 import Server, Connection, ALL
2+
from flask import request, Flask
3+
4+
app = Flask(__name__)
5+
6+
7+
@app.route("/good")
8+
def good():
9+
srv = Server(host, port, use_ssl=True)
10+
conn = Connection(srv, dn, password)
11+
conn.search(dn, search_filter)
12+
return conn.response
13+
14+
15+
@app.route("/bad")
16+
def bad():
17+
srv = Server(host, port)
18+
conn = Connection(srv, dn, password)
19+
conn.search(dn, search_filter)
20+
return conn.response

python/ql/test/experimental/query-tests/Security/CWE-522/ldap3_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def eight():
101101
host = schema + "somethingon.theinternet.com"
102102
srv = Server(host, port=1337)
103103
conn = Connection(srv, "dn", "password")
104-
conn.start_tls() # !
104+
conn.start_tls()
105105
conn.search("dn", "search_filter")
106106
return conn.response
107107

0 commit comments

Comments
 (0)