Skip to content

Commit cb58936

Browse files
committed
Documentation changes
1 parent 752620a commit cb58936

File tree

5 files changed

+55
-28
lines changed

5 files changed

+55
-28
lines changed

java/ql/src/Security/CWE/CWE-522/InsecureLdapAuth.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

java/ql/src/Security/CWE/CWE-522/InsecureLdapAuth.qhelp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,40 @@
22
<qhelp>
33

44
<overview>
5-
<p>When using the Java LDAP API to perform LDAPv3-style extended operations and controls, a context with connection properties including user credentials is started. Transmission of LDAP credentials in cleartext allows remote attackers to obtain sensitive information by sniffing the network.</p>
5+
<p>
6+
When using the Java LDAP API to perform LDAPv3-style extended operations
7+
and controls, a context with connection properties including user
8+
credentials is started. Transmission of LDAP credentials in cleartext
9+
allows remote attackers to obtain sensitive information by sniffing the
10+
network.
11+
</p>
612
</overview>
713

814
<recommendation>
9-
<p>Use LDAPS to send credentials through SSL or use SASL authentication.</p>
15+
<p>
16+
Use the <code>ldaps://</code> protocol to send credentials through SSL or
17+
use SASL authentication.
18+
</p>
1019
</recommendation>
1120

1221
<example>
13-
<p>The following example shows two ways of using LDAP authentication. In the 'BAD' case, the credentials are transmitted in cleartext. In the 'GOOD' case, the credentials are transmitted over SSL.</p>
14-
<sample src="InsecureLdapAuth.java" />
22+
<p>
23+
In the following (bad) example, a <code>ldap://</code> URL is used and
24+
credentials will be sent in plaintext.
25+
</p>
26+
<sample src="LdapAuthUseLdap.java"/>
27+
28+
<p>
29+
In the following (good) example, a <code>ldaps://</code> URL is used so
30+
credentials will be encrypted with SSL.
31+
</p>
32+
<sample src="LdapAuthUseLdaps.java"/>
33+
34+
<p>
35+
In the following (good) example, a <code>ldap://</code> URL is used, but
36+
SASL authentication is enabled.
37+
</p>
38+
<sample src="LdapEnableSasl.java"/>
1539
</example>
1640

1741
<references>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
String ldapUrl = "ldap://ad.your-server.com:389";
2+
Hashtable<String, String> environment = new Hashtable<String, String>();
3+
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
4+
environment.put(Context.PROVIDER_URL, ldapUrl);
5+
environment.put(Context.REFERRAL, "follow");
6+
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
7+
environment.put(Context.SECURITY_PRINCIPAL, ldapUserName);
8+
environment.put(Context.SECURITY_CREDENTIALS, password);
9+
DirContext dirContext = new InitialDirContext(environment);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
String ldapUrl = "ldaps://ad.your-server.com:636";
2+
Hashtable<String, String> environment = new Hashtable<String, String>();
3+
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
4+
environment.put(Context.PROVIDER_URL, ldapUrl);
5+
environment.put(Context.REFERRAL, "follow");
6+
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
7+
environment.put(Context.SECURITY_PRINCIPAL, ldapUserName);
8+
environment.put(Context.SECURITY_CREDENTIALS, password);
9+
DirContext dirContext = new InitialDirContext(environment);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
String ldapUrl = "ldap://ad.your-server.com:389";
2+
Hashtable<String, String> environment = new Hashtable<String, String>();
3+
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
4+
environment.put(Context.PROVIDER_URL, ldapUrl);
5+
environment.put(Context.REFERRAL, "follow");
6+
environment.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5 GSSAPI");
7+
environment.put(Context.SECURITY_PRINCIPAL, ldapUserName);
8+
environment.put(Context.SECURITY_CREDENTIALS, password);
9+
DirContext dirContext = new InitialDirContext(environment);

0 commit comments

Comments
 (0)