Skip to content

Commit

Permalink
Update latest docs (#6404)
Browse files Browse the repository at this point in the history
  • Loading branch information
protectionsmachine authored Jan 8, 2025
1 parent 4aafecd commit fac60d8
Show file tree
Hide file tree
Showing 67 changed files with 6,856 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
[[prebuilt-rule-8-17-2-azure-entra-mfa-totp-brute-force-attempts]]
=== Azure Entra MFA TOTP Brute Force Attempts

Identifies brute force attempts against Azure Entra multi-factor authentication (MFA) Time-based One-Time Password (TOTP) verification codes. This rule detects high frequency failed TOTP code attempts for a single user in a short time-span. Adversaries with valid credentials, when attempting to login to Azure portal or other Azure services, may be prompted to provide a TOTP code as part of the MFA process. If successful, adversaries can bypass MFA and gain unauthorized access to Azure resources.

*Rule type*: esql

*Rule indices*: None

*Severity*: medium

*Risk score*: 47

*Runs every*: 5m

*Searches indices from*: now-9m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)

*Maximum alerts per execution*: 100

*References*:

* https://www.oasis.security/resources/blog/oasis-security-research-team-discovers-microsoft-azure-mfa-bypass
* https://learn.microsoft.com/en-us/entra/identity/
* https://learn.microsoft.com/en-us/entra/identity/monitoring-health/concept-sign-ins

*Tags*:

* Domain: Cloud
* Domain: SaaS
* Data Source: Azure
* Data Source: Entra ID
* Data Source: Entra ID Sign-in
* Use Case: Identity and Access Audit
* Use Case: Threat Detection
* Tactic: Credential Access

*Version*: 1

*Rule authors*:

* Elastic

*Rule license*: Elastic License v2


==== Investigation guide



*Triage and Analysis*



*Investigating Azure Entra MFA TOTP Brute Force Attempts*


This rule detects high-frequency failed TOTP code attempts for a single user in a short time span. Such behavior could indicate an adversary attempting to bypass multi-factor authentication (MFA) protections using valid credentials. Understanding the context of the user's typical behavior and identifying anomalies in the log data are critical to determining the nature of the activity.


*Possible Investigation Steps:*


**Review the Source IP Address**:
- Check the `source.ip` or `azure.signinlogs.caller_ip_address` field.
- Determine if the IP address is associated with the user’s typical login locations.
- Look for unusual geographic patterns or anomalous IP addresses (e.g., proxies, VPNs, or locations outside the user’s normal activity).

**Analyze User Activity**:
- Identify the user from the `azure.signinlogs.properties.sign_in_identifier` field.
- Determine if the user is currently active from another device or session. Session hijacking could explain parallel activity with failed attempts.
- Review past logs for the user to determine whether MFA failures or other anomalies are consistent or new.

**Inspect the Authentication Method**:
- Evaluate the `azure.signinlogs.properties.mfa_detail.auth_method` field: `OATH verification code`.
- Confirm if the user typically uses TOTP codes or another MFA method (e.g., push notifications).
- Verify if there are any recent changes to the user’s MFA settings that may explain multiple failed attempts.

**Evaluate the User Agent**:
- Check the `user_agent.original` field.
- Identify if the user agent matches a typical browser or a potentially malicious script (e.g., Python-based).
- Look for deviations in operating system or browser versions from the user’s normal activity.

**Analyze Conditional Access Policies**:
- Review the `azure.signinlogs.properties.applied_conditional_access_policies` for enforced grant controls.
- Verify if MFA failures are tied to legitimate security policies (`display_name: Require multifactor authentication for admins`).

**Correlate with Other Events**:
- Search for other authentication attempts involving the same `azure.signinlogs.caller_ip_address`, `user_principal_name`, or `azure.signinlogs.properties.app_id`.
- Look for suspicious activity patterns, such as password resets, privilege escalation, or account lockouts.



*False Positive Analysis:*


- **Unintentional User Behavior**:
- Verify if the failed attempts could result from the user’s unfamiliarity with TOTP codes or issues with device synchronization.
- Check if the user recently switched MFA methods or devices, which could explain multiple failures.
- Determine if this is whitebox testing or a developer testing MFA integration.

- **Administrative Actions**:
- Determine if the activity is related to legitimate administrative testing or configuration changes in the MFA system.


*Response and Remediation:*


- **Immediate Actions**:
- If proven malicious, lock the affected account temporarily to prevent further unauthorized attempts.
- Notify the user of suspicious activity and validate their access to the account.
- Reset passwords and MFA settings for the affected user to prevent unauthorized access while communicating with the user.

- **Strengthen Authentication Policies**:
- Ensure conditional access policies are configured to monitor and restrict anomalous login behavior.
- Consider a different MFA method or additional security controls to prevent future bypass attempts.

- **Monitor and Audit**:
- Implement additional monitoring to track high-frequency authentication failures across the environment.
- Audit historical logs for similar patterns involving other accounts to identify broader threats.

- **Educate and Train Users**:
- Provide guidance on the secure use of MFA and the importance of recognizing and reporting suspicious activity.


==== Setup



*Required Azure Entra Sign-In Logs*

This rule requires the Azure logs integration be enabled and configured to collect all logs, including sign-in logs from Entra. In Entra, sign-in logs must be enabled and streaming to the Event Hub used for the Azure logs integration.


==== Rule query


[source, js]
----------------------------------
from logs-azure.signinlogs* metadata _id, _version, _index
| where
// filter for Entra Sign-In Logs
event.dataset == "azure.signinlogs"
and azure.signinlogs.operation_name == "Sign-in activity"
// filter for MFA attempts with OATH conditional access attempts or TOTP
and azure.signinlogs.properties.authentication_requirement == "multiFactorAuthentication"
and azure.signinlogs.properties.mfa_detail.auth_method == "OATH verification code"
// filter on failures only from brute-force attempts
and azure.signinlogs.properties.conditional_access_status == "failure"
and azure.signinlogs.result_description == "Authentication failed during strong authentication request."
| keep azure.signinlogs.properties.sign_in_identifier
| stats
// aggregate by the sign-in account or principal
failed_totp_code_attempts = count(*) by azure.signinlogs.properties.sign_in_identifier
| where
// filter on high frequency for a single user
failed_totp_code_attempts > 30
----------------------------------

*Framework*: MITRE ATT&CK^TM^

* Tactic:
** Name: Credential Access
** ID: TA0006
** Reference URL: https://attack.mitre.org/tactics/TA0006/
* Technique:
** Name: Brute Force
** ID: T1110
** Reference URL: https://attack.mitre.org/techniques/T1110/
* Sub-technique:
** Name: Password Guessing
** ID: T1110.001
** Reference URL: https://attack.mitre.org/techniques/T1110/001/
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
[[prebuilt-rule-8-17-2-behavior-detected-elastic-defend]]
=== Behavior - Detected - Elastic Defend

Generates a detection alert each time an Elastic Defend alert for malicious behavior is received. Enabling this rule allows you to immediately begin investigating your Endpoint behavior alerts. This rule identifies Elastic Defend behavior detections only, and does not include prevention alerts.

*Rule type*: query

*Rule indices*:

* logs-endpoint.alerts-*

*Severity*: medium

*Risk score*: 47

*Runs every*: 5m

*Searches indices from*: now-10m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)

*Maximum alerts per execution*: 10000

*References*:

* https://github.com/elastic/protections-artifacts/tree/main/behavior
* https://docs.elastic.co/en/integrations/endpoint

*Tags*:

* Data Source: Elastic Defend

*Version*: 1

*Rule authors*:

* Elastic

*Rule license*: Elastic License v2


==== Investigation guide



*Triage and analysis*



*Investigating Behavior Alerts*


Malicious behavior protection is a foundational feature which can be used to protect against all manner of attacks on the endpoint. For example, it provides coverage against phishing such as malicious macros, many malware families based on their activities, privilege escalation attacks such as user account control bypasses (UAC), credential theft, and much more. It works by consuming an unfiltered feed of all events that are captured on the system (process, file, registry, network, dns, etc). These events are processed against a routinely updated set of rules written by Elastic threat experts. From there, malicious behaviors are identified and offending processes are terminated. The protection operates on the event stream asynchronously, but has been designed to be extremely efficient and typically requires just milliseconds (under standard load) to stop malicious activity.


*Possible investigation steps*


- Assess whether this activity is prevalent in your environment by looking for similar occurrences across hosts.
- Verify the detailed activity of the process that triggered the alert (process tree, child process, process arguments, network, files, libraries and registry events).
- Verify the activity of the `user.name` associated with the alert (local or remote actity, privileged or standard user).
- Particular attention should be paid to instances where the same process is triggering multiple alerts (more than 2 or 3) within a short period of time.
- Even the the process is signed by a valid certificate, verify the if it's running from the expected location or if it's loading any suspicious libraries or any sign of code injection.


*False positive analysis*


- Same alert observed on a high number of hosts with similar details.
- High count of the same alert on a specific host over a long period of time.


*Response and Remediation*


- Initiate the incident response process based on the outcome of the triage.
- If malicious activity is confirmed, perform a broader investigation to identify the scope of the compromise and determine the appropriate remediation steps.
- Implement Elastic Endpoint Security to detect and prevent further post exploitation activities in the environment.
- Contain the affected system by isolating it from the network to prevent further spread of the attack.
- If the triage identified malware, search the environment for additional compromised hosts.
- Implement temporary network rules, procedures, and segmentation to contain the malware.
- Stop suspicious processes.
- Immediately block the identified indicators of compromise (IoCs).
- Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
- Remove and block malicious artifacts identified during triage.
- Restore the affected system to its operational state by applying any necessary patches, updates, or configuration changes.
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).


==== Setup



*Setup*



*Elastic Defend Alerts*

This rule is designed to capture specific alerts generated by Elastic Defend.

To capture all the Elastic Defend alerts, it is recommended to use all of the Elastic Defend feature-specific protection rules:

Behavior - Detected - Elastic Defend (UUID: 0f615fe4-eaa2-11ee-ae33-f661ea17fbce)
Behavior - Prevented - Elastic Defend (UUID: eb804972-ea34-11ee-a417-f661ea17fbce)
Malicious File - Detected - Elastic Defend (UUID: f2c3caa6-ea34-11ee-a417-f661ea17fbce)
Malicious File - Prevented - Elastic Defend (UUID: f87e6122-ea34-11ee-a417-f661ea17fbce)
Memory Threat - Detected - Elastic Defend (UUID: 017de1e4-ea35-11ee-a417-f661ea17fbce)
Memory Threat - Prevented - Elastic Defend (UUID: 06f3a26c-ea35-11ee-a417-f661ea17fbce)
Ransomware - Detected - Elastic Defend (UUID: 0c74cd7e-ea35-11ee-a417-f661ea17fbce)
Ransomware - Prevented - Elastic Defend (UUID: 10f3d520-ea35-11ee-a417-f661ea17fbce)

To avoid generating duplicate alerts, you should enable either all feature-specific protection rules or the Endpoint Security (Elastic Defend) rule (UUID: 9a1a2dae-0b5f-4c3d-8305-a268d404c306).


*Additional notes*

This rule is configured to generate more **Max alerts per run** than the default 1000 alerts per run set for all rules. This is to ensure that it captures as many alerts as possible.

**IMPORTANT:** The rule's **Max alerts per run** setting can be superseded by the `xpack.alerting.rules.run.alerts.max` Kibana config setting, which determines the maximum alerts generated by _any_ rule in the Kibana alerting framework. For example, if `xpack.alerting.rules.run.alerts.max` is set to 1000, this rule will still generate no more than 1000 alerts even if its own **Max alerts per run** is set higher.

To make sure this rule can generate as many alerts as it's configured in its own **Max alerts per run** setting, increase the `xpack.alerting.rules.run.alerts.max` system setting accordingly.

**NOTE:** Changing `xpack.alerting.rules.run.alerts.max` is not possible in Serverless projects.


==== Rule query


[source, js]
----------------------------------
event.kind : alert and event.code : behavior and (event.type : allowed or (event.type: denied and event.outcome: failure))
----------------------------------
Loading

0 comments on commit fac60d8

Please sign in to comment.