01 / 22

Endpoint Persistence
Mechanisms

Learn how attackers maintain long-term access to compromised systems and how defenders can detect and prevent these techniques.

Cyber Security

What Is Persistence?

In cybersecurity, persistence refers to any technique an attacker uses to maintain access to a compromised system across reboots, logoffs, or credential changes. Without persistence, an attacker would lose their foothold every time the machine restarts.

Why Persistence Matters

✕ For Attackers
Ensures continued access for data theft, lateral movement, or deploying ransomware even after system restarts.
✓ For Defenders
Understanding persistence helps detect compromised systems, remove backdoors, and harden endpoints against future attacks.

Where Persistence Fits in the Attack Lifecycle

Reconnaissance Initial Access Execution Persistence Privilege Escalation Lateral Movement Data Collection Exfiltration Impact loop

The Core Principle of Persistence

System Boot / Login triggers Persistence Mechanism (registry, service, task...) executes Malicious Payload Survives reboot: cycle repeats Persistence = Automatic Re-execution Hook into a legitimate OS trigger so malware runs automatically

Categories of Persistence

Registry Keys
Entries that tell Windows to run a program at startup (e.g., Run, RunOnce).
Scheduled Tasks
OS-level jobs configured to execute code at specific times or on triggers.
Services
Background processes that start automatically when the operating system boots.
Startup Folders
Special filesystem directories whose contents auto-launch on user login.
DLL Hijacking
Placing a malicious DLL where a legitimate program loads it first.
Bootkit / Firmware
Modifying boot records or firmware to run before the OS even loads.

User-Level vs System-Level Persistence

User-Level System-Level
Privileges Needed Standard user Admin / SYSTEM
Scope Active only when that user logs in Active for all users, starts at boot
Common Locations HKCU\...\Run, user Startup folder HKLM\...\Run, services, boot records
Detection Difficulty Easier: user-space tools can see it Harder: may need kernel-level inspection
Stealth Lower: visible in user profile Higher: can masquerade as OS components

Registry Run Keys Deep Dive

Windows Registry HKCU\Software\Microsoft\ Windows\CurrentVersion\Run HKLM\Software\Microsoft\ Windows\CurrentVersion\Run User-Level (no admin) System-Level (admin required) "UpdateSvc" = "C:\Users\Public\svchost.exe" Legitimate-looking name, suspicious path Real svchost.exe lives in C:\Windows\System32\

Scheduled Tasks as Persistence

Attackers create a scheduled task that triggers on system startup, user logon, or at a recurring time interval. The task launches the malicious payload without any user interaction.

Trigger At logon Task Scheduler schtasks /create /tn "SystemCheck" Payload backdoor.exe Works on both Windows (schtasks) and Linux (cron jobs)

Services and Daemons

On Windows, attackers can create a new Windows Service or modify an existing one to point to their malware. On Linux, they can create a systemd unit file or modify init scripts. Services run as SYSTEM or root: the highest privilege level.

1
Create service: sc create "WinUpdate" binPath= "C:\malware.exe" start= auto
2
Start type "auto": Tells the OS to launch this service on every boot, no user interaction needed.
3
Runs as SYSTEM: The malware inherits the highest privileges on the machine.

Startup Folders and DLL Hijacking

Startup Folder
Drop a shortcut or executable into %AppData%\...\Startup. Windows auto-executes anything in this folder at login. Low sophistication, easy to detect.
DLL Hijacking
Place a malicious DLL in a directory that a legitimate program searches before the correct system directory. The program unknowingly loads the attacker's code.

How to Investigate Persistence

1
Enumerate auto-start locations: Use tools like Autoruns (Windows) or chkconfig/systemctl (Linux) to list everything that auto-launches.
2
Verify digital signatures: Legitimate software is usually signed by a known publisher. Unsigned or self-signed binaries are suspicious.
3
Check file paths: System binaries live in protected directories. Anything running from Temp, Downloads, or Public folders is a red flag.
4
Review timestamps: Compare the creation date of auto-start entries against known patch or install events. Anomalies indicate compromise.
5
Hash and lookup: Compute file hashes and check them against threat intelligence databases (e.g., VirusTotal).

Example: Suspicious Registry Entry

HKCU\Software\Microsoft\Windows\CurrentVersion\Run "SecurityHealth" = "C:\Windows\System32\SecurityHealthSystray.exe" ✓ "ChromeUpdater" = "C:\Users\Public\Downloads\chrome_up.exe" ✕ "OneDrive" = "C:\Program Files\Microsoft OneDrive\OneDrive.exe" ✓

Example: Malicious Scheduled Task

Task: "SystemHealthMonitor" Trigger: At system startup Action: powershell.exe -enc [Base64EncodedPayload] Run as: SYSTEM Created: 2:47 AM (outside business hours) by account "admin-temp"

Example: DLL Hijacking in Action

LegitApp.exe needs helper.dll DLL Search Order: 1. Application Directory C:\Apps\LegitApp\helper.dll MALICIOUS ✕ FOUND! Stops here. 2. C:\Windows\System32\ helper.dll (REAL) ✓ Never reached Result: LegitApp.exe loads attacker's DLL Malicious code runs with the app's permissions and trust level

Common Mistakes in Detection

✕ Only Checking Run Keys
Run keys are just one of dozens of persistence locations. Services, tasks, WMI subscriptions, and boot records must also be audited.
✕ Trusting File Names
Attackers name malware "svchost.exe" or "chrome_update.exe". Always verify by path, hash, and digital signature, not just the name.
✕ Ignoring Timestamps
A registry key or scheduled task created at 3 AM on a holiday is highly suspicious. Always correlate timestamps with known activity.

Summary of Persistence Mechanisms

Mechanism Privilege Stealth Detection Tool
Registry Run Keys User or Admin Low Autoruns, reg query
Scheduled Tasks User or Admin Medium schtasks, Task Scheduler
Services Admin / SYSTEM Medium-High sc query, services.msc
Startup Folder User Very Low File explorer, dir
DLL Hijacking Varies High Process Monitor, Sysmon
Bootkit / Firmware Admin / Physical Very High UEFI scan, chipsec

Question 1 of 5

An analyst discovers a new entry in HKCU\Software\Microsoft\Windows\CurrentVersion\Run pointing to C:\Users\Public\svchost.exe. What makes this suspicious?

Question 2 of 5

Which persistence mechanism runs with the highest privilege level by default?

Question 3 of 5

In a DLL hijacking attack, where does the attacker place the malicious DLL?

Question 4 of 5

A scheduled task named "SystemHealthMonitor" was created at 2:47 AM and runs powershell.exe -enc [encoded string] at startup. Which combination of indicators is most concerning?

Question 5 of 5

Which of the following is the most effective first step when investigating potential persistence on a compromised Windows endpoint?