Skip to content

Commit 7f7ad88

Browse files
committed
Limit LdapAdditionalTaintStep to Ldap configuration
1 parent a141140 commit 7f7ad88

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

java/ql/src/Security/CWE/CWE-090/LdapInjectionLib.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ class LdapInjectionFlowConfig extends TaintTracking::Configuration {
1414
override predicate isSink(DataFlow::Node sink) { sink instanceof LdapInjectionSink }
1515

1616
override predicate isSanitizer(DataFlow::Node node) { node instanceof LdapInjectionSanitizer }
17+
18+
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
19+
any(LdapInjectionAdditionalTaintStep a).step(pred, succ)
20+
}
1721
}

java/ql/src/semmle/code/java/security/LdapInjection.qll

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ abstract class LdapInjectionSink extends DataFlow::Node { }
1313
/** A sanitizer that prevents LDAP injection attacks. */
1414
abstract class LdapInjectionSanitizer extends DataFlow::Node { }
1515

16+
private newtype TUnit = TMkUnit()
17+
18+
class Unit extends TUnit {
19+
string toString() { result = "unit" }
20+
}
21+
22+
/**
23+
* A unit class for adding additional taint steps.
24+
*
25+
* Extend this class to add additional taint steps that should apply to the LdapInjectionFlowConfig.
26+
*/
27+
class LdapInjectionAdditionalTaintStep extends Unit {
28+
abstract predicate step(DataFlow::Node node1, DataFlow::Node node2);
29+
}
30+
1631
/** Default sink for LDAP injection vulnerabilities. */
1732
private class DefaultLdapInjectionSink extends LdapInjectionSink {
1833
DefaultLdapInjectionSink() {
@@ -374,7 +389,7 @@ private predicate apacheLdapDnGetStep(DataFlow::ExprNode n1, DataFlow::ExprNode
374389
}
375390

376391
/** A set of additional taint steps to consider when taint tracking LDAP related data flows. */
377-
class LdapInjectionAdditionalTaintStep extends TaintTracking::AdditionalTaintStep {
392+
private class DefaultLdapInjectionAdditionalTaintStep extends LdapInjectionAdditionalTaintStep {
378393
override predicate step(DataFlow::Node node1, DataFlow::Node node2) {
379394
ldapNameStep(node1, node2) or
380395
ldapNameAddAllStep(node1, node2) or

0 commit comments

Comments
 (0)