Back to skill

Security audit

Kelly Formula Crypto

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed paid Kelly-position calculator with no hidden persistence or host access, but users should be cautious about the x402 charge and unvalidated financial calculations.

Before installing, confirm you are comfortable with the disclosed 0.01 USDC x402 charge and destination wallet/API endpoint. Do not connect this calculator directly to automated trading without adding strict input validation, finite-number checks, leverage checks, and position caps.

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

Warning
Location
scripts/kelly_calculator.py:124
Finding
Missing Numeric Input Validation Causes Denial of Service and Unsafe Position Recommendations<![CDATA[ ## Vulnerability Details **File Location**: `scripts/kelly_calculator.py`, lines 16–35, 71–84, 124–140, 166–167, and 181–193 **Vulnerability Type**: Improper input validation and unsafe arithmetic **Risk Level**: Medium ### Vulnerable Code ```python def kelly_position(p: float, b: float, fraction: float = 0.5) -> float: """ Calculate Kelly position size. Args: p: Win probability (0-1) b: Win/Loss ratio (e.g., 2.0 means win 2x of what you lose) fraction: Kelly fraction (0.5 = half-Kelly, 0.25 = quarter-Kelly) Returns: Position size as percentage (0-1) """ if p <= 0.5 or b <= 0: return 0.0 f_star = (p * b - (1 - p)) / b if f_star < 0: return 0.0 return f_star * fraction ``` ```python def leverage_safety(liquidation_pct: float, stop_loss_pct: float) -> Tuple[bool, float]: """ Check if leverage is safe. Args: liquidation_pct: Distance to liquidation (e.g., 10 for 10%) stop_loss_pct: Stop loss distance (e.g., 3 for 3%) Returns: (is_safe, safety_factor) """ safety_factor = liquidation_pct / stop_loss_pct is_safe = safety_factor >= 2.0 return is_safe, safety_factor ``` ```python def calculate_trade(p: float, win_pct: float, loss_pct: float, fraction: float = 0.5, leverage: float = 1.0, liquidation_pct: Optional[float] = None, stop_loss_pct: Optional[float] = None) -> dict: """ Full trade calculation with all factors. """ b = win_pct / loss_pct # Basic Kelly full_kelly = kelly_position(p, b, 1.0) half_kelly = kelly_position(p, b, 0.5) quarter_kelly = kelly_position(p, b, 0.25) # Net edge method edge = net_edge(p, win_pct, loss_pct) suggested = suggested_position(edge, win_pct, fraction) ``` ```python # Leverage check if leverage > 1 and liquidation_pct and stop_loss_pct ...[truncated 4393 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Add centralized validation before performing any calculation: ```python import math def validate_inputs( p: float, win_pct: float, loss_pct: float, fraction: float, leverage: float, liquidation_pct: Optional[float], stop_loss_pct: Optional[float], ) -> None: values = { "probability": p, "win percentage": win_pct, "loss percentage": loss_pct, "fraction": fraction, "leverage": leverage, } for name, value in values.items(): if not math.isfinite(value): raise ValueError(f"{name} must be finite") if not 0 <= p <= 1: raise ValueError("probability must be between 0 and 1") if win_pct <= 0: raise ValueError("win percentage must be greater than zero") if loss_pct <= 0: raise ValueError("loss percentage must be greater than zero") if not 0 < fraction <= 1: raise ValueError("Kelly fraction must be greater than 0 and at most 1") if leverage < 1: raise ValueError("leverage must be at least 1") for name, value in ( ("liquidation distance", liquidation_pct), ("stop-loss distance", stop_loss_pct), ): if value is not None: if not math.isfinite(value) or value <= 0: raise ValueError(f"{name} must be finite and greater than zero") ``` 2. Invoke validation at the start of `calculate_trade()` before calculating the win/loss ratio. 3. Replace the leverage truthiness check with explicit presence checks: ```python if leverage > 1: if liquidation_pct is None or stop_loss_pct is None: raise ValueError( "liquidation and stop-loss distances are required when leverage is greater than 1" ) is_safe, safety_factor = leverage_safety( liquidation_pct, st ...[truncated 635 chars]
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • 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 (7)

External Transmission

Medium
Category
Data Exfiltration
Content
```bash
# 支付示例
curl -X POST https://api.x402.dev/pay \
  -H "Content-Type: application/json" \
  -d '{
    "to": "0x24b288c98421d7b447c2d6a6442538d01c5fce22",
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
```bash
# 支付示例
curl -X POST https://api.x402.dev/pay \
  -H "Content-Type: application/json" \
  -d '{
    "to": "0x24b288c98421d7b447c2d6a6442538d01c5fce22",
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The manifest description and the full user-facing skill documentation are presented in Chinese, including usage instructions, risk notes, and examples. This imposes a specific language on users without any opt-in, alternate language support, or justification that the skill is intended only for a Chinese-speaking audience.

External Transmission

Medium
Category
Data Exfiltration
Content
from typing import Optional, Tuple

# x402 payment endpoint
X402_ENDPOINT = "https://api.x402.dev/pay"
PAYMENT_ADDRESS = "0x24b288c98421d7b447c2d6a6442538d01c5fce22"
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
from typing import Optional, Tuple

# x402 payment endpoint
X402_ENDPOINT = "https://api.x402.dev/pay"
PAYMENT_ADDRESS = "0x24b288c98421d7b447c2d6a6442538d01c5fce22"
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

External Transmission

Medium
Category
Data Exfiltration
Content
from typing import Optional, Tuple

# x402 payment endpoint
X402_ENDPOINT = "https://api.x402.dev/pay"
PAYMENT_ADDRESS = "0x24b288c98421d7b447c2d6a6442538d01c5fce22"
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
The non-JSON output path prints all user-facing labels and status text in Chinese, but the script does not offer a language selection flag or document that it is intentionally limited to Chinese-speaking users. This creates a natural-language policy issue because the skill imposes a specific locale on users without opt-in.

Static analysis

No suspicious patterns detected.