Unusual Hour for a User to Logon

A machine learning job detected a user logging in at a time of day that is unusual for the user. This can be due to credentialed access via a compromised account when the user and the threat actor are in different time zones. In addition, unauthorized user activity often takes place during non-business hours.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2021/06/10"
  3integration = ["auditd_manager", "endpoint", "system"]
  4maturity = "production"
  5updated_date = "2024/06/18"
  6
  7[rule]
  8anomaly_threshold = 75
  9author = ["Elastic"]
 10description = """
 11A machine learning job detected a user logging in at a time of day that is unusual for the user. This can be due to
 12credentialed access via a compromised account when the user and the threat actor are in different time zones. In
 13addition, unauthorized user activity often takes place during non-business hours.
 14"""
 15false_positives = ["Users working late, or logging in from unusual time zones while traveling, may trigger this rule."]
 16from = "now-30m"
 17interval = "15m"
 18license = "Elastic License v2"
 19machine_learning_job_id = "auth_rare_hour_for_a_user"
 20name = "Unusual Hour for a User to Logon"
 21setup = """## Setup
 22
 23This rule requires the installation of associated Machine Learning jobs, as well as data coming in from one of the following integrations:
 24- Elastic Defend
 25- Auditd Manager
 26- System
 27
 28### Anomaly Detection Setup
 29
 30Once the rule is enabled, the associated Machine Learning job will start automatically. You can view the Machine Learning job linked under the "Definition" panel of the detection rule. If the job does not start due to an error, the issue must be resolved for the job to commence successfully. For more details on setting up anomaly detection jobs, refer to the [helper guide](https://www.elastic.co/guide/en/kibana/current/xpack-ml-anomalies.html).
 31
 32### Elastic Defend Integration Setup
 33Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 34
 35#### Prerequisite Requirements:
 36- Fleet is required for Elastic Defend.
 37- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 38
 39#### The following steps should be executed in order to add the Elastic Defend integration to your system:
 40- Go to the Kibana home page and click "Add integrations".
 41- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 42- Click "Add Elastic Defend".
 43- Configure the integration name and optionally add a description.
 44- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 45- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
 46- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 47- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
 48For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/current/agent-policy.html).
 49- Click "Save and Continue".
 50- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
 51For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 52
 53### Auditd Manager Integration Setup
 54The Auditd Manager Integration receives audit events from the Linux Audit Framework which is a part of the Linux kernel.
 55Auditd Manager provides a user-friendly interface and automation capabilities for configuring and monitoring system auditing through the auditd daemon. With `auditd_manager`, administrators can easily define audit rules, track system events, and generate comprehensive audit reports, improving overall security and compliance in the system.
 56
 57#### The following steps should be executed in order to add the Elastic Agent System integration "auditd_manager" to your system:
 58- Go to the Kibana home page and click “Add integrations”.
 59- In the query bar, search for “Auditd Manager” and select the integration to see more details about it.
 60- Click “Add Auditd Manager”.
 61- Configure the integration name and optionally add a description.
 62- Review optional and advanced settings accordingly.
 63- Add the newly installed “auditd manager” to an existing or a new agent policy, and deploy the agent on a Linux system from which auditd log files are desirable.
 64- Click “Save and Continue”.
 65- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/auditd_manager).
 66
 67#### Rule Specific Setup Note
 68Auditd Manager subscribes to the kernel and receives events as they occur without any additional configuration.
 69However, if more advanced configuration is required to detect specific behavior, audit rules can be added to the integration in either the "audit rules" configuration box or the "auditd rule files" box by specifying a file to read the audit rules from.
 70- For this detection rule no additional audit rules are required.
 71
 72### System Integration Setup
 73The System integration allows you to collect system logs and metrics from your servers with Elastic Agent.
 74
 75#### The following steps should be executed in order to add the Elastic Agent System integration "system" to your system:
 76- Go to the Kibana home page and click “Add integrations”.
 77- In the query bar, search for “System” and select the integration to see more details about it.
 78- Click “Add System”.
 79- Configure the integration name and optionally add a description.
 80- Review optional and advanced settings accordingly.
 81- Add the newly installed “system” to an existing or a new agent policy, and deploy the agent on your system from which system log files are desirable.
 82- Click “Save and Continue”.
 83- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/system).
 84"""
 85note = """## Triage and analysis
 86
 87### Investigating Unusual Hour for a User to Logon
 88
 89This rule uses a machine learning job to detect a user logging in at a time of day that is unusual for the user. This can be due to credentialed access via a compromised account when the user and the threat actor are in different time zones. It can also indicate unauthorized user activity, as it often occurs during non-business hours.
 90
 91#### Possible investigation steps
 92
 93- Identify the user account that performed the action and whether it should perform this kind of action.
 94- Contact the account owner and confirm whether they are aware of this activity.
 95- Investigate any abnormal account behavior, such as command executions, file creations or modifications, network connections, data access, and logon events.
 96- Investigate other alerts associated with the involved users during the past 48 hours.
 97
 98### False positive analysis
 99
100- Users may need to log in during non-business hours to perform work-related tasks. Examine whether the company policies authorize this or if the activity is done under change management.
101
102### Response and remediation
103
104- Initiate the incident response process based on the outcome of the triage.
105- 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.
106- 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).
107"""
108references = ["https://www.elastic.co/guide/en/security/current/prebuilt-ml-jobs.html"]
109risk_score = 21
110rule_id = "745b0119-0560-43ba-860a-7235dd8cee8d"
111severity = "low"
112tags = [
113    "Use Case: Identity and Access Audit",
114    "Use Case: Threat Detection",
115    "Rule Type: ML",
116    "Rule Type: Machine Learning",
117    "Tactic: Initial Access",
118    "Resources: Investigation Guide",
119]
120type = "machine_learning"
121[[rule.threat]]
122framework = "MITRE ATT&CK"
123[[rule.threat.technique]]
124id = "T1078"
125name = "Valid Accounts"
126reference = "https://attack.mitre.org/techniques/T1078/"
127
128
129[rule.threat.tactic]
130id = "TA0001"
131name = "Initial Access"
132reference = "https://attack.mitre.org/tactics/TA0001/"

Triage and analysis

Investigating Unusual Hour for a User to Logon

This rule uses a machine learning job to detect a user logging in at a time of day that is unusual for the user. This can be due to credentialed access via a compromised account when the user and the threat actor are in different time zones. It can also indicate unauthorized user activity, as it often occurs during non-business hours.

Possible investigation steps

  • Identify the user account that performed the action and whether it should perform this kind of action.
  • Contact the account owner and confirm whether they are aware of this activity.
  • Investigate any abnormal account behavior, such as command executions, file creations or modifications, network connections, data access, and logon events.
  • Investigate other alerts associated with the involved users during the past 48 hours.

False positive analysis

  • Users may need to log in during non-business hours to perform work-related tasks. Examine whether the company policies authorize this or if the activity is done under change management.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • 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.
  • 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).

References

Related rules

to-top