The Windows registry is the configuration database that records how a machine and each of its users are set up, which makes it one of the first places an investigator looks when asking what ran, what changed and what was set to run again. This guide goes deeper than a general artefact overview. It covers how hives are stored on disk, which supporting files matter, what a key's last-write time does and does not tell you, how to collect hives without damaging evidence, and how to review the persistence locations that Microsoft documents, such as the Run and RunOnce keys and the Services tree.
It is written for incident responders, forensic analysts and detection engineers. It sits alongside the broader Windows Forensic Artefacts Guide, which places the registry among other Windows evidence sources, and it focuses on the registry alone. Facts about registry structure and behaviour on this page come from Microsoft's own documentation, cited in the references section. Where we give an opinion on method, we say so.
Key takeaways
- A hive is a logical group of keys, subkeys and values backed by files on disk. Most system hive files live in
%SystemRoot%\System32\Config, and each user who logs on gets a separate user profile hive (theNtuser.datfile behind HKEY_CURRENT_USER). - Collect the supporting files as well as the primary hive. Microsoft documents
.logfiles as transaction logs of changes, so leaving them behind can leave recent changes out of your analysis. - A key's last-write time reflects the last time the key or any of its value entries was modified. It tells you when something under the key changed, not which value changed or who changed it.
- Run and RunOnce keys exist under both HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER. Review both scopes, and remember that RunOnce values are normally deleted before their command runs.
- Each service has a key under
HKLM\SYSTEM\CurrentControlSet\Services. TheImagePath,StartandTypevalues together show what binary runs, when, and as what kind of service. - Registry findings are strongest when correlated with file system, event log and memory evidence on a single timeline.
How the registry is organised
Microsoft describes the registry as a hierarchical database organised as a tree, where each node is a key. A key can contain subkeys and values. Each value has a name and associated data, and a key can hold any number of values. Key names are not case sensitive, cannot contain a backslash, and must be unique among the keys directly above them. Value names and data can contain backslashes, which matters when you parse exported text or build search patterns.
The tree is deep. Microsoft documents that a registry tree can be 512 levels deep, and that up to 32 levels can be created in a single registry API call. In practice, most forensic questions are answered from a small set of well-known paths, but analysts should not assume that interesting data only sits near the root.
HKEY_LOCAL_MACHINE is the root most investigators start with. Microsoft lists its subkeys as HARDWARE, SAM, SECURITY, SOFTWARE and SYSTEM. Several of these map directly to hive files on disk, which is the link between what you see in Registry Editor on a live machine and what you analyse offline from an image.
Why the logical view and the file view differ
On a running system you browse a combined logical view made up of loaded hives. On a forensic image you have files. A good registry examination keeps the two views in mind: the path you report (for example HKLM\Software\Microsoft\Windows\CurrentVersion\Run) and the file you parsed to find it (the Software hive). Recording both makes your findings reproducible by another analyst.
Hives and their supporting files
Microsoft defines a hive as a logical group of keys, subkeys and values with a set of supporting files that are loaded into memory when the operating system starts or a user logs in. The documented standard hives and their supporting files are shown below.
| Registry hive | Supporting files |
|---|---|
| HKEY_CURRENT_CONFIG | System, System.alt, System.log, System.sav |
| HKEY_CURRENT_USER | Ntuser.dat, Ntuser.dat.log |
| HKEY_LOCAL_MACHINE\SAM | Sam, Sam.log, Sam.sav |
| HKEY_LOCAL_MACHINE\Security | Security, Security.log, Security.sav |
| HKEY_LOCAL_MACHINE\Software | Software, Software.log, Software.sav |
| HKEY_LOCAL_MACHINE\System | System, System.alt, System.log, System.sav |
| HKEY_USERS\.DEFAULT | Default, Default.log, Default.sav |
Microsoft explains the file extensions as follows. A file with no extension is a complete copy of the hive data. A .log file is a transaction log of changes to the keys and value entries in the hive. A .sav file is a backup copy of a hive, described for older Windows versions as a copy taken at the end of the text-mode stage of Setup. An .alt file is a backup copy of the critical HKEY_LOCAL_MACHINE\System hive, and only the System key has one.
Two points follow for investigators. First, the transaction logs are evidence in their own right, because they record changes that may not yet appear in the primary file you copied. Second, .sav and .alt files are older or backup states, so differences between them and the primary hive can help show what changed over time. Treat any such comparison carefully and label it as an inference.
Hive formats
Microsoft documents two registry file formats: standard and latest. The latest format is supported from Windows XP onwards. On versions that support it, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE\SAM, HKEY_LOCAL_MACHINE\Security and HKEY_USERS\.DEFAULT still use the standard format, and all other hives use the latest format. If a parser struggles with one hive but not others, the format difference is worth checking before you conclude that a file is corrupt or tampered with.
User hives and Ntuser.dat
Microsoft states that a new hive is created for each user who logs on, with a separate file for the user profile, called the user profile hive. User profile hives sit under HKEY_USERS on a live system. The supporting files for HKEY_CURRENT_USER are Ntuser.dat and Ntuser.dat.log. According to Microsoft, a user's hive contains registry information for application settings, desktop, environment, network connections and printers.
That list explains why user hives are so valuable. System hives describe the machine. User hives describe what a specific account configured, connected to and set to start at logon. When you investigate a compromised account, the user hive is often where you find the persistence and the traces of activity tied to that account rather than to the machine as a whole.
Practical points for user hives
- Collect the user hive for every profile on the system, not only the account you suspect. Attackers often move between accounts, and service or shared accounts are easy to overlook.
- Collect the matching
.logfile with eachNtuser.dat, for the reason given in the previous section. - Record which profile folder each hive came from, so that every finding can be tied to a named account.
- Remember that HKEY_CURRENT_USER on a live system shows only the user whose session you are in. Offline analysis of each profile hive avoids that blind spot.
Key last-write times
Every registry key carries a last-write time. Microsoft's documentation for the RegQueryInfoKey function says the returned FILETIME structure indicates the last time that the key or any of its value entries was modified. This timestamp is one of the most useful and most misread pieces of registry evidence.
What it tells you
- That something under the key changed at or before that time. A Run key with a last-write time inside your incident window is a strong lead.
- A way to order changes. Putting key last-write times on a timeline with file system and log events often shows the sequence of an intrusion.
What it does not tell you
- Which value changed. If a key holds ten values, the timestamp alone does not say which one was added or edited.
- Who made the change. The timestamp carries no user or process information.
- Whether subkey changes count. Microsoft's description covers the key and its value entries. It does not state that changes to subkeys update the parent, so do not rely on that.
- That the time is untouched. Timestamps can be affected by legitimate software and by deliberate tampering. In our view, a single timestamp should never be the only basis for a conclusion.
Our recommended practice is to report last-write times in UTC, note the hive file they came from, and corroborate them with at least one independent source, such as event logs, file creation times for the binary a value points to, or memory evidence. The Forensic Timeline Analysis Guide covers how to merge these sources.
Acquiring registry evidence
How you collect hives depends on whether you work from a disk image or a live system. Both are valid, but they produce different evidence and should be recorded as such.
From a forensic image
Working from an image is the cleanest approach. You copy the hive files and their supporting files from %SystemRoot%\System32\Config and from each user profile, hash them, and parse them offline. Nothing on the original system changes. The Disk Imaging and Forensic Acquisition Guide covers image creation and verification.
From a live system
Loaded hives are in use on a running machine, so a plain file copy may fail or be incomplete. Microsoft's built-in reg save command saves a copy of specified subkeys, entries and values to a file. Its syntax is reg save <keyname> <filename> [/y]. The key name must start with a valid root key: HKLM, HKCU, HKCR, HKU or HKCC locally, and only HKLM and HKU for a remote computer. The /y switch overwrites an existing file without prompting, and the command returns 0 for success and 1 for failure.
An illustrative live collection of the Software hive might look like this:
reg save HKLM\Software C:\IR\case042\Software.hiv
Points to record when collecting live, in our view:
- Write output to external or dedicated evidence storage, not to the system drive you are investigating where possible.
- Log the exact command, time (UTC), operator and the account used.
- Check the return code and hash each saved file immediately.
- Note in your report that the files are exports from a live system, not copies of the on-disk hive files, because the two can differ.
Live response trades some purity for speed. The Live Response vs Dead-Box Forensics page discusses when each approach fits.
Run and RunOnce persistence keys
The Run and RunOnce keys are the most familiar registry persistence locations, and MITRE ATT&CK tracks their abuse as T1547.001 Registry Run Keys / Startup Folder. Microsoft documents four paths:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunHKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceHKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunHKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
Documented behaviour that affects analysis
- Run versus RunOnce. A program under Run runs every time the user logs on. A program under RunOnce runs one time and then the entry is deleted.
- Deletion timing. By default a RunOnce value is deleted before its command line runs. Prefixing the value name with
!defers deletion until after the command runs. This means a RunOnce entry may be gone by the time you look, so absence is not proof that nothing ran. - Safe Mode. By default these keys are ignored when the computer starts in Safe Mode. Prefixing a RunOnce value name with
*forces the program to run even in Safe Mode. A value name beginning with*deserves a close look. - Machine RunOnce scope. HKLM RunOnce only executes when members of the Administrators group log on after the reboot.
- Value format. Each entry has the form description-string=commandline, and the command line is limited to 260 characters. Multiple entries can sit under one key, and their run order is indeterminate.
- Timing. The system does not guarantee how promptly Run key programs execute and may delay them, so the first execution may be some time after logon.
How to review them
- Export every value under all four keys from every system hive and every user hive collected.
- For each value, record the name, the command line, the key's last-write time and the hive file.
- Resolve each command line to a file path and check whether the file exists, its hashes, its signature status and its file system timestamps.
- Flag values whose names start with
!or*, command lines that call scripting hosts or point to user-writable folders, and entries that do not match your software baseline. These are our suggested triage criteria, not a Microsoft rule. - Compare against a known-good build of the same image where one exists.
Services as a persistence location
Microsoft documents that the HKLM\SYSTEM\CurrentControlSet\Services tree stores information about each service on the system, with one key per service or driver. Creating or modifying a service is a common way to gain persistence with high privilege, so this tree belongs in every Windows examination.
The values Microsoft lists as common are the most useful for triage:
| Value | Meaning (per Microsoft) | Why it matters to an investigator |
|---|---|---|
ImagePath | Path to the service binary | Points you to the file that actually runs |
Start | 0x0 Boot, 0x1 System, 0x2 Automatic, 0x3 Demand, 0x4 Disabled | Automatic start at boot gives reliable persistence; a security tool set to Disabled is a red flag |
Type | 0x1 kernel driver, 0x2 file system driver, 0x10 Win32 own process, 0x20 Win32 share process | Kernel and file system drivers run with the highest privilege |
ErrorControl | Severity if the service fails to start, from 0x0 Ignore to 0x3 Critical | Context for how the system reacts if the service breaks |
DisplayName and Description | Friendly name and description | Often imitated to make a malicious service look legitimate |
Microsoft also notes that drivers can store data under a Parameters subkey. When reviewing an unfamiliar service, look there as well as at the main key.
In our experience, the most productive checks are: services whose ImagePath points outside the usual program and system folders, services created inside the incident window according to the key's last-write time, recently changed Start values on security software, and display names that closely resemble Microsoft or vendor names. Note that CurrentControlSet is a logical path on a live system; when working offline from the System hive, record which control set you examined.
Registry evidence and non-human identities
Registry forensics is usually framed around human users, but many services, scheduled jobs and agents run under service accounts and other non-human identities. When a service key points to a binary that runs as a privileged service account, that account is part of the blast radius. In our view, every registry persistence finding should be tied back to the identity it runs as, and that identity's credentials should be reviewed and, where needed, rotated.
Registry modification itself is tracked in ATT&CK as T1112 Modify Registry, and registry reading for reconnaissance as T1012 Query Registry. Our pages on MITRE ATT&CK T1112 Modify Registry and T1012 Query Registry cover detection ideas for both.
Common failure patterns
- Copying only the primary hive. Leaving the
.logtransaction files behind can mean recent changes are missing from the analysis. - Checking only one user. Reviewing the suspect account's hive while ignoring other profiles misses persistence placed under service or administrator accounts.
- Reading too much into last-write times. Treating a key timestamp as the time a specific value was created, or as proof of who changed it.
- Treating an empty RunOnce key as clean. RunOnce values are normally deleted before they run, so absence proves little on its own.
- Ignoring machine-wide keys. Reviewing HKCU Run keys but not HKLM, or the reverse.
- Not recording the source. Reporting a registry path without naming the hive file, collection method and hash, which makes the finding hard to defend.
- Analysing in isolation. Drawing conclusions from the registry without correlating file system, event log and memory evidence.
- Modifying the live system. Writing collection output to the suspect drive, or editing keys during triage before a copy is saved.
Practitioner checklist
- Collect the System, Software, SAM, Security and Default hives with their
.log,.savand.altfiles where present. - Collect
Ntuser.datandNtuser.dat.logfor every user profile, and record which account each belongs to. - Hash every collected file and record the collection method (image copy or
reg saveexport), time in UTC and operator. - For live collection, check that each
reg savereturned 0 and write output to dedicated evidence storage. - Export all four Run and RunOnce keys from every relevant hive, and flag value names beginning with
!or*. - Review every key under the Services tree for unusual
ImagePath,StartandTypevalues and recent last-write times. - Resolve every persistence command line or image path to a file and examine that file.
- Place key last-write times on a UTC timeline with file system, event log and memory evidence before drawing conclusions.
- Map each persistence finding to the identity it runs as and review that identity's privileges and credentials.
- Document every finding with registry path, hive file, value data, timestamp and corroborating source.
Standards and references
- Microsoft Learn: Registry Hives
- Microsoft Learn: Structure of the Registry
- Microsoft Learn: RegQueryInfoKeyW function
- Microsoft Learn: Run and RunOnce Registry Keys
- Microsoft Learn: HKLM\SYSTEM\CurrentControlSet\Services Registry Tree
- Microsoft Learn: reg save
- NIST: SP 800-86 Guide to Integrating Forensic Techniques into Incident Response
- MITRE ATT&CK: T1547.001 Registry Run Keys / Startup Folder
Related NHI Mgmt Group resources: Windows Forensic Artefacts Guide · Forensic Timeline Analysis Guide · Digital Forensics (DFIR) Guide · MITRE ATT&CK T1112 Modify Registry