Back to skill

Security audit

Sync Notes

Security checks for vulnerabilities and agentic risk

Overview

The skill's notes-sync purpose is clear, but it needs review because its shell configuration handling can turn crafted setup/config values into commands during sync.

Review before installing. This skill can change or delete notes on both local and remote storage and stores R2/rclone secrets locally. The main issue to fix is replacing sourced .env shell config with safely parsed data, validating setup inputs, and removing or allowlisting extra rclone flags. Use status and dry-run first, and keep an independent backup of the vault.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/setup.sh:100
Finding
Arbitrary Command Execution and rclone Option Injection Through Unsafe Configuration Handling<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup.sh:64`, `scripts/setup.sh:100-104`, `scripts/sync.sh:39-45`, and `scripts/sync.sh:67-68` **Vulnerability Type**: Shell command injection and command-line option injection **Risk Level**: High ### Vulnerable Code `scripts/setup.sh:64` accepts unrestricted extra command-line flags: ```bash prompt EXTRA_FLAGS "Extra rclone flags" "--transfers=4 --checkers=8" ``` `scripts/setup.sh:100-104` writes user-controlled values directly into an executable shell configuration file without escaping or validation: ```bash cat > "$ENV_FILE" <<EOF RCLONE_REMOTE=${RCLONE_REMOTE} BACKUP_KEEP=${BACKUP_KEEP} RCLONE_EXTRA_FLAGS="${EXTRA_FLAGS}" EOF chmod 600 "$ENV_FILE" ``` `scripts/sync.sh:39-45` executes the generated configuration as shell code: ```bash load_env() { [[ -f "$ENV_FILE" ]] || die "config missing — run: $0 setup" # shellcheck disable=SC1090 set -a; source "$ENV_FILE"; set +a : "${RCLONE_REMOTE:?RCLONE_REMOTE not set in $ENV_FILE}" : "${BACKUP_KEEP:=1}" : "${RCLONE_EXTRA_FLAGS:=}" } ``` `scripts/sync.sh:67-68` additionally expands the configured flags as an unquoted scalar: ```bash [[ -f "$FILTER_FILE" ]] && filter_args=(--filter-from "$FILTER_FILE") rclone --config "$RCLONE_CONFIG_FILE" "${filter_args[@]}" $RCLONE_EXTRA_FLAGS "$@" ``` ### Technical Analysis The setup wizard treats interactive values as data, but serializes them directly into `config/.env`, which is subsequently loaded with Bash `source`. A sourced file is executable shell code rather than a passive configuration format. Values such as `RCLONE_REMOTE`, `BACKUP_KEEP`, and `EXTRA_FLAGS` are not restricted or shell-escaped before being written. Newlines, quotation marks, command substitutions, or other shell syntax can therefore alter the structure of the generated file and introduce commands that execute when `load_env` sources it. For example, a malicious value containing a newline can terminate an assignme ...[truncated 2473 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Do not source configuration files** - Replace the executable `.env` format with a passive format such as JSON, TOML, or a strictly parsed key-value file. - Parse only recognized keys and never evaluate configuration content as shell code. 2. **Apply strict input validation** - Restrict `RCLONE_REMOTE` to a conservative pattern such as `^[A-Za-z0-9_-]+$`. - Require `BACKUP_KEEP` to contain only an integer within an appropriate range. - Reject newline, carriage-return, NUL, and other control characters in every configuration value. - Validate endpoint, bucket, prefix, and crypt-mode fields according to their expected formats. 3. **Eliminate unrestricted extra flags** - Prefer explicit configuration prompts for supported settings such as transfer and checker counts. - If extra flags remain necessary, enforce an allowlist of safe rclone options and reject options capable of changing configuration, remote access, filtering, logging, command execution, or filesystem scope. 4. **Use array-safe argument construction** - Store approved options as separate array elements. - Invoke rclone using quoted array expansion: ```bash local extra_flags=( "--transfers=$TRANSFERS" "--checkers=$CHECKERS" ) rclone \ --config "$RCLONE_CONFIG_FILE" \ "${filter_args[@]}" \ "${extra_flags[@]}" \ "$@" ``` 5. **Protect fixed security arguments** - Reject user-provided options such as `--config`, `--filter`, `--filter-from`, `--include`, `--exclude`, `--log-file`, or other flags that can override security-sensitive arguments. - Construct mandatory arguments after validating all optional settings, while avoiding reliance solely on argument ordering. 6. **Write configuration atomically** - Create configuration files in a securely permissioned temporary file inside `config/`. - Validate the completed file, apply mode `600`, and atomically rename it into place. - Continue using `umask 077` to pr ...[truncated 335 chars]
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (20)

Credential Access

High
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
SKILL_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
CONFIG_DIR="$SKILL_DIR/config"
RCLONE_CONFIG_FILE="$CONFIG_DIR/rclone.conf"
ENV_FILE="$CONFIG_DIR/.env"

command -v rclone >/dev/null 2>&1 || { echo "rclone is required" >&2; exit 1; }
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
SKILL_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
CONFIG_DIR="$SKILL_DIR/config"
RCLONE_CONFIG_FILE="$CONFIG_DIR/rclone.conf"
ENV_FILE="$CONFIG_DIR/.env"

command -v rclone >/dev/null 2>&1 || { echo "rclone is required" >&2; exit 1; }
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
clean_failed_baseline() {
  # Wipe partial bisync state so --resync can start clean.
  rm -f "$BISYNC_WORKDIR"/*.lst-new "$BISYNC_WORKDIR"/*.lst-err 2>/dev/null || true
}

scan_conflicts() {
Confidence
95% confidence
Finding
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Lp3

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding
The skill explicitly orchestrates shell execution via bash/rclone but declares no tool scope restrictions such as allowed tools or permissions. In an agent environment, this broadens the execution surface and can allow unintended shell access or make policy enforcement ambiguous, especially for a skill that performs filesystem and remote sync operations.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The user-facing description does not prominently warn that bidirectional sync and copy operations can overwrite files or propagate deletions/conflicts between local and remote storage. This creates a real safety risk of unintended data loss because users may trigger destructive synchronization without informed consent.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
#!/usr/bin/env bash
# Interactive configuration wizard for the sync-notes skill.
# Writes config/rclone.conf and config/.env (chmod 600).

set -euo pipefail
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Natural-Language Policy Violations

Low
Confidence
76% confidence
Finding
The trigger examples and parsing rules embed Chinese-specific commands such as `下载`, `拉`, `上传`, and `试`, which indicates locale-specific behavior. The file does not explicitly state that multiple languages are supported by choice or that Chinese parsing is optional, so it risks imposing undocumented language handling policy.

Static analysis

No suspicious patterns detected.