Back to skill

Security audit

Session Cost Tracker

Security checks for vulnerabilities and agentic risk

Overview

The artifact is coherent as a local session cost tracker, but the bundled shell script contains unsafe Python fallback paths that can execute injected commands under the user's account.

Review or fix track.sh before installing. At minimum, keep jq installed, do not log untrusted text, and do not let untrusted code set SESSION_COST_FILE; a proper fix should pass data and paths to Python as arguments or stdin instead of interpolating them into source code.

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
track.sh:61
Finding

Arbitrary Python Code Execution Through Unescaped Session Fields

Content
View full analysis
/dev/null || echo "sess-$(date +%s)")", "timestamp": "$timestamp", "date": "$date_only", "task": "$task", "outcome": "$outcome", "value": "$value", "tokens": $tokens, "model": "$model", "cost_usd": $cost, "notes": "$notes" } EOF ) # Append to JSON array using jq if available, else python if command -v jq &> /dev/null; then jq --argjson entry "$entry" '.sessions += [$entry]' "$DATA_FILE" > "${DATA_FILE}.tmp" && mv "${DATA_FILE}.tmp" "$DATA_FILE" else python3 -c " import json, sys entry = json.loads('''$entry''') with open('$DATA_FILE', 'r') as f: data = json.load(f) data['sessions'].append(entry) with open('$DATA_FILE', 'w') as f: json.dump(data, f, indent=2) " fi ``` ### Technical Analysis The `task`, `outcome`, `value`, `model`, and `notes` command-line values are inserted directly into a JSON-like heredoc without JSON escaping. When `jq` is unavailable, the complete `entry` value is subsequently interpolated into the source code passed to `python3 -c`: ```python entry = json.loads('''$entry''') ``` Because the generated Python program uses a triple-single-quoted literal, an input containing `'''` can terminate that literal and introduce a Python expression. For example, a field containing an expression shaped like the following can cause a command to run while Python evaluates the argument supplied to `json.loads`: ```text ''' + str(__import__("os").system("id")) + ''' ``` The eventual JSON parse may fail, but the injected expression is evaluated first. Consequently, command execution can occur before the parsing error terminates the script. Even without a deliberately malicious payload, ordinary values containing double quotes, backslashes, ...[truncated 1407 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
track.sh:174
Finding

Arbitrary Python Code Execution Through SESSION_COST_FILE

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep

Static analysis

No suspicious patterns detected.