From c56ade4c8e5f3e3f63f069b830bad97e64c878b2 Mon Sep 17 00:00:00 2001 From: clivoa Date: Fri, 7 Aug 2026 19:08:41 +0200 Subject: [PATCH 1/7] New rule: Unusual Child Process of Homebrew's Bundled Ruby Interpreter Detects an unexpected child process of Homebrew's bundled Ruby interpreter (vendor/portable-ruby) during a cask install, catching preflight/postflight/uninstall hook abuse in a malicious or compromised cask. Validated against real Elastic Defend telemetry on macOS, including a fresh re-test today: a real cask postflight hook event was captured, and the exclusion list was corrected after real testing showed Homebrew's own environment/requirement-check utilities (bash/sh, getconf, mdfind, pkgutil, xcode-select) run as direct children of the interpreter on every invocation regardless of HOMEBREW_NO_AUTO_UPDATE/HOMEBREW_NO_ANALYTICS. Re-confirmed live via _eql/search that the real hook event still matches and this noise no longer does. Relates to #6617 --- ...ebrew_cask_unusual_hook_child_process.toml | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml diff --git a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml new file mode 100644 index 0000000000..2d144c8d1a --- /dev/null +++ b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml @@ -0,0 +1,165 @@ +[metadata] +creation_date = "2026/08/06" +integration = ["endpoint"] +maturity = "development" +updated_date = "2026/08/07" + +[rule] +author = ["clivoa"] +description = """ +This rule detects an unexpected child process spawned by Homebrew's own bundled Ruby interpreter +(`vendor/portable-ruby`) during a `brew install --cask` operation. Homebrew Cask `preflight`/`postflight`/`uninstall` +stanzas run arbitrary Ruby code (including shelling out via `system_command`) at install time — a malicious or +compromised cask (from a third-party tap, or a compromised/typosquatted first-party one) can use this to execute +code with the installing user's privileges. This is the macOS analogue of the same install-time-hook abuse pattern +already covered for npm/Composer/pip elsewhere in this ruleset; Homebrew is macOS's dominant developer package +manager and had zero coverage in `elastic/detection-rules` prior to this rule, including no representation in the +existing cross-platform package-manager ancestor meta-rule (`344e6c7d-ceb0-4f20-ba04-7c75569a7e38`), which only +recognizes npm/pip/cargo. +""" +false_positives = [ + """ + Real testing during this rule's development found that Homebrew's *own* internal package-management operations + (extracting the download archive, setting quarantine/extended attributes, symlinking binaries, checking CPU + type) are themselves children of the same bundled Ruby interpreter, indistinguishable at the process-tree level + from a cask's own hook code -- there is no OS-level signal that separates "Homebrew's own hardcoded logic" from + "a cask author's custom hook". This rule's exclusion list was built empirically from a real, clean + `binary`-artifact cask install with no hooks defined (`env`, `xattr`, `chmod`, `tar`, `bsdtar`, `ln`, `hdiutil`, + `xargs`, `defaults`, `clang`, `sysctl`) rather than assumed. + """, + """ + Real testing (2026-08-07, a fresh clean-cask install with `HOMEBREW_NO_AUTO_UPDATE=1`/`HOMEBREW_NO_ANALYTICS=1` + set) found that a wider legitimate set is spawned as a direct child of the bundled Ruby interpreter regardless + of those two variables: `bash`/`sh` (wrapping several `stty`/`tput`/`python3.7` terminal-size and + interpreter-presence probes), `getconf`, `mdfind`, `pkgutil`, and `xcode-select` -- Homebrew's own + environment/requirement checks (CPU type, terminal dimensions, Xcode Command Line Tools presence), which run on + every invocation and are not gated by the auto-update/analytics settings as an earlier test pass had assumed. + This superseded and corrected that earlier (2026-08-06) finding, which had reproduced a narrower 11-name + baseline that turned out not to generalize. All of these names are now included in this rule's exclusion list + unconditionally; the real cask postflight hook event (`echo`) in the same test run was confirmed to still match + after adding them. + """, + """ + This rule is scoped and tested against `binary`-artifact casks only. A real `app`-artifact cask (most casks in + practice) additionally invokes Gatekeeper/registration tooling as part of Homebrew's own normal install flow + (e.g. `codesign`, `spctl`, `mdimport`, `lsregister`) which is NOT in this rule's tested exclusion list and will + likely false-positive until measured and added -- documented here as an explicit, honest scope limitation rather + than silently assumed to be covered. Do not extend this false-positive claim to formula (non-cask) source builds: + a real clean-formula install was also tested during this rule's development and produces a much wider legitimate + child-process set (`git`, `curl`, `clang`, `sandbox-exec`, `nice`, `xcode-select`, `mdfind`, `pkgutil`, + `getconf`, `tput`, and a *nested* sandboxed `ruby` for the actual build) -- this rule is not scoped or validated + for formula builds and would need a much larger, separately-measured exclusion list before covering that case. + """, +] +from = "now-9m" +index = ["logs-endpoint.events.process*"] +language = "eql" +license = "Elastic License v2" +name = "Unusual Child Process of Homebrew's Bundled Ruby Interpreter" +note = """## Triage and analysis + +### Investigating Unusual Child Process of Homebrew's Bundled Ruby Interpreter + +This rule flags a process spawned by Homebrew's own bundled Ruby interpreter +(`.../Homebrew/vendor/portable-ruby/.../bin/ruby`) whose name is not one of the small set of utilities Homebrew's +own internal package-management logic is known to invoke for a routine, hook-free `binary`-artifact cask install. +A match here most often means a cask's `preflight`/`postflight`/`uninstall` Ruby block executed a command. + +### Possible investigation steps + +- Identify which cask was being installed (`brew list --cask` history, or the `HOMEBREW_*` environment variables + visible on the parent `bash`/`env` process's command line) and whether it is a known first-party cask or from a + third-party/community tap. +- Review the spawned child's full command line for network activity (`curl`, `wget`, `nc`), a scripting interpreter + invocation (`bash -c`, `python3 -c`, `osascript`), or anything writing outside the cask's own Caskroom directory. +- If the cask is from a third-party tap, check the tap's Git history/commit author for the cask file for recent, + suspicious changes. +- Correlate with any subsequent network connections, persistence (LaunchAgent/LaunchDaemon creation), or credential + file access from the same process tree. + +### False positive analysis + +- See this rule's `false_positives` field: `app`-artifact casks are expected to trigger this on their own normal + Gatekeeper/registration steps until the exclusion list is extended with real measured data; formula (non-cask) + builds are out of scope entirely and not covered by this rule's exclusion list. +""" +references = [ + "https://docs.brew.sh/Cask-Cookbook#stanza-preflight", + "https://docs.brew.sh/Cask-Cookbook#stanza-postflight", +] +risk_score = 47 +rule_id = "5e07cb07-acdb-49e5-958c-53841e79a1ae" +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: Execution", + "Tactic: Initial Access", + "Data Source: Elastic Defend", + "Resources: Investigation Guide", +] +type = "eql" + +query = ''' +process where event.action == "exec" and host.os.type == "macos" and + process.parent.executable like~ "*/Homebrew/vendor/portable-ruby/*" and + not process.name in ( + "env", "xattr", "chmod", "chown", "tar", "bsdtar", "ln", "hdiutil", "xargs", "defaults", "clang", "sysctl", + "bash", "sh", "getconf", "mdfind", "pkgutil", "xcode-select" + ) +''' + + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1195" +name = "Supply Chain Compromise" +reference = "https://attack.mitre.org/techniques/T1195/" +[[rule.threat.technique.subtechnique]] +id = "T1195.002" +name = "Compromise Software Supply Chain" +reference = "https://attack.mitre.org/techniques/T1195/002/" + +[rule.threat.tactic] +id = "TA0001" +name = "Initial Access" +reference = "https://attack.mitre.org/tactics/TA0001/" + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1059" +name = "Command and Scripting Interpreter" +reference = "https://attack.mitre.org/techniques/T1059/" + +[rule.threat.tactic] +id = "TA0002" +name = "Execution" +reference = "https://attack.mitre.org/tactics/TA0002/" From 2876ec02017c92b6ebbcda6bf595a34fa748b552 Mon Sep 17 00:00:00 2001 From: clivoa Date: Mon, 10 Aug 2026 23:00:14 +0200 Subject: [PATCH 2/7] Promote rule to production maturity Set maturity = production so the rule is actually shipped to the product, per maintainer feedback on #6612. Promoting it surfaced one check the repo's test suite only applies to production rules: added timestamp_override = "event.ingested", required for non-sequence EQL/KQL rules by TestRuleTiming::test_event_override. Verified with detection_rules validate-rule and the production-gated checks in the repo's test suite. --- .../execution_homebrew_cask_unusual_hook_child_process.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml index 2d144c8d1a..3a26e71e42 100644 --- a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml +++ b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml @@ -1,7 +1,7 @@ [metadata] creation_date = "2026/08/06" integration = ["endpoint"] -maturity = "development" +maturity = "production" updated_date = "2026/08/07" [rule] @@ -124,6 +124,7 @@ tags = [ "Data Source: Elastic Defend", "Resources: Investigation Guide", ] +timestamp_override = "event.ingested" type = "eql" query = ''' From 470096e12d37085f20d624c9a35f494e1d24116c Mon Sep 17 00:00:00 2001 From: clivoa Date: Tue, 11 Aug 2026 01:20:43 +0200 Subject: [PATCH 3/7] Address review points raised on #6612: description, false positives, setup, references - Trimmed the description to the rule itself, dropping the comparison against the package-manager meta-rule. - Rewrote false_positives. The previous entries described how the exclusion list was built and which utilities do not match, which is development history rather than false positives. They now describe traffic that does match and can be benign: an unlisted Homebrew utility, app-artifact casks, and formula source builds. - Replaced the setup block with the standard Elastic Defend text. - Added threat context references for macOS campaigns targeting Homebrew users with infostealers. --- ...ebrew_cask_unusual_hook_child_process.toml | 72 +++++-------------- 1 file changed, 18 insertions(+), 54 deletions(-) diff --git a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml index 3a26e71e42..1bc5df52c5 100644 --- a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml +++ b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml @@ -9,46 +9,27 @@ author = ["clivoa"] description = """ This rule detects an unexpected child process spawned by Homebrew's own bundled Ruby interpreter (`vendor/portable-ruby`) during a `brew install --cask` operation. Homebrew Cask `preflight`/`postflight`/`uninstall` -stanzas run arbitrary Ruby code (including shelling out via `system_command`) at install time — a malicious or -compromised cask (from a third-party tap, or a compromised/typosquatted first-party one) can use this to execute -code with the installing user's privileges. This is the macOS analogue of the same install-time-hook abuse pattern -already covered for npm/Composer/pip elsewhere in this ruleset; Homebrew is macOS's dominant developer package -manager and had zero coverage in `elastic/detection-rules` prior to this rule, including no representation in the -existing cross-platform package-manager ancestor meta-rule (`344e6c7d-ceb0-4f20-ba04-7c75569a7e38`), which only -recognizes npm/pip/cargo. +stanzas run arbitrary Ruby code at install time, including shelling out via `system_command`. A malicious cask from +a third-party tap, or a compromised or typosquatted first-party one, can use this to execute code with the +installing user's privileges. Homebrew is the dominant developer package manager on macOS, which makes install-time +hooks an attractive execution path. """ false_positives = [ """ - Real testing during this rule's development found that Homebrew's *own* internal package-management operations - (extracting the download archive, setting quarantine/extended attributes, symlinking binaries, checking CPU - type) are themselves children of the same bundled Ruby interpreter, indistinguishable at the process-tree level - from a cask's own hook code -- there is no OS-level signal that separates "Homebrew's own hardcoded logic" from - "a cask author's custom hook". This rule's exclusion list was built empirically from a real, clean - `binary`-artifact cask install with no hooks defined (`env`, `xattr`, `chmod`, `tar`, `bsdtar`, `ln`, `hdiutil`, - `xargs`, `defaults`, `clang`, `sysctl`) rather than assumed. + Homebrew's own internal package-management work runs as children of the same bundled Ruby interpreter and is + indistinguishable at the process-tree level from a cask author's hook code. The exclusion list was measured + from real clean-cask installs rather than assumed, but a Homebrew version that shells out to a utility not on + that list will match. Compare the child process against a clean install on the same Homebrew version. """, """ - Real testing (2026-08-07, a fresh clean-cask install with `HOMEBREW_NO_AUTO_UPDATE=1`/`HOMEBREW_NO_ANALYTICS=1` - set) found that a wider legitimate set is spawned as a direct child of the bundled Ruby interpreter regardless - of those two variables: `bash`/`sh` (wrapping several `stty`/`tput`/`python3.7` terminal-size and - interpreter-presence probes), `getconf`, `mdfind`, `pkgutil`, and `xcode-select` -- Homebrew's own - environment/requirement checks (CPU type, terminal dimensions, Xcode Command Line Tools presence), which run on - every invocation and are not gated by the auto-update/analytics settings as an earlier test pass had assumed. - This superseded and corrected that earlier (2026-08-06) finding, which had reproduced a narrower 11-name - baseline that turned out not to generalize. All of these names are now included in this rule's exclusion list - unconditionally; the real cask postflight hook event (`echo`) in the same test run was confirmed to still match - after adding them. + `app`-artifact casks, which are most casks in practice, invoke Gatekeeper and registration tooling such as + `codesign`, `spctl`, `mdimport` and `lsregister` as part of Homebrew's normal install flow. These are not in + the tested exclusion list and will match. Measure them in your environment before deploying broadly. """, """ - This rule is scoped and tested against `binary`-artifact casks only. A real `app`-artifact cask (most casks in - practice) additionally invokes Gatekeeper/registration tooling as part of Homebrew's own normal install flow - (e.g. `codesign`, `spctl`, `mdimport`, `lsregister`) which is NOT in this rule's tested exclusion list and will - likely false-positive until measured and added -- documented here as an explicit, honest scope limitation rather - than silently assumed to be covered. Do not extend this false-positive claim to formula (non-cask) source builds: - a real clean-formula install was also tested during this rule's development and produces a much wider legitimate - child-process set (`git`, `curl`, `clang`, `sandbox-exec`, `nice`, `xcode-select`, `mdfind`, `pkgutil`, - `getconf`, `tput`, and a *nested* sandboxed `ruby` for the actual build) -- this rule is not scoped or validated - for formula builds and would need a much larger, separately-measured exclusion list before covering that case. + Formula source builds spawn a much wider legitimate child set than casks, including `git`, `curl`, `clang`, + `sandbox-exec`, `xcode-select` and a nested sandboxed `ruby` for the build itself. This rule is scoped to cask + installs and is not validated for formula builds, which would need a separately measured exclusion list. """, ] from = "now-9m" @@ -86,33 +67,16 @@ A match here most often means a cask's `preflight`/`postflight`/`uninstall` Ruby references = [ "https://docs.brew.sh/Cask-Cookbook#stanza-preflight", "https://docs.brew.sh/Cask-Cookbook#stanza-postflight", + "https://www.securityweek.com/homebrew-macos-users-targeted-with-information-stealer-malware/", + "https://hunt.io/blog/macos-odyssey-amos-malware-campaign", ] risk_score = 47 rule_id = "5e07cb07-acdb-49e5-958c-53841e79a1ae" setup = """## Setup -This rule requires data coming in from Elastic Defend. +This rule is designed for data generated by [Elastic Defend](https://www.elastic.co/security/endpoint-security), which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules. -### 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). +Setup instructions: https://ela.st/install-elastic-defend """ severity = "medium" tags = [ From e45718fd875e365ff31eff7a457539ff0d24b010 Mon Sep 17 00:00:00 2001 From: clivoa <3012357+clivoa@users.noreply.github.com> Date: Mon, 19 Oct 2026 21:17:10 +0200 Subject: [PATCH 4/7] Address review on #6620: scope the bash/sh exclusion to Homebrew helper command lines, add Response and remediation, scope to binary-artifact casks --- ...ebrew_cask_unusual_hook_child_process.toml | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml index 1bc5df52c5..ba854ff9f0 100644 --- a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml +++ b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml @@ -2,29 +2,31 @@ creation_date = "2026/08/06" integration = ["endpoint"] maturity = "production" -updated_date = "2026/08/07" +updated_date = "2026/10/19" [rule] author = ["clivoa"] description = """ This rule detects an unexpected child process spawned by Homebrew's own bundled Ruby interpreter -(`vendor/portable-ruby`) during a `brew install --cask` operation. Homebrew Cask `preflight`/`postflight`/`uninstall` -stanzas run arbitrary Ruby code at install time, including shelling out via `system_command`. A malicious cask from -a third-party tap, or a compromised or typosquatted first-party one, can use this to execute code with the -installing user's privileges. Homebrew is the dominant developer package manager on macOS, which makes install-time -hooks an attractive execution path. +(`vendor/portable-ruby`) during a `brew install --cask` operation for a binary-artifact cask. Homebrew Cask +`preflight`/`postflight`/`uninstall` stanzas run arbitrary Ruby code at install time, including shelling out via +`system_command`. A malicious cask from a third-party tap, or a compromised or typosquatted first-party one, can use +this to execute code with the installing user's privileges. Homebrew is the dominant developer package manager on macOS, +which makes install-time hooks an attractive execution path. """ false_positives = [ """ Homebrew's own internal package-management work runs as children of the same bundled Ruby interpreter and is - indistinguishable at the process-tree level from a cask author's hook code. The exclusion list was measured - from real clean-cask installs rather than assumed, but a Homebrew version that shells out to a utility not on - that list will match. Compare the child process against a clean install on the same Homebrew version. + indistinguishable at the process-tree level from a cask author's hook code. Fixed utilities Homebrew invokes + directly are excluded by name, and the `bash`/`sh` probes it runs are excluded only when their command line names + one of Homebrew's own helper lookups (`getconf`, `xcode-select`, `mdfind`, `pkgutil`), so a shell hook that does + anything else still matches. A Homebrew version that shells out to a helper not covered by either list will match; + compare the child against a clean install on the same Homebrew version. """, """ `app`-artifact casks, which are most casks in practice, invoke Gatekeeper and registration tooling such as - `codesign`, `spctl`, `mdimport` and `lsregister` as part of Homebrew's normal install flow. These are not in - the tested exclusion list and will match. Measure them in your environment before deploying broadly. + `codesign`, `spctl`, `mdimport` and `lsregister` as part of Homebrew's normal install flow. These are not in the + tested exclusion list and will match. Measure them in your environment before deploying broadly. """, """ Formula source builds spawn a much wider legitimate child set than casks, including `git`, `curl`, `clang`, @@ -63,6 +65,17 @@ A match here most often means a cask's `preflight`/`postflight`/`uninstall` Ruby - See this rule's `false_positives` field: `app`-artifact casks are expected to trigger this on their own normal Gatekeeper/registration steps until the exclusion list is extended with real measured data; formula (non-cask) builds are out of scope entirely and not covered by this rule's exclusion list. + +### Response and remediation + +- Determine the cask and its tap. Treat a hook that spawned a shell, an interpreter, or a network client as + execution under the installing user and move to containment while you confirm intent. +- Capture the full process tree and command lines before the Caskroom is modified further, then remove the cask + with `brew uninstall --cask` and remove or disable the tap it came from. +- If the hook reached the network or wrote outside the Caskroom, treat the host as potentially compromised: hunt + for persistence (LaunchAgents/LaunchDaemons), rotate any credentials reachable from the user's session, and + review outbound connections from the process tree. +- Report a malicious first-party cask to Homebrew, and for a third-party tap warn other users of that tap. """ references = [ "https://docs.brew.sh/Cask-Cookbook#stanza-preflight", @@ -96,7 +109,11 @@ process where event.action == "exec" and host.os.type == "macos" and process.parent.executable like~ "*/Homebrew/vendor/portable-ruby/*" and not process.name in ( "env", "xattr", "chmod", "chown", "tar", "bsdtar", "ln", "hdiutil", "xargs", "defaults", "clang", "sysctl", - "bash", "sh", "getconf", "mdfind", "pkgutil", "xcode-select" + "getconf", "mdfind", "pkgutil", "xcode-select", "tput" + ) and + not ( + process.name in~ ("bash", "sh") and + process.command_line like~ ("*getconf*", "*xcode-select*", "*mdfind*", "*pkgutil*") ) ''' @@ -112,11 +129,12 @@ id = "T1195.002" name = "Compromise Software Supply Chain" reference = "https://attack.mitre.org/techniques/T1195/002/" + + [rule.threat.tactic] id = "TA0001" name = "Initial Access" reference = "https://attack.mitre.org/tactics/TA0001/" - [[rule.threat]] framework = "MITRE ATT&CK" [[rule.threat.technique]] @@ -124,7 +142,9 @@ id = "T1059" name = "Command and Scripting Interpreter" reference = "https://attack.mitre.org/techniques/T1059/" + [rule.threat.tactic] id = "TA0002" name = "Execution" reference = "https://attack.mitre.org/tactics/TA0002/" + From 93629275e8ab7a3bc44f0469c1cdfafe6fb2c487 Mon Sep 17 00:00:00 2001 From: clivoa <3012357+clivoa@users.noreply.github.com> Date: Sat, 31 Oct 2026 14:08:48 +0100 Subject: [PATCH 5/7] Switch to an inclusion-based query for Homebrew cask hook children --- ...ew_cask_suspicious_hook_child_process.toml | 175 ++++++++++++++++++ ...ebrew_cask_unusual_hook_child_process.toml | 150 --------------- 2 files changed, 175 insertions(+), 150 deletions(-) create mode 100644 rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml delete mode 100644 rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml diff --git a/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml b/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml new file mode 100644 index 0000000000..a3c8ca5a45 --- /dev/null +++ b/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml @@ -0,0 +1,175 @@ +[metadata] +creation_date = "2026/08/06" +integration = ["endpoint"] +maturity = "production" +updated_date = "2026/10/31" + +[rule] +author = ["clivoa"] +description = """ +Detects a suspicious child process spawned by Homebrew's bundled Ruby interpreter (`vendor/portable-ruby`) during a +`brew install`, `reinstall` or `upgrade`. Cask `preflight` and `postflight` blocks run arbitrary Ruby at install time, +including shelling out through `system_command`, so a malicious cask from a third-party tap, or a compromised or +typosquatted one, can use them to execute code with the installing user's privileges. The rule looks for what such a +hook would plausibly run: network and scripting tools, `osascript` prompts or shell-outs, `launchctl` persistence, +keychain and directory-service credential access, shells running download, decode or persistence commands, binaries +executed from temporary or shared directories, and untrusted or unsigned binaries. +""" +false_positives = [ + """ + A cask whose own install step legitimately runs one of the listed tools will match, for example a vendor helper + that is unsigned or ad-hoc signed, a `launchctl load` of the vendor's agent, or a vendor script run through + `python3`. Verify the cask and its tap, then scope an exception to that cask's executable path. + """, + """ + Homebrew's own nested `ruby` processes are ad-hoc signed and are excluded by path. A Homebrew release that starts + running a different unsigned helper of its own during installs would match. Compare against a clean install on + the same Homebrew version before excluding it. + """, +] +from = "now-9m" +index = ["logs-endpoint.events.process*"] +language = "eql" +license = "Elastic License v2" +name = "Suspicious Child Process of Homebrew's Bundled Ruby Interpreter" +note = """## Triage and analysis + +### Investigating Suspicious Child Process of Homebrew's Bundled Ruby Interpreter + +This rule flags a process spawned by Homebrew's bundled Ruby interpreter +(`.../Homebrew/vendor/portable-ruby/.../bin/ruby`) during `brew install`, `reinstall` or `upgrade` that matches a list +of tools and behaviours a malicious cask hook would plausibly use. A match most often means a cask's `preflight` or +`postflight` Ruby block executed a command. The list does not cover `uninstall` hooks, hooks that run a script file +instead of an inline `-c` command, or exfiltration with tools outside the list such as `ditto`, `zip`, `scp` or +`rsync`. + +### Possible investigation steps + +- Identify which cask was being installed from the parent's command line (`brew.rb install --cask /`) and + whether it is a known first-party cask or comes from a third-party or community tap. +- Review the spawned child's full command line for network activity (`curl`, `wget`, `nc`), a scripting interpreter + invocation (`bash -c`, `python3 -c`, `osascript`), or anything writing outside the cask's own Caskroom directory. +- If the cask is from a third-party tap, check the tap's Git history/commit author for the cask file for recent, + suspicious changes. +- Correlate with any subsequent network connections, persistence (LaunchAgent/LaunchDaemon creation), or credential + file access from the same process tree. + +### False positive analysis + +- A vendor helper run by a legitimate cask's install step can match when it is unsigned or ad-hoc signed, or when + the cask runs `launchctl`, `osascript` or an interpreter as part of its setup. Confirm the cask, its tap and the + helper's origin, then exclude that cask's executable path rather than the tool name. + +### Response and remediation + +- Determine the cask and its tap. Treat a hook that spawned a shell, an interpreter, or a network client as + execution under the installing user and move to containment while you confirm intent. +- Capture the full process tree and command lines before the Caskroom is modified further, then remove the cask + with `brew uninstall --cask` and remove or disable the tap it came from. +- If the hook reached the network or wrote outside the Caskroom, treat the host as potentially compromised: hunt + for persistence (LaunchAgents/LaunchDaemons), rotate any credentials reachable from the user's session, and + review outbound connections from the process tree. +- Report a malicious first-party cask to Homebrew, and for a third-party tap warn other users of that tap. +""" +references = [ + "https://docs.brew.sh/Cask-Cookbook#stanza-preflight", + "https://docs.brew.sh/Cask-Cookbook#stanza-postflight", + "https://www.securityweek.com/homebrew-macos-users-targeted-with-information-stealer-malware/", + "https://hunt.io/blog/macos-odyssey-amos-malware-campaign", +] +risk_score = 47 +rule_id = "5e07cb07-acdb-49e5-958c-53841e79a1ae" +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: Execution", + "Tactic: Initial Access", + "Data Source: Elastic Defend", + "Resources: Investigation Guide", +] +timestamp_override = "event.ingested" +type = "eql" + +query = ''' +process where event.action == "exec" and host.os.type == "macos" and + process.parent.executable like~ "*/Homebrew/vendor/portable-ruby/*" and + process.parent.args in ("install", "reinstall", "upgrade") and + ( + process.name in ("nc", "ncat", "perl", "node", "sqlite3") or + process.name like~ "python*" or + (process.name == "osascript" and + process.command_line like~ ("*do shell script*", "*display dialog*", "*hidden answer*")) or + (process.name == "launchctl" and process.args in ("load", "bootstrap", "submit", "enable")) or + (process.name == "security" and + process.args in ("find-generic-password", "find-internet-password", "dump-keychain", "export")) or + (process.name == "dscl" and process.args == "-authonly") or + (process.name in ("bash", "sh", "zsh", "dash") and process.args == "-c" and + process.command_line like~ ("*curl *", "*wget *", "*osascript*", "*base64*", "*python -c*", "*python3 -c*", + "*perl -e*", "*eval *", "*launchctl load*", "*launchctl bootstrap*", "*nohup*", + "*LaunchAgents*", "*LaunchDaemons*", "*| sh*", "*|sh*", "*| bash*", "*|bash*", + "*| zsh*", "*chmod +x*", "*com.apple.quarantine*", "*dscl*", "*security find-*", + "*sqlite3*")) or + process.executable like~ ("/tmp/*", "/private/tmp/*", "/var/folders/*", "/private/var/folders/*", "/Users/Shared/*") or + ((process.code_signature.trusted == false or process.code_signature.exists == false) and + not process.executable like~ "*/Homebrew/vendor/portable-ruby/*") + ) +''' + + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1195" +name = "Supply Chain Compromise" +reference = "https://attack.mitre.org/techniques/T1195/" +[[rule.threat.technique.subtechnique]] +id = "T1195.002" +name = "Compromise Software Supply Chain" +reference = "https://attack.mitre.org/techniques/T1195/002/" + + + +[rule.threat.tactic] +id = "TA0001" +name = "Initial Access" +reference = "https://attack.mitre.org/tactics/TA0001/" +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1059" +name = "Command and Scripting Interpreter" +reference = "https://attack.mitre.org/techniques/T1059/" + + +[rule.threat.tactic] +id = "TA0002" +name = "Execution" +reference = "https://attack.mitre.org/tactics/TA0002/" + diff --git a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml b/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml deleted file mode 100644 index ba854ff9f0..0000000000 --- a/rules/macos/execution_homebrew_cask_unusual_hook_child_process.toml +++ /dev/null @@ -1,150 +0,0 @@ -[metadata] -creation_date = "2026/08/06" -integration = ["endpoint"] -maturity = "production" -updated_date = "2026/10/19" - -[rule] -author = ["clivoa"] -description = """ -This rule detects an unexpected child process spawned by Homebrew's own bundled Ruby interpreter -(`vendor/portable-ruby`) during a `brew install --cask` operation for a binary-artifact cask. Homebrew Cask -`preflight`/`postflight`/`uninstall` stanzas run arbitrary Ruby code at install time, including shelling out via -`system_command`. A malicious cask from a third-party tap, or a compromised or typosquatted first-party one, can use -this to execute code with the installing user's privileges. Homebrew is the dominant developer package manager on macOS, -which makes install-time hooks an attractive execution path. -""" -false_positives = [ - """ - Homebrew's own internal package-management work runs as children of the same bundled Ruby interpreter and is - indistinguishable at the process-tree level from a cask author's hook code. Fixed utilities Homebrew invokes - directly are excluded by name, and the `bash`/`sh` probes it runs are excluded only when their command line names - one of Homebrew's own helper lookups (`getconf`, `xcode-select`, `mdfind`, `pkgutil`), so a shell hook that does - anything else still matches. A Homebrew version that shells out to a helper not covered by either list will match; - compare the child against a clean install on the same Homebrew version. - """, - """ - `app`-artifact casks, which are most casks in practice, invoke Gatekeeper and registration tooling such as - `codesign`, `spctl`, `mdimport` and `lsregister` as part of Homebrew's normal install flow. These are not in the - tested exclusion list and will match. Measure them in your environment before deploying broadly. - """, - """ - Formula source builds spawn a much wider legitimate child set than casks, including `git`, `curl`, `clang`, - `sandbox-exec`, `xcode-select` and a nested sandboxed `ruby` for the build itself. This rule is scoped to cask - installs and is not validated for formula builds, which would need a separately measured exclusion list. - """, -] -from = "now-9m" -index = ["logs-endpoint.events.process*"] -language = "eql" -license = "Elastic License v2" -name = "Unusual Child Process of Homebrew's Bundled Ruby Interpreter" -note = """## Triage and analysis - -### Investigating Unusual Child Process of Homebrew's Bundled Ruby Interpreter - -This rule flags a process spawned by Homebrew's own bundled Ruby interpreter -(`.../Homebrew/vendor/portable-ruby/.../bin/ruby`) whose name is not one of the small set of utilities Homebrew's -own internal package-management logic is known to invoke for a routine, hook-free `binary`-artifact cask install. -A match here most often means a cask's `preflight`/`postflight`/`uninstall` Ruby block executed a command. - -### Possible investigation steps - -- Identify which cask was being installed (`brew list --cask` history, or the `HOMEBREW_*` environment variables - visible on the parent `bash`/`env` process's command line) and whether it is a known first-party cask or from a - third-party/community tap. -- Review the spawned child's full command line for network activity (`curl`, `wget`, `nc`), a scripting interpreter - invocation (`bash -c`, `python3 -c`, `osascript`), or anything writing outside the cask's own Caskroom directory. -- If the cask is from a third-party tap, check the tap's Git history/commit author for the cask file for recent, - suspicious changes. -- Correlate with any subsequent network connections, persistence (LaunchAgent/LaunchDaemon creation), or credential - file access from the same process tree. - -### False positive analysis - -- See this rule's `false_positives` field: `app`-artifact casks are expected to trigger this on their own normal - Gatekeeper/registration steps until the exclusion list is extended with real measured data; formula (non-cask) - builds are out of scope entirely and not covered by this rule's exclusion list. - -### Response and remediation - -- Determine the cask and its tap. Treat a hook that spawned a shell, an interpreter, or a network client as - execution under the installing user and move to containment while you confirm intent. -- Capture the full process tree and command lines before the Caskroom is modified further, then remove the cask - with `brew uninstall --cask` and remove or disable the tap it came from. -- If the hook reached the network or wrote outside the Caskroom, treat the host as potentially compromised: hunt - for persistence (LaunchAgents/LaunchDaemons), rotate any credentials reachable from the user's session, and - review outbound connections from the process tree. -- Report a malicious first-party cask to Homebrew, and for a third-party tap warn other users of that tap. -""" -references = [ - "https://docs.brew.sh/Cask-Cookbook#stanza-preflight", - "https://docs.brew.sh/Cask-Cookbook#stanza-postflight", - "https://www.securityweek.com/homebrew-macos-users-targeted-with-information-stealer-malware/", - "https://hunt.io/blog/macos-odyssey-amos-malware-campaign", -] -risk_score = 47 -rule_id = "5e07cb07-acdb-49e5-958c-53841e79a1ae" -setup = """## Setup - -This rule is designed for data generated by [Elastic Defend](https://www.elastic.co/security/endpoint-security), which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules. - -Setup instructions: https://ela.st/install-elastic-defend -""" -severity = "medium" -tags = [ - "Domain: Endpoint", - "OS: macOS", - "Use Case: Threat Detection", - "Tactic: Execution", - "Tactic: Initial Access", - "Data Source: Elastic Defend", - "Resources: Investigation Guide", -] -timestamp_override = "event.ingested" -type = "eql" - -query = ''' -process where event.action == "exec" and host.os.type == "macos" and - process.parent.executable like~ "*/Homebrew/vendor/portable-ruby/*" and - not process.name in ( - "env", "xattr", "chmod", "chown", "tar", "bsdtar", "ln", "hdiutil", "xargs", "defaults", "clang", "sysctl", - "getconf", "mdfind", "pkgutil", "xcode-select", "tput" - ) and - not ( - process.name in~ ("bash", "sh") and - process.command_line like~ ("*getconf*", "*xcode-select*", "*mdfind*", "*pkgutil*") - ) -''' - - -[[rule.threat]] -framework = "MITRE ATT&CK" -[[rule.threat.technique]] -id = "T1195" -name = "Supply Chain Compromise" -reference = "https://attack.mitre.org/techniques/T1195/" -[[rule.threat.technique.subtechnique]] -id = "T1195.002" -name = "Compromise Software Supply Chain" -reference = "https://attack.mitre.org/techniques/T1195/002/" - - - -[rule.threat.tactic] -id = "TA0001" -name = "Initial Access" -reference = "https://attack.mitre.org/tactics/TA0001/" -[[rule.threat]] -framework = "MITRE ATT&CK" -[[rule.threat.technique]] -id = "T1059" -name = "Command and Scripting Interpreter" -reference = "https://attack.mitre.org/techniques/T1059/" - - -[rule.threat.tactic] -id = "TA0002" -name = "Execution" -reference = "https://attack.mitre.org/tactics/TA0002/" - From f9089b935e4494c2184af404a55734a7224baf7d Mon Sep 17 00:00:00 2001 From: clivoa <3012357+clivoa@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:38:44 +0100 Subject: [PATCH 6/7] Match combined shell -c options and narrow the portable-ruby exclusion The shell clause now accepts grouped options such as -xc and -lc, and the untrusted-binary exclusion covers only Homebrew's own vendor/portable-ruby//bin/ruby instead of the whole directory. The response section no longer recommends brew uninstall, which evaluates the cask again and runs its uninstall hooks. Adds the Platform and Rule Type tags and aligns the dates with the PR. --- ...ew_cask_suspicious_hook_child_process.toml | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml b/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml index a3c8ca5a45..a6930a47f1 100644 --- a/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml +++ b/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml @@ -1,8 +1,8 @@ [metadata] -creation_date = "2026/08/06" +creation_date = "2026/08/07" integration = ["endpoint"] maturity = "production" -updated_date = "2026/10/31" +updated_date = "2026/08/07" [rule] author = ["clivoa"] @@ -22,7 +22,8 @@ false_positives = [ `python3`. Verify the cask and its tap, then scope an exception to that cask's executable path. """, """ - Homebrew's own nested `ruby` processes are ad-hoc signed and are excluded by path. A Homebrew release that starts + Homebrew's own nested `ruby` processes are ad-hoc signed and are excluded by their executable path + (`vendor/portable-ruby//bin/ruby`). A Homebrew release that starts running a different unsigned helper of its own during installs would match. Compare against a clean install on the same Homebrew version before excluding it. """, @@ -39,9 +40,9 @@ note = """## Triage and analysis This rule flags a process spawned by Homebrew's bundled Ruby interpreter (`.../Homebrew/vendor/portable-ruby/.../bin/ruby`) during `brew install`, `reinstall` or `upgrade` that matches a list of tools and behaviours a malicious cask hook would plausibly use. A match most often means a cask's `preflight` or -`postflight` Ruby block executed a command. The list does not cover `uninstall` hooks, hooks that run a script file -instead of an inline `-c` command, or exfiltration with tools outside the list such as `ditto`, `zip`, `scp` or -`rsync`. +`postflight` Ruby block executed a command. Shells match when they run an inline command, including combined option +forms such as `-xc` or `-lc`. The list does not cover `uninstall` hooks, hooks that run a script file instead of an +inline command, or exfiltration with tools outside the list such as `ditto`, `zip`, `scp` or `rsync`. ### Possible investigation steps @@ -64,8 +65,12 @@ instead of an inline `-c` command, or exfiltration with tools outside the list s - Determine the cask and its tap. Treat a hook that spawned a shell, an interpreter, or a network client as execution under the installing user and move to containment while you confirm intent. -- Capture the full process tree and command lines before the Caskroom is modified further, then remove the cask - with `brew uninstall --cask` and remove or disable the tap it came from. +- Capture the full process tree and command lines, and preserve the cask file from the tap and from the cask's + `Caskroom//.metadata` directory for analysis. +- Do not run `brew uninstall` or `reinstall` on the suspect cask. Homebrew evaluates the cask's Ruby code + again for both commands and runs its uninstall hooks, which gives the malicious code another execution. Remove the + installed artifacts, the cask's `Caskroom` directory and the tap directory with ordinary file system tools instead, + with the host isolated. - If the hook reached the network or wrote outside the Caskroom, treat the host as potentially compromised: hunt for persistence (LaunchAgents/LaunchDaemons), rotate any credentials reachable from the user's session, and review outbound connections from the process tree. @@ -113,6 +118,8 @@ tags = [ "Tactic: Initial Access", "Data Source: Elastic Defend", "Resources: Investigation Guide", + "Rule Type: Event Correlation (EQL)", + "Platform: macOS", ] timestamp_override = "event.ingested" type = "eql" @@ -130,7 +137,7 @@ process where event.action == "exec" and host.os.type == "macos" and (process.name == "security" and process.args in ("find-generic-password", "find-internet-password", "dump-keychain", "export")) or (process.name == "dscl" and process.args == "-authonly") or - (process.name in ("bash", "sh", "zsh", "dash") and process.args == "-c" and + (process.name in ("bash", "sh", "zsh", "dash") and process.args regex "-[a-zA-Z]*c[a-zA-Z]*" and process.command_line like~ ("*curl *", "*wget *", "*osascript*", "*base64*", "*python -c*", "*python3 -c*", "*perl -e*", "*eval *", "*launchctl load*", "*launchctl bootstrap*", "*nohup*", "*LaunchAgents*", "*LaunchDaemons*", "*| sh*", "*|sh*", "*| bash*", "*|bash*", @@ -138,7 +145,7 @@ process where event.action == "exec" and host.os.type == "macos" and "*sqlite3*")) or process.executable like~ ("/tmp/*", "/private/tmp/*", "/var/folders/*", "/private/var/folders/*", "/Users/Shared/*") or ((process.code_signature.trusted == false or process.code_signature.exists == false) and - not process.executable like~ "*/Homebrew/vendor/portable-ruby/*") + not process.executable like~ "*/Homebrew/vendor/portable-ruby/*/bin/ruby") ) ''' From 4f51f578692b6f1b1915ea84b0d0dd16bc8b6508 Mon Sep 17 00:00:00 2001 From: shashank-elastic <91139415+shashank-elastic@users.noreply.github.com> Date: Tue, 1 Dec 2026 16:01:29 +0530 Subject: [PATCH 7/7] Update rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml Co-authored-by: Bryan Porras --- ...ution_homebrew_cask_suspicious_hook_child_process.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml b/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml index a6930a47f1..c13f717b2f 100644 --- a/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml +++ b/rules/macos/execution_homebrew_cask_suspicious_hook_child_process.toml @@ -7,11 +7,11 @@ updated_date = "2026/08/07" [rule] author = ["clivoa"] description = """ -Detects a suspicious child process spawned by Homebrew's bundled Ruby interpreter (`vendor/portable-ruby`) during a -`brew install`, `reinstall` or `upgrade`. Cask `preflight` and `postflight` blocks run arbitrary Ruby at install time, -including shelling out through `system_command`, so a malicious cask from a third-party tap, or a compromised or +Detects a suspicious child process spawned by Homebrew's bundled Ruby interpreter ("vendor/portable-ruby") during a +"brew install", "reinstall" or "upgrade". Cask "preflight" and "postflight" blocks run arbitrary Ruby at install time, +including shelling out through "system_command", so a malicious cask from a third-party tap, or a compromised or typosquatted one, can use them to execute code with the installing user's privileges. The rule looks for what such a -hook would plausibly run: network and scripting tools, `osascript` prompts or shell-outs, `launchctl` persistence, +hook would plausibly run: network and scripting tools, "osascript" prompts or shell-outs, "launchctl" persistence, keychain and directory-service credential access, shells running download, decode or persistence commands, binaries executed from temporary or shared directories, and untrusted or unsigned binaries. """