Skip to navigation

Threat reportThreat IntelligenceTL-2026-0821

GhostTree / GhostBranch: Recursive NTFS Directory Junctions Abused to Evade Recursive File Scanners and Hide Malware

mediumPATCHED

GhostTree (and its single-junction variant GhostBranch) abuses legitimate Windows NTFS directory junctions to manufacture an astronomically large number of valid file paths that all resolve to the same location, causing recursive directory scanners — including Windows Defender and EDR products — to loop, hang, or skip files and leave co-located malware unscanned.

Key facts

IdentifiersTL-2026-0821
Also known asGhostTree, GhostBranch
SeverityMEDIUM
Affected productsMicrosoft Microsoft Defender Antivirus (Windows Defender) recursive directory scanning; Microsoft Windows NTFS directory junctions / reparse points; Multiple EDR / antivirus products performing unbounded recursive directory traversal
Weaknesses (CWE)CWE-674, CWE-59
MITRE ATT&CK techniquesT1027 Obfuscated Files or Information, T1036 Masquerading, T1036.005 Match Legitimate Resource Name or Location, T1059 Command and Scripting Interpreter, T1059.001 PowerShell, T1059.003 Windows Command Shell, T1070 Indicator Removal, T1070.004 File Deletion, T1106 Native API, T1112 Modify Registry, T1499 Endpoint Denial of Service, T1564 Hide Artifacts and 2 more in the attack flow
MotivationUNKNOWN
Detection rules9 (1 shown free)
Sources10 cited sources

Detection coverage

As of 2026-06-16, Threadlinqs Intelligence publishes 9 detection rule(s) for TL-2026-0821 across Splunk SPL, Microsoft KQL and Sigma, covering 18 indicator(s) of compromise. The whole corpus is readable without an account. Every threat comes with one complete detection in Splunk SPL, Microsoft KQL and Sigma, free for everyone; a free account adds daily TL Creds to unlock the rest. Paid plans add a larger daily allowance, correlation and the MCP server. Threadlinqs MCP server · View plans.

Free detection: GhostTree/GhostBranch — Self-Referential NTFS Junction Creation via mklink/New-Item (Exploitation)

Detects creation of NTFS directory junctions (mklink /J or PowerShell New-Item -ItemType Junction) — the core GhostTree/GhostBranch defense-evasion primitive. An attacker with only standard-user write permissions points a child directory back at an ancestor, manufacturing a filesystem cycle that traps recursive directory scanners (Defender/EDR) so co-located malware is left unscanned. Highest fidelity when the junction is created in a user-writable path such as %TEMP% or a user profile.

  • Languages: Splunk SPL, Microsoft KQL, Sigma
  • ATT&CK: T1564, T1564.004, T1059.003, T1059.001
  • Data sources: sysmon, windows_security, microsoft_defender_for_endpoint
  • Severity: high
  • Confidence: high

Splunk SPL

index=sysmon sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
(
  (Image="*\\cmd.exe" CommandLine="*mklink*" CommandLine="*/J*")
  OR (Image IN ("*\\powershell.exe","*\\pwsh.exe") CommandLine="*New-Item*" CommandLine="*Junction*")
)
| eval is_userwritable=if(match(CommandLine, "(?i)(\\\\Temp\\\\|\\\\AppData\\\\|\\\\Users\\\\|%TEMP%)"), "yes", "no")
| stats count min(_time) as firstSeen max(_time) as lastSeen values(CommandLine) as commandlines values(is_userwritable) as user_writable by host, User, ParentImage, Image
| where count >= 1
| convert ctime(firstSeen) ctime(lastSeen)
| table host, User, ParentImage, Image, user_writable, count, firstSeen, lastSeen, commandlines

Microsoft KQL

DeviceProcessEvents
| where Timestamp > ago(24h)
| where (FileName =~ "cmd.exe" and ProcessCommandLine has "mklink" and ProcessCommandLine has "/J")
   or (FileName in~ ("powershell.exe","pwsh.exe") and ProcessCommandLine has "New-Item" and ProcessCommandLine has "Junction")
| extend UserWritable = iff(ProcessCommandLine matches regex @"(?i)(\\Temp\\|\\AppData\\|\\Users\\|%TEMP%)", "yes", "no")
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, FileName, ProcessCommandLine, UserWritable
| order by Timestamp desc

Sigma

title: GhostTree/GhostBranch Self-Referential NTFS Junction Creation
id: 7f3a9c1e-2b44-4e7a-9c10-0a1b2c3d4e01
status: experimental
description: Detects creation of NTFS directory junctions via mklink /J or PowerShell New-Item -ItemType Junction, the core GhostTree/GhostBranch scanner-evasion primitive.
references:
    - https://www.varonis.com/blog/ghosttree-ntfs-trick
    - https://attack.mitre.org/techniques/T1564/
author: Threadlinqs Team
date: 2026-06-16
tags:
    - attack.defense_evasion
    - attack.t1564
    - attack.t1564.004
    - attack.execution
    - attack.t1059.003
    - attack.t1059.001
logsource:
    product: windows
    category: process_creation
detection:
    selection_mklink:
        Image|endswith: '\cmd.exe'
        CommandLine|contains|all:
            - 'mklink'
            - '/J'
    selection_ps:
        Image|endswith:
            - '\powershell.exe'
            - '\pwsh.exe'
        CommandLine|contains|all:
            - 'New-Item'
            - 'Junction'
    condition: selection_mklink or selection_ps
fields:
    - CommandLine
    - ParentImage
    - User
falsepositives:
    - Legitimate developer/admin use of junctions (build tooling, profile redirection)
level: medium

Known false positives:

  • Legitimate developer or admin junction creation (build systems, profile/folder redirection, deduplication tooling)
  • Backup or migration utilities that create mount points

Tuning notes: Raise severity when the junction path is under %TEMP%, AppData, or a user profile and is co-located with a recently written PE. Allowlist known build/CI accounts and software-deployment service accounts. Pair with reparse-point creation telemetry (SIG-003) to confirm the target resolves to an ancestor.

8 more detection rules (Splunk SPL, Microsoft KQL, Sigma) · unlock with TL Creds. Sign up free to unlock the detection rules or query them with the Threadlinqs MCP server (Purple)
  • GhostTree/GhostBranch — Reparse-Point (Mount Point) Junction Creation on Disk (Exploitation) · unlock with TL Creds
  • GhostTree — Single-Character Nested Junction Chain & Co-Located Payload (Post-Exploitation) · unlock with TL Creds
  • GhostTree — fsutil/PowerShell Reparse-Point Query & Indicator Removal (C2/Cleanup) · unlock with TL Creds
  • GhostBranch — cmd.exe Spawning mklink /J With Ancestor Target (Exploitation, Sigma-primary) · unlock with TL Creds
  • GhostTree — PowerShell New-Item Junction Creation (Post-Exploitation, Sigma-primary) · unlock with TL Creds
  • GhostTree — Self-Referential Mount-Point Reparse Cycle On Disk (C2/Hiding, Sigma-primary) · unlock with TL Creds
  • GhostTree Amplifier — LongPathsEnabled Registry Set to 1 (Post-Exploitation) · unlock with TL Creds
  • GhostTree — Defender/EDR Scan Engine Sustained High CPU & Hang (C2/Impact: Scanner DoS) · unlock with TL Creds

Indicators of compromise

As of 2026-06-16, Threadlinqs Intelligence tracks 18 indicators of compromise for TL-2026-0821.

18 indicators of compromise · unlock with TL Creds. Compare plans

Technical analysis

The technique requires only standard-user write permissions (mklink /J). Microsoft initially closed the report as 'not crossing a security boundary' before patching the underlying recursive-scan behavior.

GhostTree is a Windows defense-evasion technique disclosed by Varonis Threat Labs (researcher Dolev Taler) on 2026-06-16. It weaponizes NTFS directory junctions — reparse points (IO_REPARSE_TAG_MOUNT_POINT) that transparently redirect directory access — to create self-referential, recursive directory loops on disk.

The simpler variant, GhostBranch, uses a single junction that points a child directory back at its own parent: `mklink /J C:\Parent\Child C:\Parent`. Because the junction resolves to its ancestor, the file system exposes an endless ladder of valid paths to the same file: C:\Parent\Child\Program.exe, C:\Parent\Child\Child\Program.exe, and so on. Any tool that walks the directory tree recursively will keep descending into the loop and never terminate.

GhostTree amplifies this by creating multiple child junctions at each level that each point back to the parent (e.g. `mklink /J C:\Parent\Child1 C:\Parent` and `mklink /J C:\Parent\Child2 C:\Parent`), producing a branching tree. Varonis calculates that with binary branching constrained by Windows' path-length limits the structure yields roughly 2^126 ≈ 8.5 × 10^37 distinct valid paths to a single executable — vastly more than the estimated number of grains of sand on Earth (~8.5 × 10^18).

Windows enforces a traditional maximum path length (MAX_PATH) of 260 characters, which caps recursion at approximately 126 nested directory levels when single-character folder names are used. This limit can be raised to 32,767 characters via the LongPathsEnabled registry value, though many applications and utilities still cannot handle paths beyond 260, so attackers can use the legacy limit while still defeating scanners.

The security impact is on recursive directory traversal. Varonis tested the technique against Windows Defender (Microsoft Defender Antivirus) and confirmed it could evade folder scans: the scanning engine becomes consumed following the directory loop and ultimately hangs without completing, so malware placed alongside the junctions remains unscanned and undetected by the endpoint agent. The same failure mode affects EDR products that perform unbounded recursive directory scans. This behaves as a denial-of-service against the security scanner itself, providing cover for arbitrary co-located payloads.

The technique is notable because it requires only standard write permissions rather than administrative privileges — any low-privileged user (or a foothold process) can create junctions with the built-in mklink utility or the CreateSymbolicLink / DeviceIoControl(FSCTL_SET_REPARSE_POINT) APIs. Varonis reported the issue to Microsoft, who initially closed the ticket with the explanation that 'bypassing Defender is not crossing a security boundary,' but Microsoft subsequently patched the recursive-scanning behavior regardless.

No CVE was assigned. No in-the-wild exploitation, malware family, threat-actor attribution, or network indicators (C2 IPs, domains, or file hashes) were reported in the source material; consequently there is no network infrastructure to correlate (BeaconBeagle pivot is not applicable). The indicators below are behavioral/host-based artifacts of the technique itself. Defenders are advised to monitor file-system activity at the data layer — anomalous junction/reparse-point creation and recursive directory structures that should not exist under normal operation — rather than relying solely on recursive native scanning, and to apply current Microsoft Defender platform updates.

MITRE ATT&CK techniques by tactic:

Defense Evasion

T1027 Obfuscated Files or Information; T1036 Masquerading; T1036.005 Match Legitimate Resource Name or Location; T1070 Indicator Removal; T1070.004 File Deletion; T1564 Hide Artifacts; T1564.004 NTFS File Attributes

Execution

T1059 Command and Scripting Interpreter; T1059.001 PowerShell; T1059.003 Windows Command Shell; T1106 Native API

defense-impairment

T1112 Modify Registry; T1685 Disable or Modify Tools

Impact

T1499 Endpoint Denial of Service

Remediation

Patches

  • Microsoft patched the underlying recursive directory-scanning behavior in Microsoft Defender Antivirus (specific KB/build and date not disclosed in public reporting).

Immediate actions

  • Apply current Microsoft Defender Antivirus platform/engine updates, which include the fix for the recursive directory-scanning behavior abused by GhostTree/GhostBranch.
  • Hunt for self-referential NTFS directory junctions whose reparse target resolves to an ancestor of the link itself (recursive loops).

Workarounds

  • Detect and remove malicious junctions with fsutil reparsepoint query / fsutil reparsepoint delete or PowerShell reparse-point inspection.
  • Restrict or alert on junction creation in sensitive directories; treat single-character nested directory chains as suspicious.

Longer-term hardening

  • Monitor file-system activity at the data layer (e.g. minifilter/audit telemetry) to detect anomalous junction/reparse-point creation and recursive directory structures, rather than relying solely on recursive native file scanners.
  • Adopt defense-in-depth so that a single recursive-scan evasion does not leave endpoints blind; correlate process creation (mklink/cmd.exe) with reparse-point creation events.
  • Configure scanners/EDR with traversal depth limits, loop/cycle detection, and reparse-point handling so directory walks terminate safely.

Affected and fixed versions

  • Microsoft — Microsoft Defender Antivirus (Windows Defender) recursive directory scanning
    Vulnerable versions: Recursive-scan engine prior to fix (specific build undisclosed)
    Fixed in: Patched Defender platform/engine update (date undisclosed)
  • Microsoft — Windows NTFS directory junctions / reparse points
    Vulnerable versions: Junction creation available to standard users on supported Windows versions
  • Multiple — EDR / antivirus products performing unbounded recursive directory traversal
    Vulnerable versions: Implementations without reparse-loop / depth handling

Timeline

  • Varonis recommended data-layer file-system monitoring for anomalous junction/reparse-point creation and recursive directory structures rather than relying solely on recursive native scanning.
  • No CVE was assigned and no in-the-wild exploitation, malware family, or threat-actor attribution was reported; the disclosure is a defensive PoC against recursive directory scanners.
  • Researchers noted the recursion depth can be extended beyond the 260-character MAX_PATH limit to 32,767 characters by enabling the LongPathsEnabled registry value.
  • Varonis documented two variants: GhostBranch (single self-referential junction yielding ~126 nested path levels) and GhostTree (multi-junction branching yielding ~2^126 ≈ 8.5 × 10^37 distinct paths to one file).
  • Technique covered by BleepingComputer, Cyber Security News, GBHackers, and CyberPress.
  • Microsoft subsequently patched the underlying recursive directory-scanning behavior despite the initial triage decision (specific KB/build/date undisclosed).
  • Researchers reported the issue to Microsoft; the ticket was initially closed with the explanation that 'bypassing Defender is not crossing a security boundary.'
  • Varonis validated the technique against Windows Defender, confirming recursive folder scans hang and leave co-located files unscanned.
  • Varonis Threat Labs (researcher Dolev Taler) publicly disclosed the GhostTree / GhostBranch NTFS-junction evasion technique.

Sources cited

Previous and next in threat intel

Drafted by the Threadlinqs research pipeline from 10 sources; published ; last updated —.

Threadlinqs Intelligence — Real-Time Threat Detection Platform

// threat_feed
$ sort --newest
Showing all threats

Live intelligence console

Threat level

Latest Threats