Back to skill

Security audit

Self Improving Habit

Security checks for vulnerabilities and agentic risk

Overview

This habit-coaching skill is mostly purpose-aligned, but its included tracker script can write outside the intended habit folder and the logging guidance under-discloses privacy risk.

Review before installing. Normal habit-coaching use appears coherent, but avoid putting sensitive health, mental-health, location, or routine details into persistent logs unless you are comfortable storing them locally. Do not use the included tracker script with habit names containing slashes, dots, path-like text, or names provided by untrusted content until the path handling is fixed.

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/habit-tracker.sh:13
Finding
Path Traversal Enables Arbitrary File Creation and Modification## Vulnerability Details **File Location**: `scripts/habit-tracker.sh`, lines 13–47 **Vulnerability Type**: Path traversal and unsafe file handling **Risk Level**: High ### Vulnerable Code ```bash HABIT_NAME="$1" STATUS="${2:-check}" HABIT_FILE=".learnings/habits/${HABIT_NAME}.md" DATE=$(date +%Y-%m-%d) # 创建习惯文件(如果不存在) if [ ! -f "$HABIT_FILE" ]; then mkdir -p "$(dirname "$HABIT_FILE")" cat > "$HABIT_FILE" << EOF # 习惯追踪: $HABIT_NAME **开始日期**: $(date +%Y-%m-%d) **目标频率**: [填写] **当前阶段**: 启动期 ## 每日记录 EOF echo "✅ 创建新习惯文件: $HABIT_FILE" echo "📝 请编辑文件填写习惯详细信息" fi ``` The completion branch subsequently appends data to the same attacker-controlled path: ```bash case $STATUS in "yes"|"y"|"完成") # 记录完成 if grep -q "### $DATE" "$HABIT_FILE"; then echo "⚠️ 今天已经记录过此习惯" else cat >> "$HABIT_FILE" << EOF ### $DATE ✅ - **完成时间**: $(date +%H:%M) - **质量评分**: [1-10] - **备注**: [填写] EOF ``` ### Technical Analysis The first command-line argument is accepted as `HABIT_NAME` and inserted directly into `HABIT_FILE`. The script does not reject path separators, `..` components, absolute-path-like input, or symbolic-link destinations. Shell quoting prevents word splitting and shell command injection, but it does not prevent filesystem path traversal. A value such as `../../../../tmp/target` produces a path similar to: ```text .learnings/habits/../../../../tmp/target.md ``` Filesystem path normalization resolves the `..` components outside the intended `.learnings/habits` directory. The `mkdir -p`, `cat >`, `cat >>`, and `grep` operations then act on the escaped destination. If the destination is not recognized as an existing regular file, the initialization branch uses `cat >`, creating the file or truncating the resolved destination. If it exists, the status branches may append habit records using `cat >>`. S ...[truncated 1816 chars]
Remediation
## Remediation Suggestions 1. **Apply strict allowlist validation to habit names.** Accept only a limited identifier format and reject all other input: ```bash HABIT_NAME="$1" if [[ ! "$HABIT_NAME" =~ ^[A-Za-z0-9_-]+$ ]]; then printf '%s\n' "Error: habit names may contain only letters, numbers, underscores, and hyphens." >&2 exit 1 fi ``` 2. **Use a fixed, canonical base directory.** Resolve the storage directory before constructing the destination and verify that the canonical destination remains inside it. ```bash BASE_DIR="$(pwd -P)/.learnings/habits" mkdir -p -- "$BASE_DIR" HABIT_FILE="$BASE_DIR/${HABIT_NAME}.md" ``` 3. **Reject symbolic-link destinations.** ```bash if [ -L "$HABIT_FILE" ]; then printf '%s\n' "Error: symbolic-link habit files are not allowed." >&2 exit 1 fi ``` Where available, perform file creation through an API or utility that supports no-follow and exclusive-creation semantics to avoid check-to-use races. 4. **Avoid unintended truncation.** Create new files atomically and refuse to overwrite existing destinations. Ensure that append operations are performed only after validating that the destination is a regular file owned or otherwise trusted by the current user. 5. **Use defensive shell settings and argument handling.** ```bash set -euo pipefail mkdir -p -- "$BASE_DIR" ``` 6. **Add regression tests** covering `../`, embedded `/`, absolute paths, newlines, symbolic links, and names beginning with `-`. Each test should verify that no file outside the canonical habits directory is created or modified.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (6)

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The daily log template encourages ongoing collection of detailed behavioral and wellness data such as streaks, resistance, willpower, sleep, stress, and performance patterns without warning that this creates a persistent personal profile. In context, repeated structured logging increases sensitivity over time because it can reveal health state, routines, emotional patterns, and vulnerabilities, making accidental disclosure or secondary misuse more harmful than a one-off note.

Description-Behavior Mismatch

Medium
Confidence
97% confidence
Finding
The manifest description says only "Self-improving system for self-improving-habit," which does not reflect the stated purpose of science-based habit formation and behavioral psychology coaching. This mismatch can mislead users or routing systems about what the skill does, increasing the risk of inappropriate invocation, poor oversight, or hiding broader behavior behind a generic label.

Vague Triggers

Medium
Confidence
90% confidence
Finding
The description is too vague to establish a clear activation scope, making it difficult for users or orchestration systems to determine when this skill should or should not be used. Ambiguous scope can cause overbroad triggering, accidental invocation in unrelated contexts, and reduced ability to audit whether the skill is operating within expected boundaries.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
This shell script hard-codes Chinese for comments, usage instructions, status messages, and guidance, which effectively forces a specific language/locale on users. The file does not offer any opt-in, fallback, or documented justification for the language restriction.

Missing User Warnings

Low
Confidence
92% confidence
Finding
The skill directs users to persist habit definitions in local markdown files that can include behavioral routines, schedules, priorities, and identity statements, but provides no warning about storing sensitive personal data. While this is not overtly malicious, it creates unnecessary privacy risk because users may record intimate wellness or mental-health-adjacent information that remains on disk indefinitely and could be exposed through backups, syncing, or later agent access.

Natural-Language Policy Violations

Low
Confidence
88% confidence
Finding
This markdown template is primarily written in Chinese, but several required field labels and enumerated values are fixed in English, such as "Habit Definition," stage names, priority values, and status values. Because the file does not indicate that users may choose their preferred language or locale, it can be read as enforcing a language convention without opt-in.

Static analysis

No suspicious patterns detected.