From 8fb20dba5d64b3e6da44727cb6f7d19cb6fbb0a1 Mon Sep 17 00:00:00 2001 From: litemars Date: Tue, 17 Nov 2026 11:29:47 +0100 Subject: [PATCH 1/9] adding timestomp rule for macOS --- .../defense_evasion_timestomp_setfile.toml | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 rules/macos/defense_evasion_timestomp_setfile.toml diff --git a/rules/macos/defense_evasion_timestomp_setfile.toml b/rules/macos/defense_evasion_timestomp_setfile.toml new file mode 100644 index 0000000000..3787549c80 --- /dev/null +++ b/rules/macos/defense_evasion_timestomp_setfile.toml @@ -0,0 +1,126 @@ +[metadata] +creation_date = "2026/11/17" +integration = ["endpoint"] +maturity = "production" +updated_date = "2026/11/17" + +[rule] +author = ["Elastic"] +description = """ +Identifies the use of SetFile on macOS to change a file's creation or modification timestamp. SetFile, included with +Xcode Command Line Tools, sets the creation date with -d and the modification date with -m. Unlike touch, it can alter +the file birth time. Adversaries use it to timestomp files so they blend in with legitimate content and hinder forensic +analysis. +""" +from = "now-9m" +index = ["logs-endpoint.events.process-*"] +language = "eql" +license = "Elastic License v2" +name = "Timestomping using SetFile" +note = """## Triage and analysis + +> **Disclaimer**: +> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs. + +### Investigating Timestomping using SetFile + +`SetFile` is a macOS developer utility that writes file metadata. The `-d` argument sets the creation date and `-m` sets the modification date, using a date string such as `mm/dd/yyyy hh:mm:ss`. On macOS, `touch` does not change the creation (birth) time, so `SetFile -d` is the usual way to backdate a file so it looks older than it is. Adversaries use this after dropping a payload, script, or persistence item to make the file appear to belong with neighboring content. This rule alerts on `SetFile` executions that pass `-d` or `-m`. + +### Possible investigation steps + +- Review `process.command_line` and `process.args` to identify which timestamp was changed (`-d` for creation, `-m` for modification), the date that was written, and the target file path. +- Compare the timestamp passed to `SetFile` with the file's current creation and modification times, and with when the file was first written or downloaded on the host. +- Examine the parent and effective parent processes (`process.parent.executable`, `process.Ext.effective_parent.executable`) to determine whether `SetFile` was launched from Terminal, a script interpreter such as `osascript`, `python`, or a shell, or from an unsigned or untrusted binary. +- Identify the user that ran the command (`user.name`) and confirm whether they are a developer or administrator who would be expected to stamp file dates. +- Check the target file for related activity around the same time, such as a download, a quarantine attribute removal, execution of that file, or a new LaunchAgent, LaunchDaemon, or cron entry pointing at it. +- Review other alerts for the same host to identify the execution that preceded the timestamp change. + +### False positive analysis + +- Software installers, package builds, and packaging tools may call `SetFile -d` or `SetFile -m` to stamp bundle or application dates. Confirm the parent process is a known installer or build tool and add an exception for that parent executable rather than for `SetFile` itself. +- Developers using Xcode Command Line Tools may set creation or modification dates while packaging an application. Verify the activity with the user and the working directory. +- Security testing that emulates timestomping may invoke `SetFile`. Confirm the activity with the team running the test. + +### Response and remediation + +- If the timestamp change is unauthorized, preserve the file and record both the timestomped dates and the original event timestamps from endpoint telemetry before restoring content from a known-good copy. +- Quarantine the target file and investigate any process that wrote or executed it. +- Terminate the process tree that launched `SetFile` when that parent is not a known installer or build tool. +- Search the host for other files whose timestamps were changed with `SetFile` or `touch` in the same session. +- Isolate the host if the timestomped file is malicious or if follow-on activity is identified, and escalate to the incident response team. +""" +references = ["https://ss64.com/mac/setfile.html", "https://attack.mitre.org/techniques/T1070/006/"] +risk_score = 47 +rule_id = "d093c7c1-d6cb-4277-b2c9-74477b393b7f" +setup = """## Setup + +This rule requires data coming in from Elastic Defend. + +### Elastic Defend Integration Setup +Elastic 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. + +#### Prerequisite Requirements: +- Fleet is required for Elastic Defend. +- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html). + +#### The following steps should be executed in order to add the Elastic Defend integration on a macOS System: +- Go to the Kibana home page and click "Add integrations". +- In the query bar, search for "Elastic Defend" and select the integration to see more details about it. +- Click "Add Elastic Defend". +- Configure the integration name and optionally add a description. +- Select the type of environment you want to protect, for MacOS it is recommended to select "Traditional Endpoints". +- 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). +- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions" +- 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. +For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/current/agent-policy.html). +- Click "Save and Continue". +- 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. +For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html). +""" +severity = "medium" +tags = [ + "Domain: Endpoint", + "OS: macOS", + "Use Case: Threat Detection", + "Tactic: Defense Evasion", + "Data Source: Elastic Defend", + "Resources: Investigation Guide", + "Noise: Low", + "Performance: Fast", + "Rule Type: Event Correlation (EQL)", + "Platform: macOS", +] +timestamp_override = "event.ingested" +type = "eql" + +query = ''' +process where host.os.type == "macos" and event.type == "start" and event.action == "exec" and + process.name == "SetFile" and process.args in ("-d", "-m") +''' + + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1070" +name = "Indicator Removal" +reference = "https://attack.mitre.org/techniques/T1070/" +[[rule.threat.technique.subtechnique]] +id = "T1070.006" +name = "Timestomp" +reference = "https://attack.mitre.org/techniques/T1070/006/" + + + +[rule.threat.tactic] +id = "TA0005" +name = "Defense Evasion" +reference = "https://attack.mitre.org/tactics/TA0005/" + +[rule.alert_suppression] +group_by = ["host.id", "process.parent.executable"] +missing_fields_strategy = "doNotSuppress" + +[rule.alert_suppression.duration] +unit = "h" +value = 1 From 788a24476b39280931102e945b21ac45dda5bdda Mon Sep 17 00:00:00 2001 From: litemars <44295342+litemars@users.noreply.github.com> Date: Tue, 24 Nov 2026 12:41:08 +0100 Subject: [PATCH 2/9] Update defense evasion rule metadata Removed noise and performance metrics from rule metadata. --- rules/macos/defense_evasion_timestomp_setfile.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/rules/macos/defense_evasion_timestomp_setfile.toml b/rules/macos/defense_evasion_timestomp_setfile.toml index 3787549c80..26d124c0a2 100644 --- a/rules/macos/defense_evasion_timestomp_setfile.toml +++ b/rules/macos/defense_evasion_timestomp_setfile.toml @@ -85,8 +85,6 @@ tags = [ "Tactic: Defense Evasion", "Data Source: Elastic Defend", "Resources: Investigation Guide", - "Noise: Low", - "Performance: Fast", "Rule Type: Event Correlation (EQL)", "Platform: macOS", ] From 0e09a84c1d3d5d220c1d09e030892d027a60f3a5 Mon Sep 17 00:00:00 2001 From: litemars Date: Tue, 24 Nov 2026 13:29:51 +0100 Subject: [PATCH 3/9] transform to BBR --- .../defense_evasion_timestomp_setfile.toml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) rename {rules/macos => rules_building_block}/defense_evasion_timestomp_setfile.toml (97%) diff --git a/rules/macos/defense_evasion_timestomp_setfile.toml b/rules_building_block/defense_evasion_timestomp_setfile.toml similarity index 97% rename from rules/macos/defense_evasion_timestomp_setfile.toml rename to rules_building_block/defense_evasion_timestomp_setfile.toml index 26d124c0a2..40ae8621d7 100644 --- a/rules/macos/defense_evasion_timestomp_setfile.toml +++ b/rules_building_block/defense_evasion_timestomp_setfile.toml @@ -2,18 +2,20 @@ creation_date = "2026/11/17" integration = ["endpoint"] maturity = "production" -updated_date = "2026/11/17" +updated_date = "2026/11/24" [rule] author = ["Elastic"] +building_block_type = "default" description = """ Identifies the use of SetFile on macOS to change a file's creation or modification timestamp. SetFile, included with Xcode Command Line Tools, sets the creation date with -d and the modification date with -m. Unlike touch, it can alter the file birth time. Adversaries use it to timestomp files so they blend in with legitimate content and hinder forensic analysis. """ -from = "now-9m" +from = "now-119m" index = ["logs-endpoint.events.process-*"] +interval = "60m" language = "eql" license = "Elastic License v2" name = "Timestomping using SetFile" @@ -50,7 +52,7 @@ note = """## Triage and analysis - Isolate the host if the timestomped file is malicious or if follow-on activity is identified, and escalate to the incident response team. """ references = ["https://ss64.com/mac/setfile.html", "https://attack.mitre.org/techniques/T1070/006/"] -risk_score = 47 +risk_score = 21 rule_id = "d093c7c1-d6cb-4277-b2c9-74477b393b7f" setup = """## Setup @@ -77,12 +79,13 @@ For more details on Elastic Agent configuration settings, refer to the [helper g - 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. For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html). """ -severity = "medium" +severity = "low" tags = [ "Domain: Endpoint", "OS: macOS", "Use Case: Threat Detection", "Tactic: Defense Evasion", + "Rule Type: BBR", "Data Source: Elastic Defend", "Resources: Investigation Guide", "Rule Type: Event Correlation (EQL)", From fd1fbe8f612ef1648e16f021e8624865ddb0aa9b Mon Sep 17 00:00:00 2001 From: litemars <44295342+litemars@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:20:36 +0100 Subject: [PATCH 4/9] Clean up timestomping rule documentation Removed detailed investigation guide and setup instructions for timestomping using SetFile. --- .../defense_evasion_timestomp_setfile.toml | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/rules_building_block/defense_evasion_timestomp_setfile.toml b/rules_building_block/defense_evasion_timestomp_setfile.toml index 40ae8621d7..33a4086414 100644 --- a/rules_building_block/defense_evasion_timestomp_setfile.toml +++ b/rules_building_block/defense_evasion_timestomp_setfile.toml @@ -19,66 +19,11 @@ interval = "60m" language = "eql" license = "Elastic License v2" name = "Timestomping using SetFile" -note = """## Triage and analysis -> **Disclaimer**: -> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs. - -### Investigating Timestomping using SetFile - -`SetFile` is a macOS developer utility that writes file metadata. The `-d` argument sets the creation date and `-m` sets the modification date, using a date string such as `mm/dd/yyyy hh:mm:ss`. On macOS, `touch` does not change the creation (birth) time, so `SetFile -d` is the usual way to backdate a file so it looks older than it is. Adversaries use this after dropping a payload, script, or persistence item to make the file appear to belong with neighboring content. This rule alerts on `SetFile` executions that pass `-d` or `-m`. - -### Possible investigation steps - -- Review `process.command_line` and `process.args` to identify which timestamp was changed (`-d` for creation, `-m` for modification), the date that was written, and the target file path. -- Compare the timestamp passed to `SetFile` with the file's current creation and modification times, and with when the file was first written or downloaded on the host. -- Examine the parent and effective parent processes (`process.parent.executable`, `process.Ext.effective_parent.executable`) to determine whether `SetFile` was launched from Terminal, a script interpreter such as `osascript`, `python`, or a shell, or from an unsigned or untrusted binary. -- Identify the user that ran the command (`user.name`) and confirm whether they are a developer or administrator who would be expected to stamp file dates. -- Check the target file for related activity around the same time, such as a download, a quarantine attribute removal, execution of that file, or a new LaunchAgent, LaunchDaemon, or cron entry pointing at it. -- Review other alerts for the same host to identify the execution that preceded the timestamp change. - -### False positive analysis - -- Software installers, package builds, and packaging tools may call `SetFile -d` or `SetFile -m` to stamp bundle or application dates. Confirm the parent process is a known installer or build tool and add an exception for that parent executable rather than for `SetFile` itself. -- Developers using Xcode Command Line Tools may set creation or modification dates while packaging an application. Verify the activity with the user and the working directory. -- Security testing that emulates timestomping may invoke `SetFile`. Confirm the activity with the team running the test. - -### Response and remediation - -- If the timestamp change is unauthorized, preserve the file and record both the timestomped dates and the original event timestamps from endpoint telemetry before restoring content from a known-good copy. -- Quarantine the target file and investigate any process that wrote or executed it. -- Terminate the process tree that launched `SetFile` when that parent is not a known installer or build tool. -- Search the host for other files whose timestamps were changed with `SetFile` or `touch` in the same session. -- Isolate the host if the timestomped file is malicious or if follow-on activity is identified, and escalate to the incident response team. -""" references = ["https://ss64.com/mac/setfile.html", "https://attack.mitre.org/techniques/T1070/006/"] risk_score = 21 rule_id = "d093c7c1-d6cb-4277-b2c9-74477b393b7f" -setup = """## Setup - -This rule requires data coming in from Elastic Defend. -### Elastic Defend Integration Setup -Elastic 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. - -#### Prerequisite Requirements: -- Fleet is required for Elastic Defend. -- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html). - -#### The following steps should be executed in order to add the Elastic Defend integration on a macOS System: -- Go to the Kibana home page and click "Add integrations". -- In the query bar, search for "Elastic Defend" and select the integration to see more details about it. -- Click "Add Elastic Defend". -- Configure the integration name and optionally add a description. -- Select the type of environment you want to protect, for MacOS it is recommended to select "Traditional Endpoints". -- 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). -- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions" -- 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. -For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/current/agent-policy.html). -- Click "Save and Continue". -- 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. -For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html). -""" severity = "low" tags = [ "Domain: Endpoint", From 0f9ccdcf7a1512887b776ab75c0f20ebbfd48fdf Mon Sep 17 00:00:00 2001 From: litemars <44295342+litemars@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:21:21 +0100 Subject: [PATCH 5/9] Change creation_date to 2026/11/24 Updated creation and updated dates in the configuration. --- rules_building_block/defense_evasion_timestomp_setfile.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules_building_block/defense_evasion_timestomp_setfile.toml b/rules_building_block/defense_evasion_timestomp_setfile.toml index 33a4086414..6bef68adbb 100644 --- a/rules_building_block/defense_evasion_timestomp_setfile.toml +++ b/rules_building_block/defense_evasion_timestomp_setfile.toml @@ -1,5 +1,5 @@ [metadata] -creation_date = "2026/11/17" +creation_date = "2026/11/24" integration = ["endpoint"] maturity = "production" updated_date = "2026/11/24" From e73e5fe2cf11851be3a687017db674cf4e89bbf5 Mon Sep 17 00:00:00 2001 From: litemars <44295342+litemars@users.noreply.github.com> Date: Tue, 1 Dec 2026 11:03:50 +0100 Subject: [PATCH 6/9] Refine description of SetFile usage on macOS Updated description for defense evasion timestomp setfile. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- rules_building_block/defense_evasion_timestomp_setfile.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rules_building_block/defense_evasion_timestomp_setfile.toml b/rules_building_block/defense_evasion_timestomp_setfile.toml index 6bef68adbb..74225ea23e 100644 --- a/rules_building_block/defense_evasion_timestomp_setfile.toml +++ b/rules_building_block/defense_evasion_timestomp_setfile.toml @@ -9,9 +9,8 @@ author = ["Elastic"] building_block_type = "default" description = """ Identifies the use of SetFile on macOS to change a file's creation or modification timestamp. SetFile, included with -Xcode Command Line Tools, sets the creation date with -d and the modification date with -m. Unlike touch, it can alter -the file birth time. Adversaries use it to timestomp files so they blend in with legitimate content and hinder forensic -analysis. +Xcode Command Line Tools, explicitly sets the creation date with -d and the modification date with -m. Adversaries use it to +timestomp files so they blend in with legitimate content and hinder forensic analysis. """ from = "now-119m" index = ["logs-endpoint.events.process-*"] From 05dacfb00e74eecbad6588161c6fcd945dd762ac Mon Sep 17 00:00:00 2001 From: litemars <44295342+litemars@users.noreply.github.com> Date: Tue, 1 Dec 2026 11:04:08 +0100 Subject: [PATCH 7/9] Update rules_building_block/defense_evasion_timestomp_setfile.toml Co-authored-by: Bryan Porras --- rules_building_block/defense_evasion_timestomp_setfile.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/rules_building_block/defense_evasion_timestomp_setfile.toml b/rules_building_block/defense_evasion_timestomp_setfile.toml index 74225ea23e..0de0b9b57d 100644 --- a/rules_building_block/defense_evasion_timestomp_setfile.toml +++ b/rules_building_block/defense_evasion_timestomp_setfile.toml @@ -31,7 +31,6 @@ tags = [ "Tactic: Defense Evasion", "Rule Type: BBR", "Data Source: Elastic Defend", - "Resources: Investigation Guide", "Rule Type: Event Correlation (EQL)", "Platform: macOS", ] From 17488cd9c807881c0221d0f079de0f039e643b91 Mon Sep 17 00:00:00 2001 From: litemars <44295342+litemars@users.noreply.github.com> Date: Tue, 1 Dec 2026 11:04:43 +0100 Subject: [PATCH 8/9] Update rules_building_block/defense_evasion_timestomp_setfile.toml Co-authored-by: Bryan Porras --- .../defense_evasion_timestomp_setfile.toml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/rules_building_block/defense_evasion_timestomp_setfile.toml b/rules_building_block/defense_evasion_timestomp_setfile.toml index 0de0b9b57d..ea0907f93c 100644 --- a/rules_building_block/defense_evasion_timestomp_setfile.toml +++ b/rules_building_block/defense_evasion_timestomp_setfile.toml @@ -61,10 +61,3 @@ id = "TA0005" name = "Defense Evasion" reference = "https://attack.mitre.org/tactics/TA0005/" -[rule.alert_suppression] -group_by = ["host.id", "process.parent.executable"] -missing_fields_strategy = "doNotSuppress" - -[rule.alert_suppression.duration] -unit = "h" -value = 1 From d4666a3f97a56da2af8b1d92cc2c9dc0c7c2652a Mon Sep 17 00:00:00 2001 From: litemars <44295342+litemars@users.noreply.github.com> Date: Tue, 1 Dec 2026 11:05:17 +0100 Subject: [PATCH 9/9] Update rules_building_block/defense_evasion_timestomp_setfile.toml Co-authored-by: Bryan Porras --- rules_building_block/defense_evasion_timestomp_setfile.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules_building_block/defense_evasion_timestomp_setfile.toml b/rules_building_block/defense_evasion_timestomp_setfile.toml index ea0907f93c..e661b4801f 100644 --- a/rules_building_block/defense_evasion_timestomp_setfile.toml +++ b/rules_building_block/defense_evasion_timestomp_setfile.toml @@ -19,7 +19,7 @@ language = "eql" license = "Elastic License v2" name = "Timestomping using SetFile" -references = ["https://ss64.com/mac/setfile.html", "https://attack.mitre.org/techniques/T1070/006/"] +references = ["https://ss64.com/mac/setfile.html"] risk_score = 21 rule_id = "d093c7c1-d6cb-4277-b2c9-74477b393b7f"