DNS over HTTPS via Unsigned or Untrusted Binary
editDNS over HTTPS via Unsigned or Untrusted Binary
editIdentifies connection attempts from unsigned or untrusted macOS processes executed from commonly abused staging or user-writable directories to known public DNS resolver IPv4 addresses over port 443. Adversaries may use DNS over HTTPS (DoH) to bypass the system resolver and obscure DNS queries associated with command-and-control. Because the rule evaluates connection-attempt metadata rather than application-layer traffic, an alert may represent a blocked or unsuccessful connection and does not by itself confirm DoH activity.
Rule type: eql
Rule indices:
- logs-endpoint.events.network-*
Severity: medium
Risk score: 47
Runs every: 5m
Searches indices from: now-9m (Date Math format, see also Additional look-back time)
Maximum alerts per execution: 100
References:
Tags:
- Domain: Endpoint
- OS: macOS
- Use Case: Threat Detection
- Tactic: Command and Control
- Data Source: Elastic Defend
- Resources: Investigation Guide
- Rule Type: Event Correlation (EQL)
- Platform: macOS
Version: 1
Rule authors:
- Elastic
Rule license: Elastic License v2
Investigation guide
editTriage 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 DNS over HTTPS via Unsigned or Untrusted Binary
Public resolvers such as Cloudflare, Google, Quad9, OpenDNS, and AdGuard accept DNS-over-HTTPS on port 443. A signed application normally sends DNS through the system resolver. An unsigned or untrusted Mach-O started from a staging directory that connects straight to one of these addresses is bypassing that resolver, which hides the lookup from DNS logs.
Possible investigation steps
- Review process.executable, process.code_signature, process.hash.sha256, and the parent process to see where the binary came from and why it is untrusted.
- Confirm destination.ip and destination.port are a public resolver on 443, then check for other outbound connections from the same process.entity_id that are not resolver addresses.
- Search file events for the executable being written into /tmp, /Users/Shared, Downloads, /Volumes, or ~/Library/Application Support just before the connection.
- Look for follow-on persistence such as a new LaunchAgent or LaunchDaemon, a login item, or a shell spawned by the same process.
- Pivot on the executable hash across hosts to see whether the same unsigned binary has made the same resolver connection elsewhere.
False positive analysis
- Unsigned helpers under ~/Library/Application Support sometimes speak DNS-over-HTTPS on their own. Confirm the binary with the user before excluding it, and scope the exception to its verified SHA-256 hash rather than a writable path or an unverified signing ID.
- A developer running an ad-hoc build from Downloads or /tmp can hit the same resolvers. Verify the exact build and use a hash-specific exception rather than excluding the staging directory or tool path.
Response and remediation
- Terminate the unsigned process and quarantine the executable from the staging directory.
- Block further execution of that hash and review the host for persistence and additional payloads downloaded after the resolver connection.
- If the same hash appears on other hosts, isolate those hosts and scope the download URL or parent process that wrote the binary.
Setup
editSetup
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.
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.
- 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.
- 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.
Rule query
editnetwork where host.os.type == "macos" and event.type == "start" and event.action == "connection_attempted" and
destination.port == 443 and
cidrmatch(destination.ip,
/* Cloudflare, including malware-blocking resolvers */
"1.1.1.1/32", "1.0.0.1/32", "1.1.1.2/32", "1.0.0.2/32", "1.1.1.3/32", "1.0.0.3/32",
/* Google */
"8.8.8.8/32", "8.8.4.4/32",
/* Quad9 */
"9.9.9.9/32", "149.112.112.112/32", "9.9.9.10/32", "149.112.112.10/32", "9.9.9.11/32", "149.112.112.11/32",
/* OpenDNS */
"208.67.222.222/32", "208.67.220.220/32",
/* AdGuard */
"94.140.14.14/32", "94.140.15.15/32") and
(process.code_signature.trusted == false or process.code_signature.exists == false) and
process.executable like (
"/tmp/*",
"/private/tmp/*",
"/private/var/tmp/*",
"/var/tmp/*",
"/Users/Shared/*",
"/Users/*/Downloads/*",
"/private/var/folders/*",
"/var/folders/*",
"/Volumes/*",
"/Users/*/Library/Application Support/*")
Framework: MITRE ATT&CKTM
-
Tactic:
- Name: Command and Control
- ID: TA0011
- Reference URL: https://attack.mitre.org/tactics/TA0011/
-
Technique:
- Name: Application Layer Protocol
- ID: T1071
- Reference URL: https://attack.mitre.org/techniques/T1071/
-
Sub-technique:
- Name: DNS
- ID: T1071.004
- Reference URL: https://attack.mitre.org/techniques/T1071/004/
-
Technique:
- Name: Protocol Tunneling
- ID: T1572
- Reference URL: https://attack.mitre.org/techniques/T1572/