Skip to main content
4657SecurityObject AccessSecurity tier 1

Event ID 4657: A registry value was modified

Event ID 4657 records that a registry value was created, changed or deleted, with the old and new data. It is written only when the key's SACL audits Set Value, and it fires for values, not for keys. Audit the Run keys and service keys first, and read ProcessName and NewValue together.

What Triggers Event 4657 and What Old and New Values Add

Event 4657 comes from the Audit Registry subcategory. It is written when a registry key value is modified, and Microsoft is specific that it does not fire when a key itself is modified. It needs a SACL entry that audits Set Value on the key, so like the other object access events it stays silent until you decide which keys matter. The reason to bother is what the event carries. Event 4663 on a registry key tells you a write right was used. Event 4657 tells you which value, and what it held before and after.

The fields are laid out for that. The Subject block names the account and SubjectLogonId. ObjectName is the full key path in the \REGISTRY\HIVE\PATH form, ObjectValueName is the value inside it, and HandleId correlates with the 4656 that opened the key. OperationType is a message code. Microsoft's event forwarding guidance spells out three: %%1904 is a new registry value created, %%1905 an existing value modified, and %%1906 a value deleted. OldValueType and OldValue describe the previous content, NewValueType and NewValue the new one, and the type fields use codes too, where Microsoft's sample shows %%1873 for a string. ProcessId is hexadecimal and matches the new process ID in a 4688, and ProcessName is the executable that made the change.

Watch the hive mapping, because it breaks more Run-key rules than anything else. Microsoft documents HKEY_LOCAL_MACHINE as \REGISTRY\MACHINE, but HKEY_CURRENT_USER appears as \REGISTRY\USER\ followed by the user's SID. A rule that looks for HKLM\Software\Microsoft\Windows\CurrentVersion\Run will never see a per-user Run value written under the SID path. Match on the tail of the path, CurrentVersion\Run, and let the hive prefix vary.

Run keys are the first place to put a SACL. MITRE lists the four classic locations, the Run and RunOnce keys under both HKCU and HKLM, and notes that programs referenced there execute when a user logs in, in that user's context. It adds that adversaries may name the entries to look like they belong to legitimate software. The sample on this page does exactly that. j.smith runs reg.exe and creates a new value called OneDriveSync under the user's Run key, pointing at sync.exe in a folder under AppData\Roaming. Nothing about the name is wrong. The process (a command-line registry tool launched by a user) and the target (a per-user path) are the story. MITRE tracks it as boot or logon autostart execution (T1547.001) and, more broadly, as Modify Registry (T1112).

The second place is the services tree. Windows stores a service's configuration, including the path to its executable, in the registry, which MITRE notes under Windows Service (T1543.003). Event 4697 has a limit that matters here: Microsoft says the service file name is recorded only when the service is created, and a later path change is not logged. A 4657 on the ImagePath value under CurrentControlSet\Services\NAME is the event that closes that gap. A trusted service whose ImagePath suddenly points at a different binary, or begins with cmd.exe /c, is a clean signal with few false positives.

Setting the SACL takes a minute per key. In the registry editor, open Permissions, then Advanced, then Auditing, add the principal whose writes you want to see (Everyone is the usual choice, since attackers use whatever account they hold) and tick Set Value. For a Run key, applying it to this key only is enough, because the values sit directly inside it. For the Services tree you need the permission to apply to the key and its subkeys, which is also where the noise comes from, so test on a single service first.

Microsoft's own monitoring guidance for this event is short and useful. Compare ProcessName with the process you expect to write the key. Flag processes outside System32 and Program Files, or running from a restricted folder. Check ProcessName for restricted substrings such as mimikatz or cain.exe. Monitor all 4657 events for a critical key, or for specific value names on a key where only those matter.

Event 4657 Fields

FieldWhat it tells youSimulated value
SubjectUserSidSID of the account that modified the value.S-1-5-21-424242-1104
SubjectUserNameName of the account that modified the value.j.smith
SubjectDomainNameDomain or computer name of the account.CORP
SubjectLogonIdLogon session ID; correlates to the 4624 that opened the session.0x8d15f6
ObjectNameFull key path in the \REGISTRY\HIVE\PATH form; HKCU appears as \REGISTRY\USER\SID.\REGISTRY\USER\S-1-5-21-424242-1104\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
ObjectValueNameName of the value that was modified.OneDriveSync
HandleIdHandle to the key; correlates with 4656.0x2c4
OperationType%%1904 created, %%1905 modified, %%1906 deleted.%%1904
OldValueTypeType of the previous value; a hyphen when the value is new.-
OldValuePrevious data of the value; a hyphen when the value is new.-
NewValueTypeType of the new value as a message code; Microsoft's sample uses %%1873 for a string.%%1873
NewValueNew data of the value.C:\Users\j.smith\AppData\Roaming\OneDriveSync\sync.exe
ProcessIdHexadecimal ID of the process that made the change.0x1a88
ProcessNameFull path of the executable that made the change.C:\Windows\System32\reg.exe

Inspect Event 4657 Values

Click a field to inspect the full simulated value, the way you would expand it in a SIEM event view.

Example Event 4657 Log

A representative Security entry for Event 4657, generated deterministically by our telemetry engine so every field holds a realistic, internally consistent value.

Simulated example generated by SOCSimulator Research
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Security-Auditing" />
    <EventID>4657</EventID>
    <Version>0</Version>
    <Level>0</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8020000000000000</Keywords>
    <TimeCreated SystemTime="2025-09-13T17:35:42.000Z" />
    <EventRecordID>920148</EventRecordID>
    <Channel>Security</Channel>
    <Computer>WS-SIM-001.corp.socsimulator.example</Computer>
    <Security />
  </System>
  <EventData>
    <Data Name="SubjectUserSid">S-1-5-21-424242-1104</Data>
    <Data Name="SubjectUserName">j.smith</Data>
    <Data Name="SubjectDomainName">CORP</Data>
    <Data Name="SubjectLogonId">0x8d15f6</Data>
    <Data Name="ObjectName">\REGISTRY\USER\S-1-5-21-424242-1104\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</Data>
    <Data Name="ObjectValueName">OneDriveSync</Data>
    <Data Name="HandleId">0x2c4</Data>
    <Data Name="OperationType">%%1904</Data>
    <Data Name="OldValueType">-</Data>
    <Data Name="OldValue">-</Data>
    <Data Name="NewValueType">%%1873</Data>
    <Data Name="NewValue">C:\Users\j.smith\AppData\Roaming\OneDriveSync\sync.exe</Data>
    <Data Name="ProcessId">0x1a88</Data>
    <Data Name="ProcessName">C:\Windows\System32\reg.exe</Data>
  </EventData>
</Event>

Detecting Event 4657

Run or RunOnce value created or modified (any hive)

Matches the key tail so HKCU entries under \REGISTRY\USER\SID are included. SPL assumes sourcetype XmlWinEventLog:Security. %%1904 is created and %%1905 is modified.

index=wineventlog sourcetype=XmlWinEventLog:Security EventCode=4657 OperationType IN ("%%1904", "%%1905")
| where match(ObjectName, "(?i)\\\\CurrentVersion\\\\Run(Once)?$")
| table _time, host, SubjectUserName, ProcessName, ObjectName, ObjectValueName, NewValue

ImagePath of an existing service changed

Closes the gap left by 4697, which logs the service path only at creation. The SACL on the Services keys must audit Set Value.

index=wineventlog sourcetype=XmlWinEventLog:Security EventCode=4657 ObjectValueName=ImagePath OperationType="%%1905"
| where match(ObjectName, "(?i)\\\\CurrentControlSet\\\\Services\\\\[^\\\\]+$")
| table _time, host, SubjectUserName, ProcessName, ObjectName, OldValue, NewValue

Value written by a command-line or scripting process

Installers write the same keys from msiexec.exe or their own setup binaries, so a registry tool or script host on an audited key is the interesting part. Extend the process list with the tools your attackers use.

index=wineventlog sourcetype=XmlWinEventLog:Security EventCode=4657
| where match(ProcessName, "(?i)\\\\(reg|powershell|pwsh|wscript|cscript|mshta)\\.exe$")
| table _time, host, SubjectUserName, ProcessName, ObjectName, ObjectValueName, NewValue

New value data points into a user-writable folder

Applies to any audited key. NewValue holds the command or path that will run.

index=wineventlog sourcetype=XmlWinEventLog:Security EventCode=4657 OperationType IN ("%%1904", "%%1905")
| where match(NewValue, "(?i)\\\\(AppData|Temp|ProgramData|Users\\\\Public)\\\\")
| table _time, host, SubjectUserName, ProcessName, ObjectName, ObjectValueName, NewValue

True Positive vs False Positive

Registry writes are constant, so scope is the whole game. Installers and updaters add Run values for tray applications. Group Policy refreshes write policy keys. Services update their own state values at every start. A SACL on a broad hive such as HKCU\Software would bury you, which is why you audit named keys and read the volume for a week before widening.

The true positives are specific. A Run or RunOnce value created by reg.exe, PowerShell, wscript, cscript or mshta, not by an installer. A NewValue that points into AppData, Temp, ProgramData or a Public folder. A value name that imitates a familiar product but does not match any software you deploy. An ImagePath modified on an existing service. An OldValue under System32 replaced by a NewValue in a user-writable folder, which is a hijack of something already trusted. Any of these shortly after a 4688 showing an Office application or a script host as the parent adds weight.

A complete persistence story has four beats. A 4688 shows a script host or Office process launching reg.exe. The 4657 records the new Run value and its target. After the next logon, a 4688 shows the binary from NewValue starting, normally as a child of the shell. And a 4624 from earlier ties the whole chain to a session you can attribute. When the first and last beats are present, the 4657 in the middle stops being a guess and becomes the proof of how the foothold was kept.

Start the investigation from the process. ProcessId leads to the 4688 and its parent chain. NewValue gives you a file to hash and check for a signature, and to look for on disk. The hive tells you the privilege level: HKLM needs administrator rights, HKCU does not, which matters for scoping the compromise. Search other hosts for the same ObjectValueName and NewValue pair. One host is an intrusion; the same pair on dozens is probably a management tool or a spreading threat, and the 4624 logon types help you decide which.

One blind spot to design around: 4657 sees values, not keys. Creating a brand-new key leaves no 4657 until a value is written into it, so a SACL that audits Create Subkey and the 4656 or 4663 events on the parent key are what show a key appearing.

MITRE ATT&CK® Techniques

Event 4657 telemetry feeds detections for these ATT&CK® techniques:

Practice Investigating Event 4657

Reading about a registry value was modified is one thing. Working the detection inside a live console is another. These free SOCSimulator operations cover the attack techniques Event 4657 helps you detect:

Start investigating free

Frequently Asked Questions

What is event ID 4657?
It records that a registry key value was created, modified or deleted. The event shows the account, the key path, the value name, the operation type, the old and new value types and data, and the process that made the change. It requires Set Value auditing on the key's SACL.
How do I decode OperationType in event 4657?
OperationType is a message code: %%1904 means a new registry value was created, %%1905 means an existing value was modified, and %%1906 means a value was deleted. Match the code in your rules rather than the rendered text, which depends on the language of the log source.
Why is there no 4657 when a registry key is created?
4657 is a value-level event. Microsoft states it does not generate when a registry key is modified, and it needs Set Value auditing in the key's SACL. Creating a key appears in 4656 or 4663 events with the Create Subkey right, and the first value written into it then produces a 4657.
Which registry keys should I audit for persistence?
Start with the Run and RunOnce keys under HKLM and HKCU, then the service keys under CurrentControlSet\Services, watching the ImagePath value. Match the key tail, since HKCU appears as \REGISTRY\USER\ plus the user's SID. Widen the SACL only after you have read the volume.

Sources

“4657 fields, Set Value SACL requirement, value-not-key behavior, \REGISTRY hive mapping, and Microsoft's monitoring recommendations”

“OperationType codes for 4657: %%1904 created, %%1905 modified, %%1906 deleted”

“4697 records the service file name only at creation; later path changes are not logged”

“Registry Run keys and startup folder (T1547.001): the four Run and RunOnce locations, execution at logon, masquerading of entries”

“Windows Service (T1543.003): service configuration including the executable path is stored in the registry”

“Modify Registry (T1112): registry interaction for defense evasion, persistence and execution”

Event ID

Event ID 4656: Handle Requested, AccessMask & Failures

Event ID 4656 logs a request for a handle to a file or key. Decode the requested AccessMask, read Failure events and Pri…

Read more
Event ID

Event ID 4663: File Access, AccessMask and Detection Queries

Event ID 4663 shows an access right being used on a file or key. Decode AccessMask, fix 'not logging', and detect stagin…

Read more
Event ID

Event ID 4670: Permissions Changed, SDDL Diff and Detection

Event ID 4670 logs a permission change with the old and new SDDL. Diff OldSd and NewSd, catch Everyone full control, and…

Read more
Glossary

What is Data Exfiltration? SOC Glossary

Data exfiltration in cyber security is the unauthorized transfer of data from an organization's systems to infrastructur…

Read more
Glossary

What is Persistence? SOC Glossary

Persistence is the set of techniques an adversary uses to keep access to a compromised system after whatever gave them t…

Read more
Glossary

What is Threat Hunting? SOC Glossary

Threat hunting is the proactive search through security telemetry for attackers that existing controls missed. The hunte…

Read more
Career Path

SOC Analyst (Tier 2) Career Guide: Salary & Skills

Tier 2 SOC Analysts handle the investigations that Tier 1 escalates. You dig into multi-stage attacks, coordinate contai…

Read more
Career Path

Threat Hunter Career Guide: Salary & Skills

Threat Hunters do not wait for alerts. You develop hypotheses based on threat intelligence and adversary behavior models…

Read more
Technique

Modify Registry (T1112): Detection Training

Modify Registry covers adversaries reading from or writing to the Windows Registry to hide configuration, erase traces, …

Read more
Technique

Boot or Logon Autostart Execution (T1547): Detection Training

T1547 Boot or Logon Autostart Execution is persistence through the startup plumbing of the OS: Run and RunOnce registry …

Read more
Comparison

SOCSimulator vs. LetsDefend: Platform Comparison

SOCSimulator wins on operational realism. You get multi-tool shift simulation with SLA pressure, noise injection, and al…

Read more
Event ID

Windows Event ID Library: SOC Reference

Windows Security and Sysmon event IDs with simulated log samples, field tables, and tested detection queries.

Read more