Writable Scheduled Tasks or Cron Jobs
A scheduled task or cron job runs with high privileges, but its definition, or the script or binary it runs, can be changed by a low-privileged user.
| Severity | High |
| CVSS 3.1 | 7.8 CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H Open in the calculator |
| CVSS 4.0 | 8.5 CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-732: Incorrect Permission Assignment for Critical Resource |
| OWASP Top 10 | A01:2025 Broken Access Control |
| MITRE ATT&CK | T1053.003 Cron, T1053.005 Scheduled Task |
| Category | Broken Access Control |
Description
Scheduled tasks on Windows, and cron jobs and systemd timers on Linux, often run with high privileges, as SYSTEM, root or a service account. A task is only as safe as the files it depends on. Where a low-privileged user, or an attacker who has compromised such an account or a web application on the host, can modify the task definition, the script or binary it runs, a file or module that the script loads, or a directory on its search path, they can make the task run their own commands with its privileges the next time it starts, and so take full control of the host. The attacker may have to wait for the next scheduled run, but because the task runs on a schedule, the change also provides persistence that survives reboots and may run unnoticed alongside the task's normal work. Where the task's account has rights on other systems, such as a domain service account, the impact extends beyond the host.
Typical examples are scripts kept in application or shared directories that all users can write to, cron entries that run scripts from user-writable locations, crontab files or /etc/cron.d entries that are writable by others, scripts that call other commands without full paths while the job's PATH includes a writable directory, and cron scripts that pass a wildcard to a command such as tar in a writable directory, where crafted file names are read as options.
The weakness is identified by listing tasks (schtasks /query /fo LIST /v or Get-ScheduledTask on Windows; /etc/crontab, /etc/cron.*, user crontabs and systemctl list-timers on Linux), checking the permissions on every file and directory each task uses, for example with icacls or ls -l, and watching for short-lived processes with a tool such as pspy.
Remediation
Protect everything a privileged task uses to the same level as the account it runs as:
- Make the task's scripts, binaries, configuration files, included modules and the directories that contain them writable only by administrators or root. On Windows, remove write and modify rights for
Users,Authenticated UsersandEveryone; on Linux, make sure the files are owned by root and are not group- or world-writable. - Keep scripts for privileged tasks in protected locations, such as a directory under
C:\Program Filesor/usr/local/sbin, rather than in user, temporary or shared application directories. - In scripts, call commands by full path, set a safe
PATHat the top of the crontab or script, and do not pass bare wildcards to commands that accept options (prefix them with./or use--so that file names cannot be read as options). - Restrict who can create and change tasks: keep
/etc/crontab,/etc/cron.dand the/etc/cron.*directories owned by root and not writable by others, use/etc/cron.allowwhere users do not need their own crontabs, and check that task definitions underC:\Windows\System32\Taskscannot be changed by standard users. - Run each task with the least privilege it needs, for example a dedicated account or a group Managed Service Account, rather than
SYSTEMor root.
Confirm the fix by repeating the permission checks, as a standard user, on every file and directory each task uses.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.