Attempt to Establish Microsoft Dev Tunnel

edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Attempt to Establish Microsoft Dev Tunnel

edit

Detects the Microsoft devtunnel command line client started with the host or connect subcommand, which exposes a local port through, or connects to, a tunnel relayed by Microsoft Dev Tunnels infrastructure. The client is signed by Microsoft and its traffic goes to trusted Microsoft domains, which makes it a Living-Off-The-Land vector for command and control and for exposing internal services.

Rule type: eql

Rule indices:

  • logs-endpoint.events.process-*

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: Windows
  • OS: Linux
  • OS: macOS
  • Use Case: Threat Detection
  • Tactic: Command and Control
  • Data Source: Elastic Defend
  • Resources: Investigation Guide
  • Rule Type: Event Correlation (EQL)
  • Platform: Windows
  • Platform: Linux
  • Platform: macOS

Version: 1

Rule authors:

  • Elastic

Rule license: Elastic License v2

Investigation guide

edit

Triage and analysis

Investigating Attempt to Establish Microsoft Dev Tunnel

Microsoft Dev Tunnels lets a user expose a local port to the internet through a relay hosted by Microsoft. The devtunnel host subcommand publishes one or more local ports, and devtunnel connect attaches to an existing tunnel and forwards its ports to the local host. Because the client is signed by Microsoft and only talks to *.devtunnels.ms and global.rel.tunnels.api.visualstudio.com, adversaries use it to reach a compromised host from the outside, to bridge into internal networks, or to carry command and control traffic that blends with legitimate developer activity.

Possible investigation steps

  • Review process.command_line for the exposed ports (-p/--port-numbers), whether anonymous access was allowed (--allow-anonymous), and any tunnel ID passed to connect.
  • Identify how the binary got on the host. Check process.executable against standard installation paths and look for recent file creation events for devtunnel or devtunnel.exe in user writable or temporary directories.
  • Examine the parent process. A shell, script interpreter, Office application or remote management tool as parent is more suspicious than an IDE or terminal used interactively by a developer.
  • Search for a preceding devtunnel user login or devtunnel create execution and for authentication with a GitHub or Microsoft account that is not associated with the user.
  • Review network events from the process and from the services listening on the exposed ports to see what was accessed through the tunnel.

False positive analysis

  • Software developers commonly use Dev Tunnels from Visual Studio, Visual Studio Code or the command line to test webhooks and share local services. Confirm the user’s role and whether the tunnel was expected.
  • If Dev Tunnels is approved in the environment, add exceptions scoped to the expected users or hosts together with process.parent.executable.

Response and remediation

  • If the activity is not authorized, terminate the devtunnel process and remove the binary.
  • Block *.devtunnels.ms and global.rel.tunnels.api.visualstudio.com at the proxy or firewall where Dev Tunnels is not used.
  • Investigate the services exposed through the tunnel for unauthorized access and review the host for persistence that would restart the tunnel.
  • Rotate credentials of the account used to authenticate the tunnel if it is suspected to be compromised.

Setup

edit

Setup

This rule is designed for data generated by Elastic Defend, 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

Rule query

edit
process where host.os.type in ("windows", "linux", "macos") and event.type == "start" and
  event.action in ("exec", "start") and
  (process.name : ("devtunnel", "devtunnel.exe") or ?process.pe.original_file_name : "devtunnel.exe") and
  process.args : ("host", "connect") and
  not process.args : ("create", "delete", "list", "show", "update", "token", "access", "port", "user")

Framework: MITRE ATT&CKTM