[Osquery_manager] Scheduled tasks artifact saved query #16082
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.
Scheduled Tasks Artifact (Cross-Platform Persistence Detection)
The Scheduled Tasks artifact provides comprehensive visibility into OS-level persistence mechanisms across all major operating systems. This wrapper encompasses three platform-specific queries that detect suspicious scheduled execution patterns using dual-detection logic: (1) non-whitelisted tasks/jobs not in known-good allowlists and (2) Living off the Land (LotL) attack indicators that identify abuse of legitimate system utilities. Together, these queries provide complete coverage for detecting persistence via scheduled execution—one of the most common techniques used by adversaries for maintaining long-term access to compromised systems.
Core Forensic Artifacts Coverage
Queries by Platform
🪟 Windows - Scheduled Task Persistence Detection
Description
Detects suspicious Windows scheduled tasks using dual-detection approach: (1) Non-whitelisted tasks not in known-good allowlist and (2) Living off the Land (LotL) attack indicators. Identifies both unsigned/unknown tasks AND abuse of legitimate Windows tools (powershell -e, certutil, wscript, etc.) for persistence, privilege escalation, and lateral movement. Uses path-based whitelist filtering to auto-exclude legitimate Microsoft Windows tasks from System32/SysWOW64 and known-good third-party updaters, while flagging suspicious patterns regardless of code signature. This query provides a live snapshot of currently configured tasks (not historical event log data).
Detection Focus:
Result
Query results will show suspicious scheduled tasks with dual classification: LOTL_INDICATOR for tasks exhibiting Living off the Land techniques, NON_WHITELISTED for tasks not matching known-good patterns, or both. Results include task metadata (name, path, action, state, schedule), detection reasoning, code signature information, and file hashes for executable validation.
Platform
windowsInterval
3600seconds (1 hour)Query ID
scheduled_tasks_windows_elasticECS Field Mappings
process.name→nameprocess.executable→actionprocess.command_line→actionfile.path→pathfile.hash.sha256→sha256file.hash.sha1→sha1file.hash.md5→md5file.size→sizefile.mtime→mtimefile.ctime→ctimefile.directory→directoryrule.category→typeevent.outcome→statecode_signature.subject_name→subject_namecode_signature.status→signature_resultevent.category→detection_methodrule.description→detection_reasonSQL Query
🐧 Linux - Cron Job Persistence Detection
Description
Detects suspicious Linux cron jobs using dual-detection approach: (1) Non-whitelisted cron jobs not in known-good allowlist and (2) Living off the Land (LotL) attack indicators. Identifies both non-standard cron jobs AND abuse of legitimate Unix tools (curl|bash, nc -e, base64 -d, etc.) for persistence, privilege escalation, and lateral movement. Uses path-based and command-based whitelist filtering to auto-exclude legitimate system cron jobs (cron.d, cron.daily, package managers, system maintenance tasks) while flagging suspicious patterns regardless of location. Supports multiple distributions (Ubuntu, Debian, CentOS, RHEL, Fedora, openSUSE). This query provides a live snapshot of currently configured cron jobs (not historical event log data).
Detection Focus:
Result
Query results will show suspicious cron jobs with dual classification: LOTL_INDICATOR for jobs exhibiting Living off the Land techniques, NON_WHITELISTED for jobs not matching known-good patterns, or both. Results include cron metadata (command, path, schedule, owner), detection reasoning, and file hashes for executable validation.
Platform
linuxInterval
3600seconds (1 hour)Query ID
crontab_linux_elasticECS Field Mappings
event.category→detection_methodrule.description→detection_reasonrule.category→typeprocess.command_line→commandprocess.executable→executable_pathfile.path→executable_pathfile.hash.sha256→sha256file.hash.sha1→sha1file.hash.md5→md5file.size→sizefile.mtime→mtimefile.ctime→ctimefile.directory→directoryfile.uid→uidfile.gid→gidfile.mode→modeuser.name→crontab_ownerSQL Query
🍎 macOS - Launch Agent/Daemon Persistence Detection
Description
Detects suspicious macOS Launch Agents and Launch Daemons using dual-detection approach: (1) Non-whitelisted launch agents/daemons not in known-good allowlist and (2) Living off the Land (LotL) attack indicators. Identifies both non-standard persistence mechanisms AND abuse of legitimate macOS/Unix tools (curl, osascript, bash -c, base64 -d, etc.) for persistence, privilege escalation, and lateral movement. Uses path-based and code signature whitelist filtering to auto-exclude legitimate Apple system agents/daemons and known-good third-party software, while flagging suspicious patterns and unsigned binaries. This query provides a live snapshot of currently configured launch agents/daemons (not historical event log data). Final filter ensures results contain either LotL indicators OR unsigned/non-Apple signed binaries.
Detection Focus:
Result
Query results will show suspicious launch agents/daemons with dual classification: LOTL_INDICATOR for items exhibiting Living off the Land techniques, NON_WHITELISTED for items not matching known-good patterns, or both. Results are filtered to include only items with LotL indicators OR unsigned/non-Apple signed binaries. Results include launch item metadata (name, path, program, arguments, schedule, status), detection reasoning, code signature information, and file hashes for executable validation.
Platform
darwinInterval
3600seconds (1 hour)Query ID
launchd_macos_elasticECS Field Mappings
event.category→detection_methodrule.description→detection_reasonrule.category→typeevent.outcome→statusprocess.name→nameprocess.executable→programprocess.command_line→program_argumentsfile.path→programfile.hash.sha256→sha256file.hash.sha1→sha1file.hash.md5→md5file.size→sizefile.mtime→mtimefile.ctime→ctimefile.directory→directorycode_signature.signed→signedcode_signature.subject_name→identifieruser.name→usernameservice.id→nameSQL Query
This PR was AI assisted with Claude Code