Back to skill

Security audit

Bytesagain Coffee

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a coffee guide, but its included ratio script can run unintended shell commands from a crafted cup value, so it needs review before installation.

Review or fix the ratio script before installing or invoking it with any user-supplied cup count. The documentation content itself is ordinary coffee guidance, but the shell helper should validate numeric input before doing arithmetic.

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/script.sh:20
Finding

Arbitrary Command Execution Through Bash Arithmetic Injection

Content
View full analysis
/dev/null || echo "$((ml / 15))") echo "⚖️ For $cups cups ($ml ml): Use ${grams}g of coffee (1:15 ratio)." } ``` ### Technical Analysis The `ratio` command accepts its first positional argument as the untrusted `cups` value. This value is used in Bash arithmetic expansion at line 22 without first verifying that it contains only a valid, bounded decimal integer: ```bash local ml=$((cups * 240)) ``` Bash recursively evaluates variable values used in arithmetic contexts as arithmetic expressions. Crafted arithmetic expressions can contain array references whose subscripts undergo shell expansion, including command substitution. Consequently, an argument that appears where a number is expected can cause an embedded command to execute. The later fallback arithmetic expansion on line 23 also operates on a derived arithmetic value, but execution can already occur when `ml` is assigned. The presence or absence of `bc` therefore does not prevent exploitation. ### Attack Path 1. An attacker causes the Skill or a user to invoke the script's `ratio` command with an attacker-controlled argument. 2. The argument is stored unchanged in the local `cups` variable. 3. Line 22 evaluates `cups` as Bash arithmetic syntax. 4. A crafted array-subscript expression triggers command substitution during arithmetic evaluation. 5. The embedded command executes with the operating-system identity and environment of the process running the Skill. For example, an invocation shaped as follows can create a file as proof of command execution: ```bash ./scripts/script.sh ratio 'x[$(touch /tmp/coffee-audit-poc)0]' ``` The attack does not require `bc`, network access, or an ...[truncated 785 chars]
Remediation
View remediation
&2 return 1 fi if (( ${#cups} > 4 )) || (( 10#$cups > 1000 )); then printf '%s\n' "Error: cups must not exceed 1000." >&2 return 1 fi local ml=$((10#$cups * 240)) local grams if command -v bc >/dev/null 2>&1; then grams=$(printf 'scale=1; %d / 15\n' "$ml" | bc) else grams=$((ml / 15)) fi printf 'For %d cups (%d ml): Use %sg of coffee (1:15 ratio).\n' \ "$cups" "$ml" "$grams" } ``` Additional hardening measures: 1. Apply strict allowlist validation before every use of user input in an arithmetic expression. 2. Impose practical upper bounds to prevent integer overflow and resource misuse. 3. Use `10#` only after validation to force decimal interpretation and avoid leading-zero octal behavior. 4. Prefer `printf` over interpolated `echo` for predictable output handling. 5. Add regression tests using malformed inputs, arithmetic expressions, array-syntax payloads, command substitutions, negative values, leading zeros, and excessively large integers. 6. Consider enabling `set -euo pipefail` after ensuring expected command failures are handled explicitly. ]]>
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
Findings (1)

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The description and headings present bilingual Chinese content as a built-in requirement, including explicit Chinese support language, without stating that language choice is optional or user-selected. This can violate language/locale policy expectations when a skill implicitly enforces a specific locale rather than offering a choice.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.