Event ID 4689
Event ID 4689: Process Exit
A process has exited
- Log source
- Security
- How to enable it
- Detailed Tracking > Audit Process Termination (Success)
- Category
- Process Execution
- Priority
- Low
- Typical volume
- Very high
- MITRE ATT&CK
-
T1685 replaces T1562, T1562.001, T1562.006, which older guides still use.
What Event ID 4689 means
4689 is written when a process ends, with its exit status. It is the counterpart of 4688 and is often left disabled, since it doubles the volume without adding new programs to the log.
It earns its place in two situations. The first is lifetime: a program that runs for half a second and one that runs for nine hours look identical in 4688, and only the exit distinguishes a quick command from an implant. The second is absence: security agents and backup services are meant never to stop, so their exit is a signal in itself.
A targeted approach works well. Enable the event on servers of high value, forward only exits of protection and backup software, and keep the remainder locally for forensic use.
Key fields to inspect
| Field | Meaning | Suspicious when |
|---|---|---|
ProcessName | Full path of the program that ended. | Endpoint protection, backup, database or logging agents. |
ProcessId | Process identifier in hexadecimal. Matches NewProcessId in 4688. | Join on it with the host and a time window, because it is reused. |
Status | Exit code in hexadecimal. 0x0 is usually success. | 0x1 or 0xFFFFFFFF for an agent, which is typical of forced termination. |
SubjectUserName | Account that the process ran as. | SYSTEM for agents that should only stop during updates. |
SubjectLogonId | Session that the process belonged to. | A remote session that ended many processes. |
Detection queries
Alert when protection or backup processes exit, and several different ones end on one host within five minutes. Adjust names and thresholds to your environment. About these queries.
Splunk SPL
index=windows source="XmlWinEventLog:Security" EventCode=4689
| regex ProcessName="(?i)(MsMpEng|MsSense|Sysmon|csfalcon|SentinelAgent|cb\.exe|veeam|sqlservr|vss)"
| bin _time span=5m
| stats dc(ProcessName) AS programs values(ProcessName) AS names values(Status) AS codes BY _time Computer
| where programs>=2 Microsoft Sentinel KQL
SecurityEvent
| where EventID == 4689
| where ProcessName matches regex @"(?i)(MsMpEng|MsSense|Sysmon|csfalcon|SentinelAgent|veeam|sqlservr|vss)"
| summarize Programs = dcount(ProcessName), Names = make_set(ProcessName, 20), Codes = make_set(Status) by Computer, bin(TimeGenerated, 5m)
| where Programs >= 2 PowerShell
Get-WinEvent -FilterHashtable @{ LogName = 'Security'; Id = 4689; StartTime = (Get-Date).AddDays(-1) } |
ForEach-Object { $d = @{ Time = $_.TimeCreated }; ([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }; [pscustomobject]$d } |
Where-Object { $_.Status -ne '0x0' } |
Select-Object Time, ProcessName, ProcessId, Status, SubjectUserName | Format-Table -AutoSize Attack scenarios
Security tools killed before ransomware
Vulnerable drivers let an attacker end protected processes. Several agents and database services exit within a minute, none through its own service stop, and file changes begin.
Estimating what an attacker did
The time between 4688 and 4689 of an archiver or copy tool gives a rough size for the data that was collected, which helps when no network volume was recorded.
Investigation checklist
- Join with 4688 on host and process identifier to get the command line and start time.
- Check whether a service stop or a software update explains the exit.
- Look for driver loads and new services (7045) just before.
- Confirm that the agent is running again, and isolate the host if it is not.
Common benign causes
- Every ordinary program close, which is nearly all of the volume.
- Agent updates, when the old process ends and a new one starts.
- Shutdown and restart.
Event ID 4689 FAQ
Should I enable event 4689?
On high-value servers it is worthwhile for process lifetimes and for noticing when protection stops. On workstations the volume usually outweighs the benefit, and Sysmon event 5 gives similar information with better filtering.
What does the exit status in 4689 tell me?
It is the code that the program returned. 0x0 normally means success. 0xC0000005 is an access violation, and other values depend on the program. A nonzero value for an agent suggests a crash or a forced end.
Does 4689 show who killed a process?
No. The subject is the account of the process that ended, and not the account that ended it. Use Sysmon event 10 or an EDR to find which process opened it with termination rights.