[Osquery_manager] Registry artifact saved query #16202
Open
+149
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Registry Persistence Detection
The Windows Registry Persistence query provides comprehensive visibility into autostart registry locations commonly abused by malware for persistence. This query detects entries across Run, RunOnce, Policy Run, Winlogon, and Active Setup keys with file hash and code signature enrichment for threat intelligence pivoting and trust assessment.
Core Forensic Artifacts Coverage
Queries by Platform
🪟 Windows - Registry Autostart Persistence Detection
Description
Detects Windows persistence via registry autostart locations. Enumerates Run, RunOnce, Policy Run, Winlogon, and Active Setup keys with file hash and code signature enrichment. Covers both HKLM and per-user (HKEY_USERS) locations including WOW64. Maps to MITRE ATT&CK T1547.001 (Registry Run Keys), T1547.014 (Active Setup).
Detection Focus:
Registry Locations Covered:
HKLM\...\CurrentVersion\RunHKLM\...\CurrentVersion\RunOnceHKEY_USERS\*\...\RunHKEY_USERS\*\...\RunOnceHKLM\...\WOW6432Node\...\RunHKLM\...\Policies\Explorer\RunHKLM\...\Winlogon(Shell, Userinit)HKLM\...\Active Setup\Installed Components\*Result
Query returns persistence entries with:
Platform
windowsInterval
3600seconds (1 hour)Query ID
registry_persistence_windows_elasticECS Field Mappings
Process Fields:
process.name→nameprocess.executable→executable_pathprocess.command_line→dataFile Fields:
file.path→executable_pathfile.hash.sha256→sha256file.hash.sha1→sha1file.hash.md5→md5file.size→sizefile.mtime→file_mtime_utcfile.ctime→file_ctime_utcfile.directory→directoryRegistry Fields:
registry.key→keyregistry.path→pathregistry.data.strings→dataregistry.value→nameCode Signature Fields:
code_signature.subject_name→subject_namecode_signature.status→signature_statusClassification Fields:
rule.category→persistence_typeevent.category→["configuration"](static)tags→["persistence", "mitre_t1547"](static)SQL Query
MITRE ATT&CK Coverage
Technical Notes
Query Design Decisions
No CTE (Common Table Expression): osquery's registry virtual table requires direct constraint pushing. Using a CTE breaks constraint optimization, resulting in incomplete results.
LEFT JOIN for Enrichment: Uses LEFT JOIN instead of CROSS JOIN to ensure all registry persistence entries are returned, even if the referenced file is missing, deleted, or inaccessible.
Filtered Winlogon Values: Only returns persistence-relevant Winlogon values (Shell, Userinit, Taskman, AppSetup) to reduce noise from configuration values.
Active Setup StubPath Only: Only returns the StubPath value from Active Setup keys, as this contains the actual persistence command. Other values (Version, ComponentID, Locale) are metadata.
Executable Path Extraction: Handles both quoted paths (
"C:\path\file.exe" args) and unquoted paths with arguments (C:\path\file.exe args).Forensic Value
This PR was AI assisted with Claude Code