Alternate data streams: hunting NTFS stream abuse with Tanium

Alternate data streams: hunting NTFS stream abuse with Tanium

An NTFS alternate data stream (ADS) lets a file carry a second body of content that no directory listing shows and no reported file size includes. An attacker can park a portable executable (PE) inside one, leave the host file looking untouched, and run the payload by path. This walkthrough covers how to find those streams with Tanium questions, and how to keep the answer from filling up with the streams Windows creates on its own. It assumes you work in the question builder and know your way around a result grid.

Key takeaways

  • Alternate data streams are additional $DATA attributes on an NTFS Master File Table entry, mapped to T1564.004 (Hide Artifacts: NTFS File Attributes) under the Stealth tactic in ATT&CK v19.2.

  • A stream name can never contain a backslash, a forward slash, or a colon, which is what lets you separate a real stream from an ordinary path when you filter on a full path.

  • Attackers have used streams to stage payloads (OceanLotus in Operation Cobalt Kitty), to let a running binary delete itself (Latrodectus), and to disguise a decoded payload as a system library (a stream named kernel32.dll under %PROGRAMDATA%\Windows\).

  • On a healthy Windows fleet, effectively every stream present is one Windows or an installed agent created, and the benign set is much wider than Zone.Identifier alone. Cloud-sync placeholder state, SmartScreen verdicts, Intune app markers, and Apple extended attributes all appear as streams on Windows.

  • Benign streams are metadata, running from a handful of bytes to a few hundred. Content measured in kilobytes is the anomaly.

  • Index - File Details reads the endpoint's file index, so stream discovery needs no advance hunt setup on an indexed fleet.

  • Filtering on a stream's first four bytes separates streams by what they contain rather than what they are called.

  • sortByColumn sorts on the endpoint before the row limit is applied, so the sort you choose decides which rows reach the server.

Prerequisites

Requirement

Detail

Modules

Tanium Threat Response, with the Index solution deployed and an Index configuration covering the paths you intend to hunt.

Platform

Tanium Platform <VERSION TBC>

Endpoints

Windows. Alternate data streams are an NTFS construct, and ATT&CK scopes T1564.004 to Windows.

RBAC

The platform READ_SENSOR privilege, plus access to the Index content set for the three questions below, and the Threat Response content set for the recorded-history question near the end. Neither sensor is in Core Content, so content-set scoping may leave you with fewer rows than a fully privileged account sees.

Not covered by the three main questions: extracting stream contents, and NTFS Extended Attributes (a separate T1564.004 variant used by Regin and some Zeroaccess builds). The creation-time view is not one of the three main questions either, but it is covered separately below, alongside what the whole hunt does and does not establish.

How alternate data streams work

Every NTFS partition keeps a Master File Table (MFT) with a record per file and directory. Attributes inside that record hold the file's content. When a record carries more than one $DATA attribute, the extra ones are alternate data streams. Microsoft's file system specification gives the addressing form: a filename may be followed by a colon and a streamname, and that may be followed by a second colon and a streamtype (MS-FSCC §2.1.5 Pathname). That is why notes.txt:payload.exe and notes.txt:payload.exe:$DATA both address a stream, and why a path can legitimately carry more than two colons. Directories participate too: a directory has no default data stream but can still carry named ones (MS-FSCC §2.1.4 Alternate Data Streams).

The evasion value is that a stream is addressable but not enumerable by the tools people reach for first. dir omits streams, the reported file size counts only the default stream, and a scanner that reads a path without a stream component reads past the payload entirely.

Which streams attackers pick, and what makes them findable

Stream abuse splits into staging and masquerade, and the two leave different traces.

Staging keeps a payload somewhere a file-based control will not look. The group Cybereason tracks as OceanLotus, which FireEye named APT32, hid payloads in streams during Operation Cobalt Kitty. WastedLocker copied itself into a stream and executed from it. Latrodectus used a stream to delete itself while its process was still running. All of these leave executable content in a stream, which means the first 4 bytes give them away regardless of the stream's name.

Masquerade picks a name that reads as ordinary. Talos documented a decoded payload written to a stream named kernel32.dll under %PROGRAMDATA%\Windows\ in the DNSMessenger campaign; ATT&CK tracks that component as POWERSOURCE. BitPaymer copied itself into a stream named :bin and created a process from it, per CrowdStrike. Gazer fell back to streams for configuration items when the registry was unavailable, per ESET. A name filter catches kernel32.dll only if you already suspected it, and :bin has no extension to match at all.

Getting content into a stream needs no custom tooling. esentutl.exe, present at C:\Windows\System32\esentutl.exe, copies a file into a stream and back out again at user-level privilege with no elevation:

esentutl.exe /y payload.exe /d C:\notes.txt:file.exe /o

LOLBAS documents that direction, the reverse extraction, and a variant sourcing the payload over SMB, each mapped to T1564.004 and each requiring only user privileges. ATT&CK lists expand.exe for the same purpose. Both are signed Microsoft binaries that belong on the disk, so the detection has to sit on the stream, not on the tool.

Choosing which stream names to hunt

The stream name is the first thing you will reach for, and three properties of stream names decide whether that filter works.

A stream name cannot contain \, / or :. The specification states the prohibition outright, along with a 255-character limit (MS-FSCC §2.1.5.3 Streamname). This matters most when your filter is applied to a full path, because C:\Windows\ already supplies a colon and a pattern as loose as .*:.* will match every ordinary file on the disk. On a full path, require a colon followed by text containing no backslash. The three questions below filter on a file name rather than a full path, where the directory lives in its own column, so the colon in that field is the stream separator and a plain colon pattern is the right filter. Which field your pattern lands on decides which form you need.

A name filter cannot find what has no name worth matching. :bin and kernel32.dll are real stream names from real campaigns, and neither matches a suspicious-extension pattern. Extension filters are worth running as a supplement to content filtering, not as a substitute for it.

Script extensions have no file signature to fall back on. .ps1, .vbs, .bat and .cmd files are plain text, so for scripts the name is all you have. A PE always starts 4d5a. Split the work along that line, content filtering for executables and name filtering for scripts.

Step 1: establish the benign baseline

Enumerate the streams your fleet already has, so everything afterwards is measured against it rather than against an assumption.

Ask: Using the "Index - File Details" sensor, what streams exist on Windows endpoints, ordered by file name ascending?

Get "Index - File Details"["100","*",".*:.*","*","*","*","*","*","*","1","0","File Name","Ascending"] from all machines with "Is Windows" equals "True"

Returns Directory Path, File Name, Object Type, Size (Bytes), Created, Last Modified, Last Hashed, Magic Number (First 4 bytes), and the four hash columns. Interact collapses identical rows and reports a Count alongside them, which is what makes this usable as a prevalence view. Four things change what you see.

Object Type tells you whether a row is a stream at all, and the value to keep is the literal string data stream. Directory records arrive alongside the streams, and no parameter filters on object type, so narrow on that column in the grid before you read anything else.

Regex matching is case-sensitive; wildcard matching is not. The sensor builds a case-insensitive comparison for wildcard input and a case-sensitive one for regex input, so checking Treat Inputs as Regular Expressions gives up the case folding you had on the wildcard path. A pattern written \.(ps1|vbs) will not match :payload.PS1. Supply (?i) yourself once you switch to regex.

A parameter carries a condition only when you change it. Left at * it adds no condition at all rather than matching everything, and at least one parameter has to carry one for the question to return rows.

Index - File Details caches for 900 seconds, so a read can predate a stream created in the last quarter of an hour. On a large fleet this question returns a lot, and the steps below narrow it.

What the baseline looks like in practice: cloud-sync placeholder state and Zone.Identifier dominate, followed by Apple extended attributes (com.apple.quarantine, com.apple.macl, and the kMDItemWhereFroms download-provenance attribute) on files that passed through macOS, SmartScreen reputation verdicts, Intune's Win32App_1 marker, Distributed File System Replication (DFSR) folder lists, and Windows telemetry streams.

One of those is worth knowing before you build exclusions. At least one benign stream name is an opaque random-looking token that begins with a non-printable control byte, sitting on Performance Logs and Alerts task files. The specification permits exactly that: among control characters only the null byte is prohibited. So "the name looks strange" does not survive as a triage signal on its own, and an exclusion list keyed on readable names will not match everything you meant it to.

Step 2: filter on content, not on name

Every benign stream above is metadata, and metadata carries metadata signatures. Zone.Identifier opens 5b5a6f6e, the ASCII [Zon of its [ZoneTransfer] header. Apple metadata opens 62706c69, bpli for a binary property list. SmartScreen opens 416e6168. Cloud placeholder state opens 00000000. None of them opens 4d5a. That gap is what content filtering exploits. Ask for stream content beginning with the MZ header of a PE.

Ask: Using the "Index - File Details" sensor, which streams on Windows endpoints have content starting with the PE header 4d5a?

Get "Index - File Details"["100","*",".*:.*","*","4d5a","*","*","*","*","1","0","Directory Path","Ascending"] from all machines with "Is Windows" equals "True"

Returns the same columns as step 1, filtered to streams whose first four bytes are a PE signature. Position 5 is the magic-number parameter, matched against the first four bytes of the stream's content.

A clean fleet returns nothing here, and nothing is the correct answer. An executable parked in a stream is not something a healthy Windows estate produces on its own. Treat any row as an escalation rather than a triage queue: check the host file the stream hangs off, compare the stream's hash against the host file's to spot a straight duplication, and note the directory, since a user-writable path carries more weight than a system one.

Because this reads the endpoint's file index, absence of rows means no PE-bearing stream was found among indexed files on the endpoints that answered, within the paths your Index configuration covers.

Step 3: sort by size on the endpoint

limit at position 1 sets rows returned per endpoint and takes a maximum of 100. sortByColumn and sortOrder, at positions 12 and 13, sort on the endpoint before that limit is applied, which the parameter's own help text describes as the way to build a top-N or bottom-N list. The sort therefore decides which rows reach the server, and sorting by size descending pushes the metadata streams below the cut with no exclusion list to maintain.

Ask: Using the "Index - File Details" sensor, what are the largest streams on Windows endpoints, sorted by size descending?

Get "Index - File Details"["20","*",".*:.*","*","*","*","*","*","*","1","0","Size (Bytes)","Descending"] from all machines with "Is Windows" equals "True"

Returns the same column set, largest streams first. Run this for a size baseline rather than a verdict, because the baseline is the useful part. Benign streams top out in the low hundreds of bytes: download provenance, a reputation verdict, a placeholder record. A stream holding kilobytes already sits outside that distribution, and one holding a megabyte is not metadata at all.

Calibrate your own threshold from that rather than from a round number. A filter set at 10 KB is very conservative against a baseline peaking in the hundreds of bytes, and 1 KB already separates content from metadata on most fleets.

Two reading notes. Directory records interleave with streams in the sorted output, so apply the Object Type filter from step 1 before judging the ordering. And a live question answers as endpoints report: read the coverage figure before concluding, because the same question can return nothing on a first read and a full result set moments later, purely because more endpoints have answered.

Reading the results

Triage in this order.

  1. PE content in any stream. Step 2 returning rows is the strongest single signal in this hunt. Escalate rather than triage.

  2. Stream size outside the metadata range. Kilobytes or more, from step 3.

  3. Executable or script extension on the stream name, in a user-writable path such as %TEMP%, %APPDATA%, %PUBLIC%, Downloads, ProgramData, or a web root. Apply the case-sensitivity rule from step 1 when you write that pattern.

  4. A stream name that impersonates a system component. kernel32.dll as a stream name matches the DNSMessenger pattern above and has no legitimate use we are aware of.

  5. Multiple streams on one host file, or a stream whose hash matches its host file's.

Against that, the benign population is large and predictable. Download provenance, reputation verdicts, cloud placeholder state, mobile-device-management markers, replication lists, and Apple extended attributes account for the overwhelming majority of it, and all of it is small.

The creation-time view these questions do not cover

Everything above reads current state: the stream exists now and the index has seen it. It cannot tell you which process created the stream, when, or under which account, and it cannot see a stream created and removed between index passes.

Trace File Operations answers that from recorded file system history, filtered to Create operations. Its FilePath parameter takes a full path, so this is where the colon discriminator from the earlier section applies: require a colon followed by text containing no backslash, or the pattern matches every ordinary file create on the disk.

Three of its 11 parameters decide the shape of the answer. MaxResultsPerHost at position 5 sets how many events each endpoint returns; set it to 100 for a hunt, since the default of 1 is tuned for a presence check. MakeStackable at position 6 chooses between two output shapes: at "1" results collapse into a prevalence view, and at "0" you get one row per event with Endpoint Name, Timestamp, and Username present. Pick per question. TreatInputAsRegEx at position 3 must be "1" for a pattern to be read as a regex rather than a literal string. All 11 parameters belong in the bracket list in definition order, with "" for the ones you are not using.

Its regex matching is case-sensitive, as the index sensor's is, and it additionally requires the expression to match the entire field rather than a substring. Anchor the pattern end to end. The positional notes above are there for the hand-written case; in the question builder you set these by label.

Pairing that question with the three above is worth a writeup of its own.

What this hunt does and does not establish

A stream is not a payload. These questions establish that a second data stream exists, how big it is, and what its first four bytes are. They do not establish that the content is malicious, or that anything ever executed it. A PE in a stream is inert until something runs it, and current state carries no execution evidence at all.

Absence is scoped to collection. Empty results mean nothing matched among indexed files on the endpoints that answered within the coverage window. Paths outside your Index configuration are outside the hunt.

Which field you filter decides which pattern is correct. A colon-only pattern is right against a file name and wrong against a full path, where the drive letter supplies its own colon. Getting that backwards does not announce itself: it returns a large, plausible result set made entirely of ordinary file activity.

Scripts and executables need different questions. Content filtering finds PEs and cannot find scripts, because text files have no signature. Name filtering finds scripts and misses any payload whose stream name was chosen to look ordinary. Run both.

Extended Attributes are a separate variant. T1564.004 covers NTFS Extended Attributes alongside data streams, and Regin stored encrypted executables in them. Index - File Details addresses data streams; Extended Attribute abuse needs different collection and is not covered here. The macOS and Linux equivalent, extended attributes reached through xattr and getfattr, is a different sub-technique with different tooling and is also out of scope.

Next steps

Run step 1 once and keep the output as a named baseline, then re-run it on a schedule and diff the results. A stream name absent from last week's baseline is a better starting point than any static exclusion list. Set step 2 up as a standing check, since PE content in a stream should never be routine. Calibrate a size threshold for step 3 against your own baseline rather than a round number. Then add the recorded-history question above, so that once you find a stream worth asking about you can also answer which process created it.

Further reading

About HuntIQ

HuntIQ is Tanium's threat hunting practice. Our hunters go hands-on-keyboard in customer environments, running hunt campaigns against live telemetry, triaging what surfaces, pivoting from one endpoint to the whole estate, and escalating with the evidence already attached. Alongside that we build the durable content behind it, the Signals, hunt packages, and recurring hunts your own analysts can run without us.