Agent Foskett Academy • KQL Academy • Module 12 • Lesson 147 • Endpoint Investigation

Lesson 147 — A New Registry Run Key Appeared

Lesson 146 uncovered a scheduled task created during the suspicious endpoint activity. Now another persistence clue appears: a new value under a Windows Registry Run key.

In this lesson we use DeviceRegistryEvents to identify the registry change, preserve the value name and data, connect the modification back to the process that made it and determine whether the same autorun pattern appears elsewhere.

The registry value is only half the clue. The process that wrote it tells us why it matters.
Agent Foskett KQL Academy registry Run key persistence investigation
Your case file

Minutes after the suspicious execution, network connection and scheduled-task activity on WS-FIN-042, Defender records a new autorun registry value.

✓ Hunt Registry Run and RunOnce changes
✓ Preserve value name and command
✓ Identify the writing process
✓ Hunt the persistence clue across devices

Case briefing

CASE FILE Device: WS-FIN-042 01:22:19 — suspicious execution ↓ 01:22:24 — external connection ↓ 01:24:03 — scheduled task created ↓ 01:25:11 — Registry Run value appears Value name: UpdateCheck ↓ THE QUESTION What will the value launch, which process created it, and is this another persistence mechanism?

Investigation objective

Use DeviceRegistryEvents to investigate changes to common Windows autorun locations, identify the process and account responsible for the change, preserve the registry value data and determine whether the same persistence pattern exists elsewhere.

Investigator's rule

A Run key is not automatically malicious. Legitimate applications use autorun locations too. The investigative value comes from the command stored in the value, who wrote it, when it appeared and how it connects to the rest of the endpoint timeline.

Stage 1 — find Run and RunOnce changes

Begin with the known device and time window. Search DeviceRegistryEvents for changes under common Run and RunOnce paths while keeping the initiating-process context visible.

01-find-run-key-changes.kql
12345678910111213141516171819
let TargetDevice = "WS-FIN-042";
let TargetTime = datetime(2026-08-18 01:24:03);
DeviceRegistryEvents
| where DeviceName =~ TargetDevice
| where Timestamp between (TargetTime - 5m .. TargetTime + 10m)
| where RegistryKey has_any (
    @"\Software\Microsoft\Windows\CurrentVersion\Run",
    @"\Software\Microsoft\Windows\CurrentVersion\RunOnce"
)
| project Timestamp,
          ActionType,
          RegistryKey,
          RegistryValueName,
          RegistryValueData,
          InitiatingProcessFileName,
          InitiatingProcessCommandLine,
          InitiatingProcessId,
          InitiatingProcessAccountName
| order by Timestamp asc

Preserve RegistryValueData

The value name may be designed to look harmless. RegistryValueData can reveal the executable, script, path or arguments Windows is being instructed to launch.

ActionType matters again

Keep ActionType so the report distinguishes creation, modification and deletion rather than describing every registry event as a newly created key or value.

Stage 2 — follow the suspicious registry value

Once a distinctive value name is identified, follow its history on the device. Preserve both current and previous value data where available so changes are not mistaken for first-time creation.

02-follow-registry-value-history.kql
12345678910111213141516
let TargetDevice = "WS-FIN-042";
let TargetValueName = "UpdateCheck";
DeviceRegistryEvents
| where DeviceName =~ TargetDevice
| where RegistryValueName =~ TargetValueName
| project Timestamp,
          ActionType,
          RegistryKey,
          RegistryValueName,
          RegistryValueData,
          PreviousRegistryValueData,
          InitiatingProcessFileName,
          InitiatingProcessCommandLine,
          InitiatingProcessId,
          InitiatingProcessAccountName
| order by Timestamp asc

Creation and modification differ

An existing legitimate value being changed to launch a suspicious path tells a different story from a brand-new value. The event type and previous data help establish what actually changed.

Names are weak evidence

UpdateCheck sounds ordinary. That is precisely why the investigator should focus on the stored command, process ancestry and timing rather than the friendly-looking label.

Stage 3 — identify the process that wrote the value

The initiating-process fields can connect the registry modification to the suspicious process chain already reconstructed in this case.

03-identify-registry-writing-process.kql
12345678910111213141516
let TargetDevice = "WS-FIN-042";
let TargetTime = datetime(2026-08-18 01:25:11);
DeviceRegistryEvents
| where DeviceName =~ TargetDevice
| where Timestamp between (TargetTime - 5m .. TargetTime + 5m)
| where RegistryKey contains @"\CurrentVersion\Run"
| project Timestamp,
          RegistryKey,
          RegistryValueName,
          RegistryValueData,
          InitiatingProcessFileName,
          InitiatingProcessCommandLine,
          InitiatingProcessId,
          InitiatingProcessParentFileName,
          InitiatingProcessAccountName
| order by Timestamp asc

Connect the writer to the case

If the registry event was initiated by PowerShell, a command shell or another process already present in the incident timeline, that relationship can substantially strengthen the persistence hypothesis.

Keep the account

The initiating account helps explain whether the persistence was created in user context, elevated context or another security principal. That can affect both scope and remediation.

Stage 4 — hunt the value across the estate

Treat the value name and, more importantly, its command data as pivots. First determine whether the same named value appears on other endpoints.

04-hunt-registry-value-across-estate.kql
12345678910111213
let SuspiciousValueName = "UpdateCheck";
DeviceRegistryEvents
| where Timestamp > ago(7d)
| where RegistryValueName =~ SuspiciousValueName
| summarize FirstSeen=min(Timestamp),
            LastSeen=max(Timestamp),
            Events=count(),
            Devices=dcount(DeviceId),
            DeviceNames=make_set(DeviceName, 50),
            ValueData=make_set(RegistryValueData, 25),
            Creators=make_set(InitiatingProcessFileName, 25)
          by RegistryValueName
| order by FirstSeen asc

Repeated values need comparison

A common enterprise application may legitimately create the same autorun value everywhere. Compare the value data and creating process before concluding that multiple devices are compromised.

Attackers can vary the name

If the command or path is distinctive, hunt that too. Persistence mechanisms can use different value names while still launching the same payload or script.

Stage 5 — build the registry persistence timeline

Finish by placing the relevant registry events chronologically. This shows where the autorun change sits in relation to execution, network activity and the scheduled task from the previous lesson.

05-build-registry-persistence-timeline.kql
12345678910111213141516
let TargetDevice = "WS-FIN-042";
let StartTime = datetime(2026-08-18 01:22:00);
let EndTime = datetime(2026-08-18 01:30:00);
DeviceRegistryEvents
| where DeviceName =~ TargetDevice
| where Timestamp between (StartTime .. EndTime)
| where RegistryKey contains @"\CurrentVersion\Run"
| project Timestamp,
          ActionType,
          RegistryKey,
          RegistryValueName,
          RegistryValueData,
          InitiatingProcessFileName,
          InitiatingProcessCommandLine,
          InitiatingProcessAccountName
| order by Timestamp asc

Multiple persistence mechanisms matter

If the same suspicious chain creates both a scheduled task and a Run key, the attacker may have established more than one way to regain execution. Remediation must account for each confirmed mechanism.

Stay evidence-led

Document exactly what Defender observed first. Then explain why the registry change is suspicious in the context of the already established process, file and network evidence.

Agent Foskett's persistence timeline

01:22:19 suspicious execution ↓ 01:22:24 external connection ↓ 01:24:03 scheduled task created ↓ 01:25:11 DeviceRegistryEvents Run value: UpdateCheck ↓ VALUE DATA points to suspicious execution path ↓ WRITING PROCESS correlates with attack chain ↓ ASSESSMENT Second persistence mechanism suspected
The value name looked boring. The command behind it did not.

Your evidence board

EvidenceWhat it supportsWeight
Run/RunOnce value appears during incident windowPlaces autorun activity inside the compromise timeline.Strong context
Value data references suspicious path or commandConnects persistence to suspicious execution.Very strong
Initiating process belongs to attack chainConnects the registry change to earlier endpoint activity.Strong
Unexpected account writes the valueAdds identity and privilege context.Strong when validated
Same value appears elsewhereMay indicate wider persistence or legitimate software.Requires validation
Friendly-looking value name aloneDoes not establish legitimacy or maliciousness.Insufficient alone

Write the finding like an investigator

Example: Microsoft Defender XDR registry telemetry on WS-FIN-042 recorded an autorun value under a Windows CurrentVersion Run location shortly after the suspicious process, network and scheduled-task activity identified earlier in the investigation. The event preserved the registry value name, stored command, initiating process, account and timestamp. The value data referenced activity associated with the suspicious execution chain, while the initiating-process context connected the registry modification to the same incident sequence. The value name and command were then hunted across the environment to determine whether similar persistence existed on other endpoints. In context, the registry change supports the hypothesis that an additional persistence mechanism was established.

Lesson 147 key takeaways

  • DeviceRegistryEvents provides registry activity for Defender XDR advanced hunting.
  • Run and RunOnce locations are useful persistence hunting pivots but are also used legitimately.
  • Preserve ActionType so creation and modification are not confused.
  • RegistryValueData often matters more than the friendly-looking value name.
  • Use initiating-process fields to identify what wrote the registry value.
  • Account context can help explain the privilege and scope of the change.
  • Compare current and previous value data when investigating modifications.
  • Hunt distinctive value names, paths and commands across other devices.
  • Multiple persistence mechanisms can exist in the same compromise.
  • Interpret the registry event as part of the full process, file, network and persistence timeline.

Module 12 — the attack chain continues

Lesson 146 identified scheduled-task persistence. Lesson 147 now uncovers a second autorun mechanism in the registry. Next we investigate whether the attacker moved from persistence into credential access.

Next: Lesson 148 — LSASS Was Accessed by an Unexpected Process.

Continue your KQL investigation training

Module 12 follows endpoint evidence from suspicious execution through process relationships, files, network activity, persistence, credential access and spread.

Related Agent Foskett Investigations

Continue with endpoint investigations where persistence and process evidence must be correlated before reaching a conclusion.

🔎 KQL Academy — Module 12: Advanced Endpoint Investigation

Following the attack chain from the first suspicious process to a defensible endpoint compromise assessment.

Investigate Registry Run key persistence with KQL

Lesson 147 of the Agent Foskett KQL Academy uses Microsoft Defender XDR DeviceRegistryEvents to investigate Run and RunOnce autorun changes, registry value data and initiating-process evidence.

Hunt registry persistence in Microsoft Defender XDR

Learn how to connect registry changes to suspicious endpoint execution, identify the process and account responsible, hunt related persistence across devices and write a defensible investigation finding.