Skip to content

detect: add keywords for LDAPDN - v3#12556

Closed
AkakiAlice wants to merge 3 commits intoOISF:masterfrom
AkakiAlice:detect-ldap-dn-7471-v3
Closed

detect: add keywords for LDAPDN - v3#12556
AkakiAlice wants to merge 3 commits intoOISF:masterfrom
AkakiAlice:detect-ldap-dn-7471-v3

Conversation

@AkakiAlice
Copy link
Contributor

Ticket: #7471

Contribution style:

Our Contribution agreements:

Changes (if applicable):

Link to ticket: https://redmine.openinfosecfoundation.org/issues/7471

Description:

  • Implement keywords ldap.request.dn and ldap.responses.dn

Changes:

  • Change commit message

SV_BRANCH=OISF/suricata-verify#2278
Previous PR: #12545

ldap.request.dn matches on LDAPDN from request operations
This keyword maps the following eve fields:
ldap.request.bind_request.name
ldap.request.add_request.entry
ldap.request.search_request.base_object
ldap.request.modify_request.object
ldap.request.del_request.dn
ldap.request.mod_dn_request.entry
ldap.request.compare_request.entry
It is a sticky buffer
Supports prefiltering

Ticket: OISF#7471
ldap.responses.dn matches on LDAPDN from responses operations
This keyword maps the following eve fields:
ldap.responses[].search_result_entry.base_object
ldap.responses[].bind_response.matched_dn
ldap.responses[].search_result_done.matched_dn
ldap.responses[].modify_response.matched_dn
ldap.responses[].add_response.matched_dn
ldap.responses[].del_response.matched_dn
ldap.responses[].mod_dn_response.matched_dn
ldap.responses[].compare_response.matched_dn
ldap.responses[].extended_response.matched_dn
It is a sticky buffer
Supports prefiltering

Ticket: OISF#7471
@codecov
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 85.81560% with 20 lines in your changes missing coverage. Please review.

Project coverage is 80.70%. Comparing base (ef044b2) to head (8e268b4).
Report is 45 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12556      +/-   ##
==========================================
- Coverage   80.71%   80.70%   -0.02%     
==========================================
  Files         928      928              
  Lines      259007   259132     +125     
==========================================
+ Hits       209063   209136      +73     
- Misses      49944    49996      +52     
Flag Coverage Δ
fuzzcorpus 56.93% <36.87%> (-0.03%) ⬇️
livemode 19.41% <36.87%> (+<0.01%) ⬆️
pcap 44.21% <36.87%> (-0.03%) ⬇️
suricata-verify 63.39% <85.81%> (+<0.01%) ⬆️
unittests 58.35% <36.87%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work

CI : ✅
Code : good
Commits segmentation : ok, nice
Commit messages : good, could also specify the responses keyword is a multi-buffer
Git ID set : looks fine for me
CLA : you already contributed
Doc update : thanks
Redmine ticket : ok, updated to in review
Rustfmt : good
Tests : approved SV


.. container:: example-rule

alert tcp any any -> any any (msg:"Test LDAPDN"; :example-rule-emphasis:`ldap.request.dn:uid=jdoe,ou=People,dc=example,dc=com;` sid:1;)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be more explicit alert ldap


.. container:: example-rule

alert tcp any any -> any any (msg:"Test LDAPDN and operation"; :example-rule-emphasis:`ldap.responses.operation:search_result_entry; ldap.responses.dn:dc=example,dc=com;` sid:1;) No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that these may be in different response like ldap.responses[0] has operation:search_result_entry and ldap.reponses[1] has dn:dc=example,dc=com

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be added as a note in this section?


.. container:: example-rule

alert tcp any any -> any any (msg:"Test LDAPDN and operation"; :example-rule-emphasis:`ldap.request.operation:search_request; ldap.request.dn:dc=example,dc=com;` sid:1;)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ rule does not work, misses content keyword

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same applies to the other examples, right?

Copy link
Contributor

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example rules need to work copy pasted ;-)

Copy link
Contributor

@jufajardini jufajardini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more notes for the docs section. :)


``ldap.request.dn`` is a 'sticky buffer' and can be used as a ``fast_pattern``.

This keyword maps to the eve fields:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
This keyword maps to the eve fields:
This keyword maps to the EVE fields:

Comment on lines +198 to +199
It is possible to use the keyword ``ldap.request.operation`` in the same rule to specify the operation to match.
Here is an example of a signature that would alert if a packet has an LDAP search request operation and contains the LDAP distinguished name ``dc=example,dc=com``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits to remove extra space and to conform line length to ideal character limits :P

Suggested change
It is possible to use the keyword ``ldap.request.operation`` in the same rule to specify the operation to match.
Here is an example of a signature that would alert if a packet has an LDAP search request operation and contains the LDAP distinguished name ``dc=example,dc=com``.
It is possible to use the keyword ``ldap.request.operation`` in the same rule to
specify the operation to match.
Here is an example of a signature that would alert if a packet has an LDAP
search request operation and contains the LDAP distinguished name
``dc=example,dc=com``.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same idea applies to the other section.


.. container:: example-rule

alert tcp any any -> any any (msg:"Test LDAPDN and operation"; :example-rule-emphasis:`ldap.request.operation:search_request; ldap.request.dn:dc=example,dc=com;` sid:1;)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same applies to the other examples, right?


.. container:: example-rule

alert tcp any any -> any any (msg:"Test LDAPDN and operation"; :example-rule-emphasis:`ldap.responses.operation:search_result_entry; ldap.responses.dn:dc=example,dc=com;` sid:1;) No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be added as a note in this section?

@AkakiAlice
Copy link
Contributor Author

Replaced by: #12620

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants