Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
799d509
Upload LDAP Injection query, qhelp and tests
jorgectf Mar 18, 2021
719b48c
Move to experimental folder
jorgectf Mar 18, 2021
95a1dae
Precision warn and Remove CWE reference
jorgectf Mar 18, 2021
85ec82a
Refactor in progress
jorgectf Mar 28, 2021
ad36bea
Refactor LDAP3 stuff (untested)
jorgectf Mar 29, 2021
8223539
Add a test without attributes
jorgectf Mar 29, 2021
3cda2e5
Polish up ldap3 tests
jorgectf Mar 29, 2021
8faafb6
Update Sink
jorgectf Mar 30, 2021
4328ff3
Remove attrs feature
jorgectf Mar 31, 2021
9b43031
Improve Sanitizer calls
jorgectf Mar 31, 2021
1bcb9cd
Simplify query
jorgectf Apr 6, 2021
33423ea
Optimize calls
jorgectf Apr 7, 2021
a1850dd
Change LDAP config (qll) filename
jorgectf Apr 8, 2021
8661cb0
Polish LDAP3Query
jorgectf Apr 8, 2021
7296879
Polish tests
jorgectf Apr 8, 2021
3c1ca72
Improve qhelp
jorgectf Apr 8, 2021
1554f4f
Create qhelp examples
jorgectf Apr 8, 2021
95bfdc4
Move tests to /test
jorgectf Apr 8, 2021
4f85de8
Add qlref
jorgectf Apr 8, 2021
7819d1a
Generate .expected
jorgectf Apr 8, 2021
b405c67
Add qhelp last newline
jorgectf Apr 8, 2021
82f47f8
Polish metadata
jorgectf Apr 8, 2021
cd75433
Fix qhelp examples extension
jorgectf Apr 8, 2021
a2e8d88
Write documentation
jorgectf Apr 8, 2021
b020ea6
Polish documentation
jorgectf Apr 8, 2021
1c34230
Fix documentation typo
jorgectf Apr 8, 2021
c2b96b3
Add documentation to main classes' functions.
jorgectf May 7, 2021
34b8af3
Move structure to LDAP.qll
jorgectf May 7, 2021
6159fbe
Update functions naming
jorgectf May 7, 2021
2ad72ad
Add LDAP framework entry in Frameworks.qll
jorgectf May 7, 2021
8665747
Update sink and sanitizer to match new naming
jorgectf May 8, 2021
9e9678b
Apply documentation suggestions
jorgectf May 21, 2021
37d6ff7
Update tests and .expected
jorgectf May 21, 2021
d5f2846
Merge branch 'main' into jorgectf/python/ldapInjection
RasmusWL May 26, 2021
f807c2f
Python: autoformat
RasmusWL May 26, 2021
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
Remove attrs feature
  • Loading branch information
jorgectf committed Mar 31, 2021
commit 4328ff398121d12f800a67a3edc0cd72ea2bf77e
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ from
LDAPInjectionSink castedSink
where
config.hasFlowPath(source, sink) and
castedSink.getLDAPNode() = sink.getNode() //and
// if exists(castedSink.getAttrs()) then
castedSink.getLDAPNode() = sink.getNode()
select sink.getNode(), source, sink, "$@ LDAP query executes $@ as a $@.", castedSink, "This",
source.getNode(), "a user-provided value", castedSink.getLDAPNode(), castedSink.getLDAPPart() //, castedSink.getAttrs(), "probably leaking this attribute(s)"
source.getNode(), "a user-provided value", castedSink.getLDAPNode(), castedSink.getLDAPPart()
4 changes: 0 additions & 4 deletions python/ql/src/experimental/semmle/python/Concepts.qll
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ module LDAPQuery {
abstract DataFlow::Node getLDAPNode();

abstract string getLDAPPart();
Comment thread
jorgectf marked this conversation as resolved.
Outdated

abstract DataFlow::Node getAttrs();
}
}

Expand All @@ -33,8 +31,6 @@ class LDAPQuery extends DataFlow::Node {
DataFlow::Node getLDAPNode() { result = range.getLDAPNode() }
Comment thread
jorgectf marked this conversation as resolved.
Outdated

string getLDAPPart() { result = range.getLDAPPart() }

DataFlow::Node getAttrs() { result = range.getAttrs() }
}

module LDAPEscape {
Expand Down
11 changes: 0 additions & 11 deletions python/ql/src/experimental/semmle/python/frameworks/Stdlib.qll
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ private module LDAP {
private class LDAP2Query extends DataFlow::CallCfgNode, LDAPQuery::Range {
DataFlow::Node ldapNode;
string ldapPart;
DataFlow::Node attrs;

LDAP2Query() {
exists(DataFlow::AttrRead searchMethod, DataFlow::CallCfgNode initCall |
Expand All @@ -45,10 +44,6 @@ private module LDAP {
override DataFlow::Node getLDAPNode() { result = ldapNode }

override string getLDAPPart() { result = ldapPart }

override DataFlow::Node getAttrs() {
result = this.getArg(3) or result = this.getArgByName("attrlist")
}
}

private class LDAP2EscapeDN extends DataFlow::CallCfgNode, LDAPEscape::Range {
Expand Down Expand Up @@ -77,14 +72,12 @@ private module LDAP {

private module LDAP3 {
private class LDAP3QueryMethods extends string {
// pending to dig into this although https://github.com/cannatag/ldap3/blob/21001d9087c0d24c399eec433a261c455b7bc97f/ldap3/core/connection.py#L760
LDAP3QueryMethods() { this in ["search"] }
}

private class LDAP3Query extends DataFlow::CallCfgNode, LDAPQuery::Range {
DataFlow::Node ldapNode;
string ldapPart;
DataFlow::Node attrs;

LDAP3Query() {
exists(DataFlow::AttrRead searchMethod, DataFlow::CallCfgNode connCall |
Expand All @@ -105,10 +98,6 @@ private module LDAP {
override DataFlow::Node getLDAPNode() { result = ldapNode }

override string getLDAPPart() { result = ldapPart }

override DataFlow::Node getAttrs() {
result = this.getArg(3) or result = this.getArgByName("attributes")
}
}

private class LDAP3EscapeDN extends DataFlow::CallCfgNode, LDAPEscape::Range {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ import semmle.python.dataflow.new.TaintTracking
import semmle.python.dataflow.new.RemoteFlowSources

class LDAPInjectionSink extends DataFlow::Node {
// DataFlow::Node attrs;
DataFlow::Node ldapNode;
string ldapPart;

LDAPInjectionSink() {
exists(LDAPQuery ldapQuery |
this = ldapQuery and
ldapNode = ldapQuery.getLDAPNode() and
ldapPart = ldapQuery.getLDAPPart() // and
// if exists(ldapQuery.getAttrs()) then attrs = ldapQuery.getAttrs()
ldapPart = ldapQuery.getLDAPPart()
)
}

DataFlow::Node getLDAPNode() { result = ldapNode }

string getLDAPPart() { result = ldapPart }
// DataFlow::Node getAttrs() { result = attrs }
}

/**
Expand Down