Dataset match subdomain/v2 - #15073
Conversation
Ticket: 8385 Add a new match subdomain option that enables blocking a domain and all its subdomains using datasets.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #15073 +/- ##
=======================================
Coverage 82.59% 82.60%
=======================================
Files 990 990
Lines 271761 271806 +45
=======================================
+ Hits 224465 224522 +57
+ Misses 47296 47284 -12
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
catenacyber
left a comment
There was a problem hiding this comment.
Thanks for the work
CI : ✅
Code : good
Commits segmentation : I would squash but ok
Commit messages : nice
Git ID set : looks fine for me
CLA : you already contributed
Doc update : ok
Redmine ticket : ok
Rustfmt : no rust
Tests : cool
Dependencies added: none
| #define DETECT_DATASET_CMD_ISNOTSET 2 | ||
| #define DETECT_DATASET_CMD_ISSET 3 | ||
|
|
||
| #define DATASET_SUBDOMAIN_MAX_LOOKUPS 126 |
There was a problem hiding this comment.
So, where did you find this constant ?
There was a problem hiding this comment.
A valid domain name is limited to 253 bytes (whether it's dns, http host, tls sni, ...), giving at most 126 labels (1 char + 1 dot per label). Buffers like http.host are not length enforced, but anything beyond that limit is malformed or malicious and shouldn't match the dataset entry.
There was a problem hiding this comment.
Cool
A valid domain name is limited to 253 bytes
Where did you find this ?
There was a problem hiding this comment.
RFC 1035 defines it for DNS. (it's actually 255 bytes but a length byte and a null terminator byte are needed, hence the 253)
So maybe my statement up there wasn't 100% accurate :) While an http.host can exceed the 253 limit, it would not be a "globally resolvable domain". Perhaps used for an internal/private network?
|
@victorjulien @catenacyber any updates on this? also would it be possible to backport it? |
|
Thanks for your work, it is fine for me. We are waiting on Victor's review... |
|
|
||
| .. container:: example-rule | ||
|
|
||
| reject dns any any -> any any (msg:"Blocked domain"; dns.query; dotprefix; dataset:isset,blocked-domains, type string, match subdomain, load blocked-domains.lst; sid:8000003; rev:1;) |
There was a problem hiding this comment.
This is leading to a CI failure for Check rules doc: Error: detect-dataset: failed to set up dataset 'blocked-domains'. [DetectDatasetSetup:detect-dataset.c:640]
https://github.com/OISF/suricata/actions/runs/27315514634/job/80695160734?pr=15601#step:22:12
There was a problem hiding this comment.
Is it because of load blocked-domains.lst? It's trying to find the file relative to the path of the rule file itself. Examples 1 and 2 use state instead of load.
There was a problem hiding this comment.
I think this just may show a limitation of the check. I don't think it is aware of how datasets needs a file to load here. I'd say the check is wrong, not this doc example.
|
Merged in #15601, thanks! |
Hi @antoineaboufayssal if you could prepare a backport patch for this so we can review and test, we'll consider backporting it :) |
done! #16024 |
Previously #15058
Contribution style:
https://docs.suricata.io/en/latest/devguide/contributing/contribution-process.html
Our Contribution agreements:
https://suricata.io/about/contribution-agreement/ (note: this is only required once)
Changes (if applicable):
https://redmine.openinfosecfoundation.org/projects/suricata/issues
Link to ticket: https://redmine.openinfosecfoundation.org/issues/8385
Describe changes:
SV_BRANCH=OISF/suricata-verify#2979