Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
57886e1
Moved files from experimental to src/
egregius313 Mar 2, 2023
5ff4fcb
Replace `exists` with `any`
egregius313 Mar 2, 2023
938d953
Refactor getLeftmostOperand method
egregius313 Mar 3, 2023
9275b54
Refactoring the InsecureLdapUrl constructor
egregius313 Mar 7, 2023
3936aea
Split Ldap query file into libraries
egregius313 Mar 9, 2023
98b445c
Convert test to InlineExpectationsTest
egregius313 Mar 9, 2023
05da1dc
Merge concatInsecureLdapString into InsecureLdapUrl constructor
egregius313 Mar 9, 2023
6a0167f
Convert to using the new DataFlow modules
egregius313 Mar 9, 2023
db60c08
Add security severity
egregius313 Mar 9, 2023
0f4709e
Add change note
egregius313 Mar 9, 2023
59ce0d7
Documentation changes
egregius313 Mar 9, 2023
efdfc2d
Change version of PathNode used to appropriate module
egregius313 Mar 9, 2023
752620a
Rename SSL configuration and fix PathGraph
egregius313 Mar 9, 2023
cb58936
Documentation changes
egregius313 Mar 10, 2023
658c54a
Change names of configuration to fit new naming convention
egregius313 Mar 10, 2023
151357d
Make classes/predicates not used outside of query private
egregius313 Mar 17, 2023
24d4859
Import changes
egregius313 Mar 17, 2023
f28f1af
Add `InsecureLdapUrlSink`
egregius313 Mar 17, 2023
0eaf222
Move public classes/predicates to top of library file
egregius313 Mar 17, 2023
43d79dc
Apply docs review suggestions
egregius313 Mar 24, 2023
106e5e7
Docs review suggestion
egregius313 Mar 24, 2023
9bfb13b
Update to the `Global`/`flow*` api
egregius313 Mar 27, 2023
97ec808
Make configuration public
egregius313 Mar 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Documentation changes
  • Loading branch information
egregius313 committed Mar 27, 2023
commit cb58936c083d1a5943fa2fd68fd3a1d8ef6c6b77
24 changes: 0 additions & 24 deletions java/ql/src/Security/CWE/CWE-522/InsecureLdapAuth.java

This file was deleted.

32 changes: 28 additions & 4 deletions java/ql/src/Security/CWE/CWE-522/InsecureLdapAuth.qhelp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,40 @@
<qhelp>

<overview>
<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>
<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>
</overview>

<recommendation>
<p>Use LDAPS to send credentials through SSL or use SASL authentication.</p>
<p>
Use the <code>ldaps://</code> protocol to send credentials through SSL or
use SASL authentication.
</p>
</recommendation>

<example>
<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>
<sample src="InsecureLdapAuth.java" />
<p>
In the following (bad) example, a <code>ldap://</code> URL is used and
credentials will be sent in plaintext.
</p>
<sample src="LdapAuthUseLdap.java"/>

<p>
In the following (good) example, a <code>ldaps://</code> URL is used so
credentials will be encrypted with SSL.
</p>
<sample src="LdapAuthUseLdaps.java"/>

<p>
In the following (good) example, a <code>ldap://</code> URL is used, but
SASL authentication is enabled.
Comment thread
egregius313 marked this conversation as resolved.
Outdated
</p>
<sample src="LdapEnableSasl.java"/>
</example>

<references>
Expand Down
9 changes: 9 additions & 0 deletions java/ql/src/Security/CWE/CWE-522/LdapAuthUseLdap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
String ldapUrl = "ldap://ad.your-server.com:389";
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.PROVIDER_URL, ldapUrl);
environment.put(Context.REFERRAL, "follow");
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
environment.put(Context.SECURITY_PRINCIPAL, ldapUserName);
environment.put(Context.SECURITY_CREDENTIALS, password);
DirContext dirContext = new InitialDirContext(environment);
9 changes: 9 additions & 0 deletions java/ql/src/Security/CWE/CWE-522/LdapAuthUseLdaps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
String ldapUrl = "ldaps://ad.your-server.com:636";
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.PROVIDER_URL, ldapUrl);
environment.put(Context.REFERRAL, "follow");
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
environment.put(Context.SECURITY_PRINCIPAL, ldapUserName);
environment.put(Context.SECURITY_CREDENTIALS, password);
DirContext dirContext = new InitialDirContext(environment);
9 changes: 9 additions & 0 deletions java/ql/src/Security/CWE/CWE-522/LdapEnableSasl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
String ldapUrl = "ldap://ad.your-server.com:389";
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.PROVIDER_URL, ldapUrl);
environment.put(Context.REFERRAL, "follow");
environment.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5 GSSAPI");
environment.put(Context.SECURITY_PRINCIPAL, ldapUserName);
environment.put(Context.SECURITY_CREDENTIALS, password);
DirContext dirContext = new InitialDirContext(environment);