Event ID 4688
Event ID 4688: Process Creation
A new process has been created
- Log source
- Security
- How to enable it
- Detailed Tracking > Audit Process Creation (Success), plus the policy "Include command line in process creation events"
- Category
- Process Execution
- Priority
- Medium
- Typical volume
- Very high
- MITRE ATT&CK
What Event ID 4688 means
4688 records every program that starts. Among built-in events it is the closest thing to a full account of what happened on a computer, because nearly all attacker activity ends up as a process at some point.
Out of the box it lacks its best part. The command line is recorded only if a separate policy is turned on, and without it powershell.exe is just a name. With the policy, encoded commands, download locations and remote targets are in plain view, and so is any password that someone typed as an argument, so protect the log accordingly.
Process identifiers are written in hexadecimal and are reused, so joining parent and child by number alone is unreliable over time. Include the host and a short window. Sysmon event 1 solves this with a unique identifier and adds hashes, which is why many teams collect both.
Key fields to inspect
| Field | Meaning | Suspicious when |
|---|---|---|
NewProcessName | Full path of the program. | Executables in user profiles, ProgramData, Temp, or a system name in the wrong folder. |
CommandLine | Arguments, if the policy is on. | -enc, DownloadString, FromBase64String, /node:, \\host\ADMIN$, or vssadmin delete shadows. |
ParentProcessName | Program that started it. Windows 10 and Server 2016 or later. | winword.exe, excel.exe, outlook.exe, w3wp.exe or sqlservr.exe starting a shell. |
SubjectUserName | Account that started it. | A service account running whoami or net. |
SubjectLogonId | Session that started it. | Match it to 4624 to see where the session came from. |
TokenElevationType | Type of token, related to User Account Control. | %%1937 (full token) for a standard user. |
MandatoryLabel | Integrity level as a SID. | S-1-16-16384 (System) for a program started by a user. |
TokenElevationType
| Value | Type | Meaning |
|---|---|---|
%%1936 | Type 1, default | Full token with no split, as for the built-in Administrator, services, or UAC off |
%%1937 | Type 2, full | Elevated with Run as administrator |
%%1938 | Type 3, limited | Administrator who runs without elevation |
Detection queries
Find shells and script hosts started by office programs, web servers and databases. Adjust names and thresholds to your environment. About these queries.
Splunk SPL
index=windows source="XmlWinEventLog:Security" EventCode=4688
| regex ParentProcessName="(?i)\\\\(winword|excel|powerpnt|outlook|w3wp|sqlservr|httpd|tomcat\d*)\.exe$"
| regex NewProcessName="(?i)\\\\(cmd|powershell|pwsh|wscript|cscript|mshta|rundll32|regsvr32|certutil|bitsadmin)\.exe$"
| table _time Computer SubjectUserName ParentProcessName NewProcessName CommandLine Microsoft Sentinel KQL
SecurityEvent
| where EventID == 4688
| extend Parent = tolower(tostring(split(ParentProcessName, "\\")[-1])), Child = tolower(tostring(split(NewProcessName, "\\")[-1]))
| where Parent in ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "w3wp.exe", "sqlservr.exe", "httpd.exe")
| where Child in ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe", "certutil.exe", "bitsadmin.exe")
| project TimeGenerated, Computer, SubjectUserName, Parent, Child, CommandLine PowerShell
Get-WinEvent -FilterHashtable @{ LogName = 'Security'; Id = 4688; StartTime = (Get-Date).AddDays(-1) } |
ForEach-Object { $d = @{ Time = $_.TimeCreated }; ([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }; [pscustomobject]$d } |
Where-Object { $_.CommandLine -match '-e(nc|c)?\s|DownloadString|FromBase64String|\\ADMIN\$' } |
Select-Object Time, SubjectUserName, ParentProcessName, NewProcessName, CommandLine | Format-List Attack scenarios
Malicious document
A macro or exploit makes an office program start cmd.exe, powershell.exe or mshta.exe. The parent and child pair is abnormal in almost any organization and needs no signature to detect.
Web shell
w3wp.exe or a Java server starts cmd.exe with commands such as whoami, ipconfig and net user. The account is the application pool, and the commands arrive in bursts as the operator types.
Living off the land
certutil with -urlcache, rundll32 with a script URL, and regsvr32 with /i:http download and run code with signed Windows programs. The program is trusted, so the arguments carry all of the evidence.
Investigation checklist
- Build the tree: find the parent of the parent until you reach a user action, a service or a task.
- Decode any Base64 in the command line. PowerShell uses UTF-16LE.
- Match SubjectLogonId to 4624 to find the session and its source.
- Search other hosts for the same path, command line or hash.
- Collect the file before it is deleted.
Common benign causes
- Management agents and login scripts that start shells with long arguments.
- Office add-ins that start helper programs.
- Developers and build servers, which need their own baseline.
Event ID 4688 FAQ
How do I enable command line logging for event 4688?
Turn on Audit Process Creation, then enable the policy under Computer Configuration, Administrative Templates, System, Audit Process Creation named Include command line in process creation events. The registry value is ProcessCreationIncludeCmdLine_Enabled, set to 1.
Is 4688 better than Sysmon event 1?
4688 is built in and needs no agent. Sysmon event 1 adds hashes, the original file name, the parent's command line and a unique process identifier. If you can deploy Sysmon, use it for investigation and keep 4688 as a fallback.
Why are process IDs in 4688 different from Task Manager?
They are written in hexadecimal. 0x1a4c is 6732 in decimal. Convert the value before you compare it with other sources.