Back to skill

Security audit

Option Calculator

Security checks for vulnerabilities and agentic risk

Overview

This options calculator is mostly purpose-aligned, but its script unsafely turns user-supplied numeric arguments into executable Python code, creating a real command-execution risk.

Review before installing. Use this only with trusted inputs until the Python heredoc interpolation is fixed, because crafted calculator arguments can execute commands as your user account. Also be aware that price commands are logged under $HOME/.option-calculator/history.log unless you redirect the data directory.

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:90
Finding

Arbitrary Command Execution Through Unsafe Python Heredoc Interpolation

Content
View full analysis

Vulnerability Details

File Location: scripts/script.sh, lines 90–97. The same unsafe pattern is repeated at lines 139–144, 225–231, 263–266, 318–322, 365–367, 410–413, and 433–435.
Vulnerability Type: Python code injection leading to arbitrary operating-system command execution
Risk Level: High

Vulnerable Code

bash
python3 << PYEOF
import math

# ...

opt_type = "${opt_type}"
S = float(${spot})
K = float(${strike})
r = float(${rate})
sigma = float(${vol})
days = float(${days})
T = days / 365.0

Equivalent direct interpolation occurs in the other calculator functions:

bash
target = float(${market_price})
premium = float(${premium})
rng = int(${range})
entry = float(${entry})
current = float(${current})
qty = float(${qty})

Technical Analysis

The script inserts user-controlled command-line arguments directly into executable Python source generated through an unquoted heredoc. Although option types are validated, numeric arguments are not parsed or validated by Bash before being embedded.

Expressions passed to Python's float() or int() are evaluated as Python code before conversion. Consequently, an argument does not need to be a numeric literal; it can be an arbitrary Python expression that performs a side effect and then returns a number.

For example, a crafted spot-price argument could take the following form:

text
__import__('os').system('id') or 100

This produces Python source equivalent to:

python
S = float(__import__('os').system('id') or 100)

Python executes os.system('id') before evaluating the or 100 fallback and converting the result. Any command available to the invoking user can therefore be executed.

The vulnerability affects all calculation commands that interpolate numeric input into inline Python: price, greeks, iv, payoff, compare, chain, pnl, and breakeven.

Attack Path

...[truncated 1779 chars]

Remediation
View remediation

Remediation Suggestions

Do not construct Python source by interpolating command-line arguments. Pass all values as data through Python positional arguments and use a single-quoted heredoc delimiter:

bash
bs_price() {
    local opt_type="$1" spot="$2" strike="$3" rate="$4" vol="$5" days="$6"

    python3 - "$opt_type" "$spot" "$strike" "$rate" "$vol" "$days" <<'PYEOF'
import math
import sys

opt_type = sys.argv[1]

try:
    S = float(sys.argv[2])
    K = float(sys.argv[3])
    r = float(sys.argv[4])
    sigma = float(sys.argv[5])
    days = float(sys.argv[6])
except ValueError:
    raise SystemExit("ERROR: all numeric arguments must be valid numbers")

if opt_type not in {"call", "put"}:
    raise SystemExit("ERROR: option type must be call or put")

if not all(math.isfinite(value) for value in (S, K, r, sigma, days)):
    raise SystemExit("ERROR: numeric arguments must be finite")

if S <= 0 or K <= 0:
    raise SystemExit("ERROR: spot and strike must be positive")
if sigma <= 0 or days <= 0:
    raise SystemExit("ERROR: volatility and days must be positive")

T = days / 365.0
# Continue calculation using the parsed values.
PYEOF
}

Apply the same design to every affected function:

  1. Use python3 - "$arg1" "$arg2" ... to transport values as arguments.
  2. Use <<'PYEOF' so Bash performs no interpolation within Python source.
  3. Parse values exclusively from sys.argv.
  4. Reject invalid, infinite, and NaN values with math.isfinite().
  5. Enforce domain constraints such as positive spot, strike, volatility, expiration, and sensible payoff ranges.
  6. Validate both minimum and maximum argument counts to prevent ambiguous input.
  7. Add regression tests using Python expressions and shell metacharacters as inputs, verifying that they are rejected and never executed.
Vulnerability Patterns
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • 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
Findings (4)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill’s declared purpose does not accurately match its documented behavior, most notably by persisting pricing history to local storage and advertising capabilities that are not actually implemented as described. This is dangerous because users and upstream agents may rely on the metadata and description for trust and authorization decisions, causing unexpected data retention and misuse of the tool under false assumptions.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The stated purpose includes visualizing profit-loss curves and exercise analysis, but the code implements a payoff table, P/L calculator, and breakeven text output only. There is no graph generation, charting, or actual plotting logic, so the manifest overstates the implemented behavior.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script appends user-supplied option parameters and computed prices to a persistent file in the user's home directory, even though the advertised functionality is just calculation. This creates an unexpected data-retention behavior that can expose sensitive trading ideas or financial inputs to other local users, backups, or later compromise of the host.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

Writing user-provided financial inputs and results to a persistent history log without notice is an information-handling weakness. In this skill's context, users may reasonably expect ephemeral local computation, so silent logging increases privacy risk and could leak proprietary or sensitive trading data through local file access or backups.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.