Back to skill

Security audit

Cron Scheduler

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed cron manager, but it needs Review because it can change persistent scheduled tasks and system cron service state, and one removal path can execute unintended local commands.

Install only if you trust this skill to edit your crontab and potentially affect the cron service. Before use, prefer reviewing exact crontab changes, avoid broad pattern removals, avoid service start/stop unless you intentionally want system-level changes, and consider fixing numeric validation, confirmation prompts, and backup permissions first.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/cron-helper.sh:145
Finding
GNU sed Program Injection Through Unvalidated Line Number<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cron-helper.sh:145-180` **Vulnerability Type**: Command injection through dynamically constructed sed program **Risk Level**: High ### Vulnerable Code ```bash remove_job() { check_crontab local mode="$1" local value="$2" local temp_file temp_file=$(mktemp) # Get current crontab local current_crontab current_crontab=$(crontab -l 2>/dev/null) || true if [[ -z "$current_crontab" ]]; then log_error "No cron jobs to remove" rm -f "$temp_file" exit 1 fi if [[ "$mode" == "line" ]]; then # Remove by line number echo "$current_crontab" | sed -n "H;1h;\$!d;x;s/^[0-9]*[ \t]*//;${value}d" > "$temp_file" log_success "Removed job at line $value" elif [[ "$mode" == "pattern" ]]; then # Remove by pattern echo "$current_crontab" | grep -v "$value" > "$temp_file" log_success "Removed jobs matching pattern: $value" else log_error "Invalid mode. Use 'line' or 'pattern'" rm -f "$temp_file" exit 1 fi crontab "$temp_file" rm -f "$temp_file" log_success "Cron job(s) removed" } ``` ### Technical Analysis The `remove` argument is expected to be a positive line number, but the script performs no numeric validation before interpolating it into a sed program: ```bash sed -n "...;${value}d" ``` Shell quoting prevents shell expansion of the value at this stage, but it does not prevent injection into sed's command language. On GNU sed, an attacker can include additional sed commands, including the GNU-specific `e` command, which executes a shell command. For example, a crafted value structured like `1e <shell-command> #` can cause the generated sed program to execute the supplied shell command when processing the first line. The appended `d` can be neutralized as part of a sed comment. This exploitation method is GNU sed-specific, m ...[truncated 1176 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Strictly require a positive decimal line number before invoking any text-processing utility: ```bash if [[ ! "$value" =~ ^[1-9][0-9]*$ ]]; then log_error "Line number must be a positive integer" rm -f "$temp_file" exit 1 fi ``` Avoid constructing an executable sed program from user input. Use a fixed program and pass the value as data, for example: ```bash awk -v target="$value" 'NR != target' <<< "$current_crontab" > "$temp_file" ``` Additional hardening should include: - Verify that the requested line exists before replacing the crontab. - Preview the exact entry to be removed and request confirmation. - Install the modified crontab only after the transformation succeeds. - Use an exit trap to remove temporary files on errors or interruption. - Add regression tests containing sed metacharacters and GNU sed `e` syntax. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/cron-helper.sh:17
Finding
Crontab Backups May Be Created with Excessively Permissive File Permissions<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cron-helper.sh:17-21, 241-257` **Vulnerability Type**: Insufficient protection of potentially sensitive backup data **Risk Level**: Medium ### Vulnerable Code ```bash # Configuration BACKUP_DIR="${HOME}/.cron-backups" SCRIPT_NAME="$(basename "$0")" # Ensure backup directory exists mkdir -p "$BACKUP_DIR" ``` ```bash backup_crontab() { check_crontab local timestamp timestamp=$(date +%Y%m%d_%H%M%S) local backup_file="${BACKUP_DIR}/crontab_${timestamp}.bak" local crontab_output crontab_output=$(crontab -l 2>/dev/null) || true if [[ -z "$crontab_output" ]]; then log_warn "No crontab to backup" return fi echo "$crontab_output" > "$backup_file" log_success "Backed up crontab to: $backup_file" } ``` ### Technical Analysis The script neither sets a restrictive `umask` nor explicitly assigns permissions to the backup directory and files. Their permissions therefore depend on the invoking process's environment. With a common `umask` of `022`, a newly created directory may receive mode `755` and a backup file may receive mode `644`. Whether another local user can reach the backup also depends on permissions of the user's home directory, but the backup mechanism itself does not enforce confidentiality. Crontab entries may expose internal paths, service endpoints, operational schedules, tokens embedded in command arguments, or other sensitive configuration. Copying these entries into broadly readable files can therefore create an additional disclosure surface. ### Attack Path 1. A user invokes the `backup` command under a permissive umask. 2. The script creates `~/.cron-backups` without an explicit restrictive mode. 3. The script writes the complete crontab to a new backup without setting mode `600`. 4. If parent-directory permissions permit traversal, another local account reads the backup. 5. Sensitive commands, paths, URLs, ...[truncated 560 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Enforce private permissions before creating any backup artifacts: ```bash umask 077 mkdir -p -- "$BACKUP_DIR" chmod 700 -- "$BACKUP_DIR" ``` Create each backup with mode `600` and fail closed if the operation cannot be completed securely: ```bash backup_file="${BACKUP_DIR}/crontab_${timestamp}.bak" (umask 077 && printf '%s\n' "$crontab_output" > "$backup_file") chmod 600 -- "$backup_file" ``` Further hardening should include: - Verify that `BACKUP_DIR` is a real directory owned by the invoking user. - Refuse to use an unexpected symbolic link as the backup directory. - Use collision-resistant or securely created backup files. - Warn users not to place credentials directly in crontab command lines. - Consider applying a retention policy to limit the lifetime of sensitive backups. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
scripts/cron-helper.sh:170
Finding
grep Option Injection and Unsafe Regular-Expression Matching in Pattern Removal<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cron-helper.sh:170-173` **Vulnerability Type**: Argument option injection and unintended destructive filtering **Risk Level**: Low ### Vulnerable Code ```bash elif [[ "$mode" == "pattern" ]]; then # Remove by pattern echo "$current_crontab" | grep -v "$value" > "$temp_file" log_success "Removed jobs matching pattern: $value" ``` The filtered result is subsequently installed: ```bash crontab "$temp_file" rm -f "$temp_file" log_success "Cron job(s) removed" ``` ### Technical Analysis The attacker-controlled pattern is supplied to grep without a `--` end-of-options marker: ```bash grep -v "$value" ``` Quoting preserves the argument as a single string but does not stop grep from interpreting a leading hyphen as an option. A crafted argument such as a long-form grep option can therefore alter how grep obtains or interprets its patterns. The script also uses grep's default regular-expression semantics. A pattern containing metacharacters may match substantially more entries than a user expects from the documentation's description of matching a “pattern.” Because the filtered output is installed directly as the new crontab, unexpectedly broad matching can remove unrelated scheduled jobs. ### Attack Path 1. An attacker controls or influences the argument passed to `removep`. 2. The attacker supplies a leading-hyphen grep option or a broad regular expression. 3. grep interprets the argument as configuration or regex syntax rather than a literal search string. 4. grep produces an unexpectedly filtered version of the current crontab. 5. The script installs that result with `crontab "$temp_file"`. 6. Unrelated cron jobs may be deleted or the removal operation may behave differently from the user's intent. ### Impact Assessment Exploitation can alter or remove cron entries belonging to the invoking user. This may disable backups, monitoring, synchronization, maintenance, or other schedu ...[truncated 256 chars]
Remediation
<![CDATA[ ## Remediation Suggestions If the intended behavior is literal substring matching, terminate option parsing and disable regular-expression interpretation: ```bash if [[ -z "$value" ]]; then log_error "Removal pattern must not be empty" rm -f "$temp_file" exit 1 fi printf '%s\n' "$current_crontab" | grep -Fv -- "$value" > "$temp_file" || { status=$? if [[ $status -ne 1 ]]; then log_error "Failed to filter crontab" rm -f "$temp_file" exit 1 fi } ``` Also: - Show all matching entries before removal. - Require confirmation when multiple entries match. - Clearly document whether patterns are literal strings or regular expressions. - If regex support is intentional, still use `grep -v -- "$value"` and validate potentially dangerous or unexpectedly broad expressions. - Confirm that at least one intended entry matched before installing the replacement crontab. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (35)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The skill is described as a cron job manager, but it also advertises starting, stopping, and checking the cron service via launchctl/systemctl, which expands its capability into privileged system administration. That mismatch matters because users or orchestrators may invoke it expecting per-user crontab management, while the skill can influence system task scheduling availability and may trigger sudo-backed operations.

Missing User Warnings

High
Confidence
95% confidence
Finding
Job removal performs destructive modification of the user's crontab with no confirmation or preview, and the pattern-removal mode can delete multiple entries at once. This can cause loss of legitimate scheduled tasks or be abused to disable backups, monitoring, or other defenses that rely on cron.

Chaining Abuse

High
Category
Tool Misuse
Content
linux)
            case "$action" in
                start)
                    sudo systemctl start cron 2>/dev/null || sudo systemctl start crond 2>/dev/null || \
                    log_error "Failed to start cron service"
                    ;;
                stop)
Confidence
75% confidence
Finding
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Chaining Abuse

High
Category
Tool Misuse
Content
linux)
            case "$action" in
                start)
                    sudo systemctl start cron 2>/dev/null || sudo systemctl start crond 2>/dev/null || \
                    log_error "Failed to start cron service"
                    ;;
                stop)
Confidence
75% confidence
Finding
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Chaining Abuse

High
Category
Tool Misuse
Content
linux)
            case "$action" in
                start)
                    sudo systemctl start cron 2>/dev/null || sudo systemctl start crond 2>/dev/null || \
                    log_error "Failed to start cron service"
                    ;;
                stop)
Confidence
75% confidence
Finding
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Session Persistence

Medium
Category
Rogue Agent
Content
Then use: `cron-helper.sh <command>`

### Option 3: Create an alias
```bash
alias cron='~/.openclaw/workspace/skills/cron-scheduler/scripts/cron-helper.sh'
```
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
This markdown file documents commands that add, remove, edit, backup, and restore crontab entries, which can directly change system task scheduling and potentially overwrite existing cron configuration. The README presents these operations as ordinary commands but does not include any caution about their impact on user data, system behavior, or the risk of replacing the current crontab during restore.

Session Persistence

Medium
Category
Rogue Agent
Content
---
name: cron-scheduler
description: Manage cron jobs on macOS/Linux - list, add, remove, backup, and schedule recurring tasks
triggers:
  - "cron"
  - "cron job"
Confidence
88% confidence
Finding
The skill's core purpose is to create recurring tasks, which is a persistence mechanism: commands added to crontab will execute automatically in future sessions without further user interaction. In a security context, any agent capability that can establish scheduled execution materially increases abuse potential if invoked by mistake or under prompt injection.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger phrase "cron" is extremely broad and likely to appear in normal discussion, documentation, or troubleshooting contexts without the user intending to execute this skill. In agent environments, such ambiguous activation increases the risk of accidental invocation of commands that modify persistent scheduled tasks.

Vague Triggers

Medium
Confidence
94% confidence
Finding
Phrases like "schedule task" and "recurring task" are common natural-language expressions and are not specific to cron administration. This creates a collision risk where the skill may activate in unrelated contexts, potentially causing unintended persistence changes or confusing the agent's tool selection.

Session Persistence

Medium
Category
Rogue Agent
Content
## Features

1. **List Jobs** - View all cron jobs for the current user
2. **Add Job** - Create new cron jobs with schedule validation
3. **Remove Job** - Delete jobs by line number or pattern
4. **Edit Crontab** - Open crontab in your default editor
5. **Next Runs** - See when each job will execute next
Confidence
86% confidence
Finding
The feature "Create new cron jobs" confirms that the skill can establish persistent execution on the host. Even though this is expected for a cron management tool, it remains security-relevant because persistence is a common post-compromise technique and can survive beyond the current agent session.

Session Persistence

Medium
Category
Rogue Agent
Content
}

check_crontab() {
    if ! command -v crontab &> /dev/null; then
        log_error "crontab command not found. Please install cron."
        exit 1
    fi
Confidence
85% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
check_crontab
    
    local crontab_output
    crontab_output=$(crontab -l 2>/dev/null) || true
    
    if [[ -z "$crontab_output" ]]; then
        log_warn "No cron jobs found for user $(whoami)"
Confidence
85% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
check_crontab
    
    local crontab_output
    crontab_output=$(crontab -l 2>/dev/null) || true
    
    if [[ -z "$crontab_output" ]]; then
        log_warn "No cron jobs found for user $(whoami)"
Confidence
85% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
check_crontab
    
    local crontab_output
    crontab_output=$(crontab -l 2>/dev/null) || true
    
    if [[ -z "$crontab_output" ]]; then
        log_warn "No cron jobs found for user $(whoami)"
Confidence
85% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
Adding a cron job writes persistence into the user's crontab immediately after minimal validation and without an approval prompt. In an agent setting, this can create unintended recurring execution of attacker-influenced commands, making the skill more dangerous than a simple one-shot shell helper.

Session Persistence

Medium
Category
Rogue Agent
Content
local temp_file
    temp_file=$(mktemp)
    
    # Preserve existing crontab
    crontab -l 2>/dev/null >> "$temp_file" || true
    
    # Add new job
Confidence
93% confidence
Finding
This code preserves the current crontab in a temp file as part of a workflow that appends and installs a new cron entry, thereby enabling recurring execution. In the context of an agent skill, cron creation is inherently persistence-establishing and deserves elevated scrutiny even if it is nominally intended functionality.

Session Persistence

Medium
Category
Rogue Agent
Content
temp_file=$(mktemp)
    
    # Get current crontab
    local current_crontab
    current_crontab=$(crontab -l 2>/dev/null) || true
    
    if [[ -z "$current_crontab" ]]; then
Confidence
85% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
edit_crontab() {
    check_crontab
    crontab -e
    log_success "Crontab editor closed"
}
Confidence
85% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Description-Behavior Mismatch

Medium
Confidence
96% confidence
Finding
The skill's stated purpose is managing user cron jobs, but it also includes functionality to start, stop, and inspect the system cron service via sudo. This expands scope into privileged service administration, which can affect system-wide scheduling behavior and surprise users with elevation prompts or operational changes beyond the expected task.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
Starting or stopping the cron service changes system behavior and may require privilege escalation, yet the script provides no explicit warning or confirmation before attempting it. In an agent context, this creates risk of unintended service disruption or privilege-prompt abuse from a seemingly routine scheduling request.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
macos)
            case "$action" in
                start)
                    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.cron.plist 2>/dev/null || \
                    log_error "Need sudo to start cron"
                    ;;
                stop)
Confidence
91% confidence
Finding
This line attempts to run launchctl with sudo to load the cron LaunchDaemon, introducing privileged execution into a skill whose main purpose is user cron management. Even if not directly exploitable for code injection here, unnecessary elevation in an agent-integrated tool increases abuse potential and user surprise.

Session Persistence

Medium
Category
Rogue Agent
Content
macos)
            case "$action" in
                start)
                    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.cron.plist 2>/dev/null || \
                    log_error "Need sudo to start cron"
                    ;;
                stop)
Confidence
90% confidence
Finding
Loading the cron LaunchDaemon enables or restores a system scheduling service, which can facilitate persistence for scheduled tasks at the host level. In this skill context, that capability is more dangerous because it crosses from user cron management into system-wide persistence infrastructure control.

Session Persistence

Medium
Category
Rogue Agent
Content
macos)
            case "$action" in
                start)
                    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.cron.plist 2>/dev/null || \
                    log_error "Need sudo to start cron"
                    ;;
                stop)
Confidence
90% confidence
Finding
Loading the cron LaunchDaemon enables or restores a system scheduling service, which can facilitate persistence for scheduled tasks at the host level. In this skill context, that capability is more dangerous because it crosses from user cron management into system-wide persistence infrastructure control.

Context-Inappropriate Capability

Medium
Confidence
97% confidence
Finding
These lines implement privileged launchctl/systemctl operations that are not necessary for ordinary per-user crontab management. In the context of an agent skill, unjustified administrative capability increases attack surface and the chance of misuse, especially if invoked indirectly by natural-language triggers about cron jobs.

Static analysis

No suspicious patterns detected.