Back to skill

Security audit

Binance Dca

Security checks for vulnerabilities and agentic risk

Overview

This Binance DCA skill matches its trading purpose, but it should be reviewed carefully because it can place live orders and contains unsafe code execution and credential-persistence risks.

Install only if you are comfortable granting a local script access to Binance trading keys. Use testnet first, use a dedicated key with no withdrawals and the narrowest spot permissions possible, avoid storing secrets in ~/.bashrc, avoid unattended cron buys until you add explicit approval and spending limits, and do not pass untrusted values into the plan command until the Python argument-injection issue 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/dca.sh:172
Finding

Arbitrary Python Code Execution Through Unsanitized DCA Plan Arguments

Content
View full analysis

Vulnerability Details

File Location: scripts/dca.sh:172-209
Vulnerability Type: Python source-code injection
Risk Level: High

Vulnerable Code

bash
action_plan() {
  local amount="${1:-50}" frequency="${2:-7}" periods="${3:-12}" symbol="${4:-BTCUSDT}"
  symbol=$(echo "$symbol" | tr '[:lower:]' '[:upper:]')

  # Get current price
  local price_resp price
  price_resp=$(api_public "/api/v3/ticker/price" "symbol=${symbol}")
  price=$(echo "$price_resp" | grep -o '"price":"[^"]*"' | head -1 | cut -d'"' -f4)

  echo "DCA Plan: ${symbol}"
  echo "=========================="
  echo "Buy amount:  \$${amount} per buy"
  echo "Frequency:   every ${frequency} days"
  echo "Duration:    ${periods} buys"
  echo "Current:     ${price}"
  echo "=========================="

  python3 -c "
amount = float('${amount}')
periods = int('${periods}')
freq = int('${frequency}')
price = float('${price}')

total_invested = amount * periods
btc_at_current = total_invested / price
total_days = freq * periods

print(f'Total invest:  \${total_invested:,.2f}')
print(f'At cur. price: {btc_at_current:.8f} ${symbol%%USDT*}')
print(f'Time span:     {total_days} days (~{total_days/30:.1f} months)')
print()
print('Scenario Analysis (if avg price over period is):')
for pct in [-30, -20, -10, 0, 10, 20, 50, 100]:
    avg = price * (1 + pct/100)
    coins = total_invested / avg
    value = coins * price * (1 + pct/100)
    pnl = value - total_invested
    pnl_pct = (pnl / total_invested) * 100
    sign = '+' if pnl >= 0 else ''
    print(f'  {pct:+4d}% -> avg \${avg:>10,.2f} -> {coins:.8f} BTC -> PnL: {sign}\${pnl:>10,.2f} ({sign}{pnl_pct:.1f}%)')
" 2>/dev/null || die "Python3 required for plan calculations"
}

Technical Analysis

The amount, frequency, and periods command-line arguments are interpolated directly into a string passed to python3 -c. The plan action does n ...[truncated 2643 chars]

Remediation
View remediation

Remediation Suggestions

Do not construct Python source code using command-line values. Pass data as positional arguments to a fixed Python program and parse it through sys.argv.

A safer pattern is:

bash
[[ "$amount" =~ ^[0-9]+([.][0-9]+)?$ ]] ||
  die "Amount must be a positive number"
[[ "$frequency" =~ ^[1-9][0-9]*$ ]] ||
  die "Frequency must be a positive integer"
[[ "$periods" =~ ^[1-9][0-9]*$ ]] ||
  die "Number of buys must be a positive integer"
[[ "$symbol" =~ ^[A-Z0-9]{2,20}$ ]] ||
  die "Invalid trading symbol"

python3 - "$amount" "$frequency" "$periods" "$price" "$symbol" <<'PY'
import sys

amount = float(sys.argv[1])
frequency = int(sys.argv[2])
periods = int(sys.argv[3])
price = float(sys.argv[4])
symbol = sys.argv[5]

# Perform calculations using parsed values.
PY

Apply both syntactic validation and business limits. Recommended controls include:

  • Require amount to be a finite positive decimal and impose a reasonable maximum.
  • Require frequency and periods to be positive integers with upper bounds.
  • Restrict trading symbols to expected uppercase ASCII letters and digits.
  • Validate the API-provided price as a finite positive decimal before calculation.
  • Keep executable Python code static; never interpolate shell variables into Python source.
  • Run the Skill under a dedicated, unprivileged account.
  • Provide the Binance key only to processes that require it.
  • Configure the Binance key without withdrawal privileges, with only required spot-trading permissions and an IP allowlist.
  • Add regression tests containing quotes, semicolons, comment characters, newlines, and Python expressions in every CLI argument.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (15)

YARA rule 'ransomware_behavior': Ransomware-like patterns (mass encryption, ransom notes) [malware]

Critical
Category
YARA Match
Confidence
80% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · SKILL.md (reported line 434)May include surrounding context.

w for intelligent DCA automation with alerts:

Example: Weekly BTC DCA with Telegram notifications

json
{
  "name": "Weekly BTC DCA",
  "schedule": {
    "kind": "cron",
    "expr": "0 9 * * 1",
    "tz": "America/New_York"
  },
  "sessionTarget": "isolated",
  "payload": {
    "kind": "agentTurn",
    "message": "Execute weekly DCA: buy $50 BTCUSDT via binance-dca skill. After execution, send me a summary: amount bought, price, total BTC accumulated so far (check history). If it fails, alert me immediately.",
    "deliver": true,
    "channel": "telegram"
  }
}

Benefits:

  • ✅ Execution confirmations sent to you
  • ✅ Failure alerts
  • ✅ Can ask agent to analyze history and report progress
  • ✅ Easy to pause/resume via openclaw cron commands

Setup:

bash
# Add the cron job (paste JSON above when prompted)
openclaw cron add

# List all jobs
openclaw cron list

# Run manually to test
openclaw cron run <jobId>

# Disable temporarily
openclaw cron update <jobI

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The skill claims automation, risk management, and OpenClaw integration beyond what is visibly implemented, which can mislead users or orchestrators into trusting safety controls that may not exist. In a financial trading context, overstated capabilities are dangerous because users may rely on absent safeguards before executing real-money orders.

Content

No source excerpt is available for this finding.

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Confidence
90% confidence
Finding

Appending API credentials directly into ~/.bashrc creates persistent plaintext secret storage in a shell startup file that is easy to leak through backups, dotfile sync, accidental sharing, or later command/output exposure. In a trading skill handling live exchange keys, persistent credential placement materially raises the risk of account compromise and unauthorized trading.

Content

Scanner excerpt · SKILL.md (reported line 66)May include surrounding context.

has a static IP

  • Use a separate API key for DCA (easier to revoke if needed)
  • Start with small amounts to test

2. Set Environment Variables

Never hardcode credentials. Always use environment variables:

bash
export BINANCE_API_KEY="your-api-key-here"
export BINANCE_SECRET_KEY="your-secret-key-here"

Make them permanent (optional, add to ~/.bashrc or ~/.zshrc):

bash
echo 'export BINANCE_API_KEY="your-api-key-here"' >> ~/.bashrc
echo 'export BINANCE_SECRET_KEY="your-secret-key-here"' >> ~/.bashrc
source ~/.bashrc

For testnet (recommended for first-time users):

bash
export BINANCE_BASE_URL="https://testnet.binance.vision"

Get testnet API keys at: testnet.binance.vision

3. Verify Setup

bash
# Check balance (should not error)
bash scripts/dca.sh balance USDT

# Check BTC price
bash scripts/dca.sh price BTCUSDT

If you see prices/balances, you're ready!


Quick Start Examples

Example

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill advertises and demonstrates shell execution (bash scripts/dca.sh ...) but declares no explicit tool scope or permission boundaries. In an agent setting, this can cause the skill to be invoked with broader execution capability than intended, increasing the risk of unreviewed command execution against a live trading environment.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The trigger description is broad enough to match ordinary discussion about investing or accumulation strategies, which may cause accidental invocation of a trading-capable skill. Because the skill can lead to balance checks and order execution, overbroad routing raises the chance of unintended financial actions.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 42)May include surrounding context.

md
1. Log in to [binance.com](https://www.binance.com)
2. Go to **Account** → **API Management**
3. Create a new API key:
   - **Label:** `OpenClaw-DCA` (or similar)
   - **Restrictions:** Enable **Spot & Margin Trading** only
   - **IP Whitelist:** Add your server IP for security (optional but recommended)

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
89% confidence
Finding

The automation section explicitly describes scheduled execution with 'No confirmations' and silent operation, then recommends agent-driven cron execution of purchases. Autonomous financial transactions without per-execution confirmation materially increase the risk of accidental, repeated, or context-manipulated trades.

Content

Scanner excerpt · SKILL.md (reported line 414)May include surrounding context.

md
**Limitations:**
- No alerts if it fails
- No confirmations
- Silent execution

### OpenClaw Cron (Recommended)

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 487)May include surrounding context.

bash
# Sync system time
sudo ntpdate -s time.nist.gov

# Or install/enable NTP
sudo systemctl enable systemd-timesyncd

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 490)May include surrounding context.

bash
# Sync system time
sudo ntpdate -s time.nist.gov

# Or install/enable NTP
sudo systemctl enable systemd-timesyncd

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 491)May include surrounding context.

bash
# Sync system time
sudo ntpdate -s time.nist.gov

# Or install/enable NTP
sudo systemctl enable systemd-timesyncd

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 490)May include surrounding context.

sudo ntpdate -s time.nist.gov

Or install/enable NTP

sudo systemctl enable systemd-timesyncd sudo systemctl start systemd-timesyncd

text

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 638)May include surrounding context.

md
🔒 **Credential Management:**
- Never commit `.env` files with keys to Git
- Use environment variables, not hardcoded strings
- On shared servers, restrict file permissions: `chmod 600 ~/.bashrc`

🔒 **Testnet First:**
- Always test new strategies on testnet before using real funds

External Transmission

Medium
Category
Data Exfiltration
Confidence
86% confidence
Finding

This script sends signed trading requests and the API key to an externally configurable endpoint via BASE_URL, which is taken directly from the environment. If an attacker can influence BINANCE_BASE_URL, they can redirect authenticated requests to an arbitrary server, capturing the API key and full signed query data and potentially replaying or abusing those requests within the validity window.

Content

Scanner excerpt · scripts/dca.sh (reported line 55)May include surrounding context.

sh
curl -sf -H "X-MBX-APIKEY: ${BINANCE_API_KEY}" \
      "${BASE_URL}${endpoint}?${query}" 2>/dev/null || die "Signed API request failed: ${endpoint}"
  else
    curl -sf -X "$method" -H "X-MBX-APIKEY: ${BINANCE_API_KEY}" \
      -d "$query" "${BASE_URL}${endpoint}" 2>/dev/null || die "Signed API request failed: ${endpoint}"
  fi
}

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The code claims to perform scenario analysis and prints 'PnL' values for different average-price scenarios, but value is computed as coins * price * (1 + pct/100) while coins is total_invested / avg and avg is the same price * (1 + pct/100), making value always equal total_invested. This contradicts the apparent intent of the output because every scenario will show zero profit/loss regardless of the percentage change.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The manifest centers this skill on recurring purchases, DCA planning, and Binance spot buys, but the history command retrieves all trades for a symbol and explicitly reports both BUY and SELL sides. Viewing sell-side trading activity is not necessary to implement DCA purchase execution or planning, so this is a modest capability expansion beyond the stated accumulation-focused purpose.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.