Back to skill

Security audit

Cron Backup

Security checks for vulnerabilities and agentic risk

Overview

This backup skill is mostly purpose-aligned, but it uses unsafe shell and cron construction that can turn user-supplied paths or version commands into persistent command execution.

Review before installing. Use only trusted, simple paths and version sources, do not run these scripts as root, and avoid scheduling jobs until eval-based version checks and unquoted crontab construction are fixed. Be aware that cleanup permanently deletes matching backup archives according to retention settings.

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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/backup-versioned.sh:24
Finding

Arbitrary Command Execution Through an Untrusted Version Source

Content
View full analysis
/dev/null || echo "unknown") elif command -v "$VERSION_SOURCE" &> /dev/null; then # Version from command CURRENT_VERSION=$($VERSION_SOURCE 2>/dev/null || echo "unknown") else # Try as command string CURRENT_VERSION=$(eval "$VERSION_SOURCE" 2>/dev/null || echo "unknown") fi ``` ### Technical Analysis `VERSION_SOURCE` is supplied directly by the caller. If it is not recognized as a regular file or executable name, the script passes it to `eval`. The shell consequently reparses the entire value as shell syntax. An attacker who can influence this argument can include command separators, command substitutions, pipelines, redirections, or other shell constructs. These constructs execute with the privileges of the user running the script. The preceding command-execution branch is also unsafe because it expands a string as a command rather than handling a validated executable and arguments as a structured array. Although the documentation intentionally supports obtaining a version from command output, supporting this feature does not require `eval`. The implementation unnecessarily converts a data parameter into unrestricted shell code. ### Attack Path 1. A user, automation system, or wrapper invokes `backup-versioned.sh` with an attacker-controlled version-source argument. 2. The supplied value does not identify a regular file and is not accepted by `command -v`. 3. Execution reaches `eval "$VERSION_SOURCE"`. 4. The shell interprets embedded shell syntax instead of treating the value as data. 5. The injected commands execute under the account that launched the backup script. 6. If the vulnerable invocation is placed in cro ...[truncated 657 chars]
Remediation
View remediation
/dev/null) || { echo "Error: version command failed" >&2 exit 1 } ``` 6. Do not silently convert command failures to the string `unknown`, because this can cause misleading version transitions and unintended backups. 7. Document that command-based version sources must come only from trusted configuration. 8. Run scheduled backups under a dedicated, minimally privileged account with read access only to required source data and write access only to the intended backup directory. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/setup-cron.sh:35
Finding

Persistent Command Injection Through Unsafe Crontab Entry Construction

Content
View full analysis
> $BACKUP_DIR/.backup.log 2>&1 $CRON_TAG" echo "Setting up cron job..." echo " Type: $JOB_TYPE" echo " Schedule: $SCHEDULE" echo " Command: $CMD" # Check if job already exists if crontab -l 2>/dev/null | grep -q "$CRON_TAG"; then echo "Warning: A cron job with tag $CRON_TAG already exists" echo "Remove it first with: crontab -e" exit 1 fi # Add to crontab (crontab -l 2>/dev/null || echo "") | grep -v "$CRON_TAG" | { cat; echo "$CRON_ENTRY"; } | crontab - ``` ### Technical Analysis The script constructs executable crontab content by concatenating caller-controlled values into a single string. The following values are n ...[truncated 2581 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (13)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The code partially matches the description in that it tracks a version value and triggers a backup only when that version changes. However, the declared purpose emphasizes scheduled automated backups and automatic cleanup of old backups, neither of which is present in this code chunk. The script is a one-shot wrapper that compares current and previous version values, then calls another backup script if needed. Additionally, it can execute a supplied command string using eval to obtain the version, which is a meaningful undeclared capability beyond simple file monitoring/version tracking. Therefore the description overstates key features and omits a potentially sensitive behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared description presents a more comprehensive backup automation skill that schedules recurring backups, monitors version changes to trigger backups, and cleans up old backups. The supplied code only performs a single on-demand compressed backup of a directory with timestamped naming and exclusions. While timestamping loosely relates to versions, there is no actual version tracking, change detection, scheduler integration, or cleanup logic. Therefore the description materially overstates the implemented behavior.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The script treats the second argument as either a file path, a command name, or an arbitrary shell command string, and in the fallback path executes it with eval. If an attacker can influence VERSION_SOURCE, they can run arbitrary commands with the privileges of the backup job, which is especially dangerous because backup scripts are commonly run via cron or as privileged service accounts. In the context of a backup skill, executing arbitrary commands for version detection is broader than necessary and increases the attack surface.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill encourages backup and cleanup operations on user-supplied paths without clearly warning that it may process sensitive user data and later delete stored backups. In a backup skill, omission of destructive-data-handling warnings increases the risk of accidental data loss or unsafe use on sensitive directories, especially when users may automate the commands via cron.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The quick-start cleanup example presents deletion behavior as routine without warning that the command irreversibly removes backups according to retention parameters. In the context of an automation-focused backup skill, this is more dangerous because users are likely to copy-paste the cron setup and may unintentionally purge needed recovery points at scale.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

Using eval on a user-controlled argument causes the shell to parse and execute arbitrary content, including command substitution, separators, and redirections. This creates direct command injection risk, and if the script is scheduled or run with elevated privileges, exploitation can lead to arbitrary code execution, data exfiltration, or system compromise. The lack of any warning does not mitigate the issue; the core problem is unsafe execution behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The cleanup job invokes a separate cleanup script and describes it only as 'Cleanup old backups', but there is no explicit disclosure that this operation may permanently delete backup data based on retention days. Although the script prints the cron command being installed, it does not warn the user about the destructive effect of enabling this recurring cleanup task.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · scripts/setup-cron.sh (reported line 76)May include surrounding context.

sh
echo "  Command: $CMD"

# Check if job already exists
if crontab -l 2>/dev/null | grep -q "$CRON_TAG"; then
    echo "Warning: A cron job with tag $CRON_TAG already exists"
    echo "Remove it first with: crontab -e"
    exit 1

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · scripts/setup-cron.sh (reported line 87)May include surrounding context.

sh
echo "  Command: $CMD"

# Check if job already exists
if crontab -l 2>/dev/null | grep -q "$CRON_TAG"; then
    echo "Warning: A cron job with tag $CRON_TAG already exists"
    echo "Remove it first with: crontab -e"
    exit 1

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · scripts/setup-cron.sh (reported line 78)May include surrounding context.

sh
# Check if job already exists
if crontab -l 2>/dev/null | grep -q "$CRON_TAG"; then
    echo "Warning: A cron job with tag $CRON_TAG already exists"
    echo "Remove it first with: crontab -e"
    exit 1
fi

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · scripts/setup-cron.sh (reported line 88)May include surrounding context.

sh
# Check if job already exists
if crontab -l 2>/dev/null | grep -q "$CRON_TAG"; then
    echo "Warning: A cron job with tag $CRON_TAG already exists"
    echo "Remove it first with: crontab -e"
    exit 1
fi

Session Persistence

Medium
Category
Rogue Agent
Confidence
92% confidence
Finding

This line installs a persistent cron job using unsanitized user-controlled values in both the cron schedule and command string. Because SOURCE_DIR, BACKUP_DIR, EXTRA_ARGS, and SCHEDULE are interpolated directly into a crontab entry without escaping or validation, a crafted input containing shell metacharacters, newlines, or additional cron fields can inject arbitrary commands that will execute later under the crontab owner's privileges.

Content

Scanner excerpt · scripts/setup-cron.sh (reported line 82)May include surrounding context.

sh
exit 1
fi

# Add to crontab
(crontab -l 2>/dev/null || echo "") | grep -v "$CRON_TAG" | { cat; echo "$CRON_ENTRY"; } | crontab -

echo "✓ Cron job added successfully"

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

The script invokes a backup routine and then writes a version record file in the backup directory, both of which modify the filesystem. While the script name and status messages indicate backup behavior, the usage/help text does not explicitly disclose that files and directories will be created or updated under the provided backup path.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.