T09 · Insecure Skill Coding Practices
- Location
scripts/cron_manager.py:281- Finding
Unrestricted Stored Shell Command Execution
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a cron task manager, but it stores and runs arbitrary shell commands with weak scoping and file-path validation.
Review this skill carefully before installing. Only use it in a low-privilege, trusted workspace, do not allow untrusted users or agents to create tasks, avoid sensitive environment variables, and treat every saved task command as code that may execute on the host.
scripts/cron_manager.py:281Unrestricted Stored Shell Command Execution
scripts/cron_manager.py:136Path Traversal Through Unvalidated Task IDs
Referenced artifact was not completely inspected
Run from the `scripts/cron_manager.py` script with these actions:
This is a clear tool-parameter abuse risk: task['command'] is attacker-influenced input executed by the shell. Because the skill is specifically designed to manage recurring tasks for autonomous agents, the context makes this more dangerous than a normal admin-only cron wrapper; it can become a convenient persistence and remote-execution mechanism if task creation or task-file modification is exposed.
# Execute the command
start = datetime.now(pytz.UTC)
try:
result = subprocess.run(task['command'], shell=True, capture_output=True, text=True, timeout=300)
success = result.returncode == 0
output = result.stdout[-1000:] if result.stdout else ''
error = result.stderr[-1000:] if result.stderr else ''
The markdown advertises cron remove <task_id> — Delete a task but provides no warning that the action is destructive or irreversible, and no mention of confirmation requirements. For a skill that manages scheduled tasks, deleting a task can affect system behavior and user data continuity, so the description should explicitly disclose that risk.
TASKS_FILE is derived from CRON_DATA_DIR, an environment-controlled path, and is opened for writing without validation. If this script runs with elevated privileges or in a shared environment, an attacker controlling the environment could redirect writes to unintended files or sensitive locations via path manipulation or symlink abuse.
def save_tasks(tasks: list):
"""Save tasks to JSON file."""
with open(TASKS_FILE, 'w') as f:
json.dump(tasks, f, indent=2)
The log file path is influenced by LOGS_DIR (derived from environment-controlled DATA_DIR) and task_id, then opened for append without path or symlink validation. An attacker who controls the environment or task identifier format could cause log writes to unintended filesystem locations, especially if the process has broader write permissions.
def add_log_entry(task_id: str, entry: dict):
"""Add a log entry for task execution."""
log_file = os.path.join(LOGS_DIR, f"{task_id}.jsonl")
with open(log_file, 'a') as f:
f.write(json.dumps(entry) + '\n')
The remove command rewrites the tasks file and deletes the associated log file, which is an irreversible data-destructive operation. Although the module docstring lists a remove action, there is no confirmation prompt, explicit warning, or user-facing disclosure at the point of deletion.
Immediate command execution without any warning or confirmation is dangerous here because the implementation runs stored commands directly on the host system. In agent-integrated tooling, this lowers the barrier for accidental or manipulated execution of destructive commands and amplifies the risk posed by the shell-based command runner.
The code executes task['command'] with shell=True, which allows arbitrary shell command execution from task definitions stored in JSON or added via the CLI. In an agent skill context, this is especially dangerous because untrusted users or upstream agent workflows may be able to register or modify tasks, turning the feature into unrestricted OS command execution.
# Execute the command
start = datetime.now(pytz.UTC)
try:
result = subprocess.run(task['command'], shell=True, capture_output=True, text=True, timeout=300)
success = result.returncode == 0
output = result.stdout[-1000:] if result.stdout else ''
error = result.stderr[-1000:] if result.stderr else ''
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
stale_count = 0
# Check disk space
disk_usage = subprocess.run(['df', '-h', DATA_DIR], capture_output=True, text=True)
health_issues = []
if failed_tasks:
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
stale_count = 0
# Check disk space
disk_usage = subprocess.run(['df', '-h', DATA_DIR], capture_output=True, text=True)
health_issues = []
if failed_tasks:
The inline comment says the code will check for stale logs, but the implementation only initializes stale_threshold and stale_count and never inspects any log files or uses those values in the result. This is an intent-code divergence because the comment describes a diagnostic capability the function does not actually perform.
No suspicious patterns detected.