* [New BBR] AWS RDS DB Snapshot Created ... * Squashed commit of the following: commit6746a421c4Author: Ruben Groenewoud <78494512+Aegrah@users.noreply.github.com> Date: Tue Jun 25 16:14:28 2024 +0200 [New Rules] Yum Plugin Creation / Discovery (#3820) * [New Rules] Yum Plugin Creation / Discovery * Update discovery_yum_plugin_detection.toml * Update and rename discovery_yum_plugin_detection.toml to discovery_yum_dnf_plugin_detection.toml commit632e169f7aAuthor: Terrance DeJesus <99630311+terrancedejesus@users.noreply.github.com> Date: Tue Jun 25 09:35:36 2024 -0400 [Hunt Tuning] Add Descriptions, Collapse Queries and Re-Generate Docs (#3791) * add description to hunting schema; change queries to be a list * update createremotethreat by process hunt * update dll hijack and masquerading as MSFT library * remove sysmon specific dDLL hijack via masquerading MSFT library * updated Masquerading Attempts as Native Windows Binaries * updates Rare DLL Side-Loading by Occurrence * updates Rare LSASS Process Access Attempts * update DNS Queries via LOLBins with Low Occurence Frequency * updated Low Occurrence of Drivers Loaded on Unique Hosts * updates Excessive RDP Network Activity by Host and User * updates Excessive SMB Network Activity by Process ID * updated Executable File Creation by an Unusual Microsoft Binary * Frequency of Process Execution and Network Logon by Source Address * updates Frequency of Process Execution and Network Logon by Source Address * updated Execution via Remote Services by Client Address * updated Startup Execution with Low Occurrence Frequency by Unique Host * updated Low Frequency of Process Execution via WMI by Unique Agent * updated Low Frequency of Process Execution via Windows Scheduled Task by Unique Agent * updated Low Occurence of Process Execution via Windows Services with Unique Agent * Updated High Count of Network Connection Over Extended Period by Process * update Libraries Loaded by svchost with Low Occurrence Frequency * updated Microsoft Office Child Processes with Low Occurrence Frequency by Unique Agent * updated Network Discovery via Sensitive Ports by Unusual Process * updated PE File Transfer via SMB_Admin Shares by Agent or User * updated Persistence via Run Key with Low Occurrence Frequency * updates Persistence via Startup with Low Occurrence Frequency by Unique Host * updates "Persistence via Run Key with Low Occurrence Frequency"; adjusted file names to remove data source * updates "Low Occurrence of Suspicious Launch Agent or Launch Daemon" * updates "Egress Network Connections with Total Bytes Greater than Threshold" * updates "Rundll32 Execution Aggregated by Command Line" * updates "Scheduled tasks Creation by Action via Registry" * updates "Scheduled Tasks Creation for Unique Hosts by Task Command" * updates "Suspicious Base64 Encoded Powershell Command" * updates "Suspicious DNS TXT Record Lookups by Process" * updates "Unique Windows Services Creation by Service File Name" * Updates "Unique Windows Services Creation by Service File Name" * updates "Windows Command and Scripting Interpreter from Unusual Parent Process" * updates "Windows Logon Activity by Source IP" * updates "Suspicious Network Connections by Unsigned Mach-O" * updates LLM hunting queries * re-generated markdown files; updated generate markdown py file * updated test_hunt_data * Update hunting/macos/queries/suspicious_network_connections_by_unsigned_macho.toml Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> * Update hunting/windows/queries/drivers_load_with_low_occurrence_frequency.toml Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> * Update hunting/windows/queries/domain_names_queried_via_lolbins_and_with_low_occurence_frequency.toml Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> * Update hunting/windows/queries/excessive_rdp_network_activity_by_source_host_and_user.toml Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> * Update hunting/windows/queries/excessive_rdp_network_activity_by_source_host_and_user.toml Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> * updated missing integrations * updated MD docs according to recent hunting changes * Update hunting/windows/queries/executable_file_creation_by_an_unusual_microsoft_binary.toml Co-authored-by: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> * Update hunting/windows/queries/detect_rare_dll_sideload_by_occurrence.toml Co-authored-by: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> * Update hunting/windows/queries/detect_masquerading_attempts_as_native_windows_binaries.toml Co-authored-by: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> * Update hunting/windows/queries/detect_dll_hijack_via_masquerading_as_microsoft_native_libraries.toml Co-authored-by: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> * Update hunting/llm/queries/aws_bedrock_dos_resource_exhaustion_detection.toml Co-authored-by: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> * added enrichment policy link to rule * Update hunting/windows/docs/execution_via_windows_management_instrumentation_by_occurrence_frequency_by_unique_agent.md Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/docs/windows_command_and_scripting_interpreter_from_unusual_parent.md Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/docs/windows_command_and_scripting_interpreter_from_unusual_parent.md Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/docs/rundll32_execution_aggregated_by_cmdline.md Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/docs/microsoft_office_child_processes_with_low_occurrence_frequency.md Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/docs/microsoft_office_child_processes_with_low_occurrence_frequency.md Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/queries/execution_via_windows_management_instrumentation_by_occurrence_frequency_by_unique_agent.toml Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/queries/execution_via_windows_management_instrumentation_by_occurrence_frequency_by_unique_agent.toml Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/index.md Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/docs/execution_via_network_logon_by_occurrence_frequency_by_top_source_ip.md Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> * Update hunting/windows/queries/execution_via_network_logon_by_occurrence_frequency_by_top_source_ip.toml Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> --------- Co-authored-by: Mika Ayenson <Mikaayenson@users.noreply.github.com> Co-authored-by: Jonhnathan <26856693+w0rk3r@users.noreply.github.com> Co-authored-by: Samirbous <64742097+Samirbous@users.noreply.github.com> commit6f43d1f535Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue Jun 25 17:58:37 2024 +0530 Lock versions for releases: 8.9,8.10,8.11,8.12,8.13,8.14 (#3821) commit0726ce41bfAuthor: James Valente <65730960+jvalente-salemstate@users.noreply.github.com> Date: Tue Jun 25 07:22:07 2024 -0400 Tune rule to exclude forwarded events. (#3790) Events containing "forwarded" as a tag may include host information that is not related to the host running elastic agent. This triggers false positive alerts. Examples include Entity Analytics integrations, Palo Alto GlobalProtect activity, and M365 Defender device events. Co-authored-by: Ruben Groenewoud <78494512+Aegrah@users.noreply.github.com> commit2708a89f20Author: Isai <59296946+imays11@users.noreply.github.com> Date: Tue Jun 25 00:11:48 2024 -0400 [New Rule] AWS IAM User Created Access Keys for Another User (#3788) * [New Rule] AWS IAM User Created Access Keys for Another User ... * updated min_stack and removed index field * reversed tactic order * added AWS documentation as reference * Apply suggestions from code review updated_date, query format change, removed keep from query commitda8f3e4880Author: Terrance DeJesus <99630311+terrancedejesus@users.noreply.github.com> Date: Fri Jun 21 13:11:23 2024 -0400 [New Rule] Okta Credential Stuffing and Password Spraying Identification via Source, Device Token and Actor (#3797) * adding new rule 'Multiple Okta User Authentication Events with Same Device Token Hash' * adding new rule 'Multiple Okta User Authentication Events with Client Address' * updating UUIDs * removed indexes * adding new rule 'High Number of Okta Device Token Cookies Generated for Authentication' * added okta outcome reason 'INVALID_CREDENTIALS' to queries * updated risk score * made all rules low risk score * added user session start to rule * updated min-stack comments commita131e021edAuthor: Mika Ayenson <Mika.ayenson@elastic.co> Date: Fri Jun 21 11:05:57 2024 -0500 Revert "Test case to check updated_date (#3764)" This reverts commit7621a54fcc. commit7621a54fccAuthor: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> Date: Fri Jun 21 18:43:32 2024 +0530 Test case to check updated_date (#3764) commit675cad2ed4Author: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> Date: Fri Jun 21 18:29:39 2024 +0530 Incorrect Integration Index Check (#3794) * fix technique id
Detection Rules
Detection Rules is the home for rules used by Elastic Security. This repository is used for the development, maintenance, testing, validation, and release of rules for Elastic Security’s Detection Engine.
This repository was first announced on Elastic's blog post, Elastic Security opens public detection rules repo. For additional content, see the accompanying webinar, Elastic Security: Introducing the public repository for detection rules.
Table of Contents
Overview of this repository
Detection Rules contains more than just static rule files. This repository also contains code for unit testing in Python and integrating with the Detection Engine in Kibana.
| folder | description |
|---|---|
detection_rules/ |
Python module for rule parsing, validating and packaging |
etc/ |
Miscellaneous files, such as ECS and Beats schemas |
hunting |
Root directory where threat hunting queries are stored |
kibana/ |
Python library for handling the API calls to Kibana and the Detection Engine |
kql/ |
Python library for parsing and validating Kibana Query Language |
rta/ |
Red Team Automation code used to emulate attacker techniques, used for rule testing |
rules/ |
Root directory where rules are stored |
rules_building_block/ |
Root directory where building block rules are stored |
tests/ |
Python code for unit testing rules |
Getting started
Although rules can be added by manually creating .toml files, we don't recommend it. This repository also consists of a python module that aids rule creation and unit testing. Assuming you have Python 3.12+, run the below command to install the dependencies using the makefile:
✗ make
python3.12 -m pip install --upgrade pip setuptools
Looking in indexes: https://pypi.org/simple
Requirement already satisfied: pip in /opt/homebrew/lib/python3.12/site-packages (24.0)
Requirement already satisfied: setuptools in /opt/homebrew/lib/python3.12/site-packages (69.1.1)
python3.12 -m venv ./env/detection-rules-build
./env/detection-rules-build/bin/pip install --upgrade pip setuptools
Looking in indexes: https://pypi.org/simple
Requirement already satisfied: pip in ./env/detection-rules-build/lib/python3.12/site-packages (24.0)
Collecting setuptools
Using cached setuptools-69.1.1-py3-none-any.whl.metadata (6.2 kB)
Using cached setuptools-69.1.1-py3-none-any.whl (819 kB)
Installing collected packages: setuptools
Successfully installed setuptools-69.1.1
Installing kql and kibana packages...
...
Or install the dependencies using the following command:
$ pip3 install ".[dev]"
Collecting jsl==0.2.4
Downloading jsl-0.2.4.tar.gz (21 kB)
Collecting jsonschema==3.2.0
Downloading jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
|████████████████████████████████| 56 kB 318 kB/s
Collecting requests==2.22.0
Downloading requests-2.22.0-py2.py3-none-any.whl (57 kB)
|████████████████████████████████| 57 kB 1.2 MB/s
Collecting Click==7.0
Downloading Click-7.0-py2.py3-none-any.whl (81 kB)
|████████████████████████████████| 81 kB 2.6 MB/s
...
Note: The kibana and kql packages are not available on PyPI and must be installed from the lib directory.
# Install from the repository
pip3 install git+https://github.com/elastic/detection-rules.git#subdirectory=kibana
pip3 install git+https://github.com/elastic/detection-rules.git#subdirectory=kql
# Or locally for development
pip3 install lib/kibana lib/kql
Remember, make sure to activate your virtual environment if you are using one. If installed via make, the associated virtual environment is created in env/detection-rules-build/.
If you are having trouble using a Python 3.12 environment, please see the relevant section in our troubleshooting guide.
To confirm that everything was properly installed, run with the --help flag
$ python -m detection_rules --help
Usage: detection_rules [OPTIONS] COMMAND [ARGS]...
Commands for detection-rules repository.
Options:
-d, --debug / -n, --no-debug Print full exception stacktrace on errors
-h, --help Show this message and exit.
Commands:
create-rule Create a detection rule.
dev Commands for development and management by internal...
es Commands for integrating with Elasticsearch.
import-rules Import rules from json, toml, or Kibana exported rule...
kibana Commands for integrating with Kibana.
mass-update Update multiple rules based on eql results.
normalize-data Normalize Elasticsearch data timestamps and sort.
rule-search Use KQL or EQL to find matching rules.
test Run unit tests over all of the rules.
toml-lint Cleanup files with some simple toml formatting.
validate-all Check if all rules validates against a schema.
validate-rule Check if a rule staged in rules dir validates against a...
view-rule View an internal rule or specified rule file.
Note:
- If you are using a virtual environment, make sure to activate it before running the above command.
- If using Windows, you may have to also run
<venv_directory>\Scripts\pywin32_postinstall.py -installdepending on your python version.
The contribution guide describes how to use the create-rule and test commands to create and test a new rule when contributing to Detection Rules.
For more advanced command line interface (CLI) usage, refer to the CLI guide.
How to contribute
We welcome your contributions to Detection Rules! Before contributing, please familiarize yourself with this repository, its directory structure, and our philosophy about rule creation. When you're ready to contribute, read the contribution guide to learn how we turn detection ideas into production rules and validate with testing.
Licensing
Everything in this repository — rules, code, RTA, etc. — is licensed under the Elastic License v2. These rules are designed to be used in the context of the Detection Engine within the Elastic Security application. If you’re using our Elastic Cloud managed service or the default distribution of the Elastic Stack software that includes the full set of free features, you’ll get the latest rules the first time you navigate to the detection engine.
Occasionally, we may want to import rules from another repository that already have a license, such as MIT or Apache 2.0. This is welcome, as long as the license permits sublicensing under the Elastic License v2. We keep those license notices in NOTICE.txt and sublicense as the Elastic License v2 with all other rules. We also require contributors to sign a Contributor License Agreement before contributing code to any Elastic repositories.
Questions? Problems? Suggestions?
- Want to know more about the Detection Engine? Check out the overview in Kibana.
- This repository includes new and updated rules that have not been released yet. To see the latest set of rules released with the stack, see the Prebuilt rule reference.
- If you’d like to report a false positive or other type of bug, please create a GitHub issue and check if there's an existing one first.
- Need help with Detection Rules? Post an issue or ask away in our Security Discuss Forum or the #security-detection-rules channel within Slack workspace.