Attempt to Establish Microsoft Dev Tunnel
editAttempt to Establish Microsoft Dev Tunnel
editDetects 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
editTriage 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_linefor the exposed ports (-p/--port-numbers), whether anonymous access was allowed (--allow-anonymous), and any tunnel ID passed toconnect. -
Identify how the binary got on the host. Check
process.executableagainst standard installation paths and look for recent file creation events fordevtunnelordevtunnel.exein 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 loginordevtunnel createexecution 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.msandglobal.rel.tunnels.api.visualstudio.comat 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
editSetup
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
editprocess 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
-
Tactic:
- Name: Command and Control
- ID: TA0011
- Reference URL: https://attack.mitre.org/tactics/TA0011/
-
Technique:
- Name: Web Service
- ID: T1102
- Reference URL: https://attack.mitre.org/techniques/T1102/
-
Sub-technique:
- Name: Bidirectional Communication
- ID: T1102.002
- Reference URL: https://attack.mitre.org/techniques/T1102/002/
-
Technique:
- Name: Protocol Tunneling
- ID: T1572
- Reference URL: https://attack.mitre.org/techniques/T1572/