Back to skill

Security audit

Paper Ondo Hedge

Security checks for vulnerabilities and agentic risk

Overview

This is a real trading bot whose local web panel can expose saved wallet/API secrets and start or stop trading without authentication.

Install only if you are comfortable reviewing and hardening it first. Use mock mode by default, avoid entering valuable wallet keys or broad API credentials into the web panel, do not expose the localhost service while browsing untrusted sites, and add authentication, origin/host checks, secret masking, input validation, and explicit real-trading confirmations before using real funds.

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
web_server.py:173
Finding

Unauthenticated loopback API exposes trading credentials and privileged bot controls

Content
View full analysis

Vulnerability Details

File Location: web_server.py, lines 173–233 and 260
Vulnerability Type: Unauthenticated sensitive-data disclosure and state-changing API access
Risk Level: High

Technical Analysis

The web control panel binds to the loopback interface, but its API has no authentication, authorization, CSRF protection, or validation of the Host and Origin headers.

The configuration endpoint returns every value loaded from .env, including PAPER_WALLET_PRIVATE_KEY, PAPER_SESSION_KEY, ONDO_KEY_ID, and ONDO_API_SECRET:

python
def do_GET(self):
    parsed = urlparse(self.path)
    path = parsed.path

    if path == "/" or path == "/index.html":
        if HTML_FILE.exists():
            self._send_html(HTML_FILE.read_text(encoding="utf-8"))
        else:
            self._send_html("<h1>index.html not found</h1>", 404)
        return

    if path == "/api/config":
        self._send_json({"success": True, "config": load_env()})
        return

    if path == "/api/status":
        running = is_running()
        pid = get_pid()
        self._send_json({
            "success": True,
            "running": running,
            "pid": pid,
            "log": tail_log(150),
        })
        return

    if path == "/api/log":
        self._send_json({"success": True, "log": tail_log(300)})
        return

The POST API also permits callers to overwrite the entire .env configuration and start or stop the bot without proving that they are the authorized operator:

python
def do_POST(self):
    parsed = urlparse(self.path)
    path = parsed.path

    length = int(self.headers.get("Content-Length", 0))
    body = self.rfile.read(length).decode("utf-8") if length else "{}"
    try:
        data = json.loads(body)
    except json.JSONDecodeError:
        data = {}

    if path == "/api/config":
        try:
            s
...[truncated 3018 chars]
Remediation
View remediation

Remediation Suggestions

  1. Generate a cryptographically random control token for each server launch and require it on every API request. Store it outside the served page or deliver it through a secure initialization mechanism.
  2. Validate the Host header against an exact allowlist such as 127.0.0.1:8765 and localhost:8765; reject all other values to mitigate DNS rebinding.
  3. Validate Origin on all state-changing requests and reject missing or unexpected origins where appropriate.
  4. Add CSRF protection to every configuration and process-control endpoint.
  5. Never return raw secret values from /api/config. Return only non-sensitive settings and masked indicators such as whether each credential is configured.
  6. Split secret updates from ordinary strategy configuration. Require explicit re-entry and authenticated confirmation when changing credentials.
  7. Allowlist accepted configuration keys and validate their types and ranges server-side before writing .env.
  8. Require a separate explicit confirmation for switching to real mode and starting real trades. The backend must enforce this gate rather than relying only on browser UI warnings.
  9. Apply restrictive filesystem permissions to .env and avoid exposing exception messages that could reveal sensitive local details.
  10. Consider replacing the browser-accessible HTTP interface with a local authenticated IPC mechanism, or use a framework with established session, CSRF, origin, and host-validation controls.
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
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (57)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · .gitignore (reported line 2)May include surrounding context.

text
# 环境变量和私钥(绝对不能上传)
.env
*.env.local

# 运行时生成的文件

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · .gitignore (reported line 3)May include surrounding context.

text
# 环境变量和私钥(绝对不能上传)
.env
*.env.local

# 运行时生成的文件
bot.log

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

The README instructs users to place a wallet private key and API secrets into a local .env file for a bot that can execute real trades. Storing high-value secrets in plaintext configuration materially increases the risk of credential exposure through accidental commits, local malware, backups, shell history, logs, or insecure file permissions; in this trading context, exposed credentials could allow unauthorized trading and financial loss.

Content

Scanner excerpt · README.md (reported line 72)May include surrounding context.

2. 配置环境变量

bash
cp .env.example .env

编辑 .env,填入以下内容:

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

This skill explicitly supports real authenticated trading using wallet/API credentials while describing the bot in softer operational terms that may understate the sensitivity of the actions performed. In an agent setting, capability understatement around live market orders and leverage changes can cause unsafe delegation, unintended financial loss, and overtrust by users or orchestrators.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding

This skill explicitly supports real authenticated trading using wallet/API credentials while describing the bot in softer operational terms that may understate the sensitivity of the actions performed. In an agent setting, capability understatement around live market orders and leverage changes can cause unsafe delegation, unintended financial loss, and overtrust by users or orchestrators.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

This skill explicitly supports real authenticated trading using wallet/API credentials while describing the bot in softer operational terms that may understate the sensitivity of the actions performed. In an agent setting, capability understatement around live market orders and leverage changes can cause unsafe delegation, unintended financial loss, and overtrust by users or orchestrators.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

This skill explicitly supports real authenticated trading using wallet/API credentials while describing the bot in softer operational terms that may understate the sensitivity of the actions performed. In an agent setting, capability understatement around live market orders and leverage changes can cause unsafe delegation, unintended financial loss, and overtrust by users or orchestrators.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

This skill explicitly supports real authenticated trading using wallet/API credentials while describing the bot in softer operational terms that may understate the sensitivity of the actions performed. In an agent setting, capability understatement around live market orders and leverage changes can cause unsafe delegation, unintended financial loss, and overtrust by users or orchestrators.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
91% confidence
Finding

The skill instructs users to place highly sensitive secrets, including a wallet private key and exchange API credentials, into a local .env file and use them for real trading. In an agent/tooling context with Write/Bash access, encouraging plaintext secret handling materially raises the risk of credential leakage through logs, shell history, accidental commits, file reads by other tools, or compromise of the local environment.

Content

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

1. Configure .env

bash
cp .env.example .env

Edit .env:

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The bot can perform live leveraged trading and later force-close positions without any explicit confirmation gate, risk acknowledgment, or strong warning at the point of execution. In this context, accidental invocation, ambiguous user intent, or hostile prompt injection could directly cause real financial exposure and liquidation risk.

Content

No source excerpt is available for this finding.

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · index.html (reported line 279)May include surrounding context.

html
<div class="subtitle" data-i18n="subtitle">亏损挖矿 · 中性对冲 · PAPER + ONDO 积分</div>
  </header>

  <!-- 状态栏 -->
  <div class="status-bar">
    <div class="status-left">
      <div class="status-dot stopped" id="statusDot"></div>

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · index.html (reported line 349)May include surrounding context.

html
</div>
    </div>

    <!-- 对冲策略参数 -->
    <div class="card">
      <h2 data-i18n="strategy_params">对冲策略参数</h2>
      <div class="form-row">

Credential Access

High
Category
Privilege Escalation
Confidence
97% confidence
Finding

The page collects a wallet private key and API secret, then posts them to a backend endpoint that saves them to a .env file. In the context of a live trading bot, storing high-value credentials in plaintext application configuration substantially increases the blast radius of any local file disclosure, logging mistake, backup leak, or server compromise, and could directly lead to wallet and account takeover.

Content

Scanner excerpt · index.html (reported line 676)May include surrounding context.

html
}
  try {
    const res = await api("/api/config", "POST", cfg);
    if (res.success) toast("配置已保存到 .env");
    else toast(res.message, "error");
  } catch (e) {
    toast("保存失败: " + e.message, "error");

Lp1

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'env' capability that is not listed in its permissions. This may indicate deceptive intent or missing permission declarations.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The close-all command liquidates positions on both platforms immediately with no confirmation, dry-run, scope selection, or summary of what will be closed. In a live trading bot, a mistaken invocation, automation bug, or prompt-injection-driven tool call could force premature liquidation and realize financial losses.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The register command prints the newly issued session key directly to stdout, which can leak into terminal history, logs, CI output, shell capture, or orchestration traces. Because this key authorizes actions for the trading account, disclosure can enable unauthorized trading or account manipulation.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
99% confidence
Finding

This line outputs the full session key value intended for placement in .env, directly exposing a live credential to any observer or logging system. In the context of a trading skill, leaked session credentials are especially dangerous because they can enable unauthorized account actions and fund-impacting trades.

Content

Scanner excerpt · main.py (reported line 130)May include surrounding context.

python
sess = paper.register_session_key()
    print(f"Session Key: {sess.session_address}")
    print(f"过期时间: {sess.expiry}")
    # 保存 session key 到 .env
    print("请将以下变量添加到 .env:")
    print(f"PAPER_SESSION_KEY={sess.session_key}")

Lp1

High
Category
MCP Least Privilege
Confidence
93% confidence
Finding

This client performs authenticated network requests to a live trading API, including placing market orders, changing leverage, and closing positions. In the context of an agent skill for automated hedging and account control, undeclared network capability is security-relevant because it enables real-money account actions and exfiltration paths if the surrounding permission model does not explicitly authorize such access.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

The skill explicitly instructs the operator to run cat .env, which will print secrets such as wallet private keys, API keys, and session keys to the terminal. In an agent-assisted environment, this can expose credentials into logs, transcripts, terminal history, screenshots, or downstream tooling, enabling account takeover and unauthorized trading.

Content

Scanner excerpt · paper-ondo-hedge.md (reported line 80)May include surrounding context.

bash
cd /Users/caroline/Desktop/源代码/demo/paper中性脚本
cat .env

模拟模式(默认 HEDGE_MODE=mock):无需配置凭证,直接运行。

Lp1

High
Category
MCP Least Privilege
Confidence
84% confidence
Finding

The code has process-execution capability through subprocess.Popen, but the finding indicates this capability is not declared in permissions. In an agent skill ecosystem, undeclared execution capability is risky because reviewers and orchestrators may not expect the skill to spawn local processes.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · main.py (reported line 45)May include surrounding context.

python
然后在浏览器打开 http://localhost:8765

功能:
- 可视化填写和保存 .env 配置
- 一键启动/停止对冲机器人
- 实时查看运行日志和账户状态
"""

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · main.py (reported line 53)May include surrounding context.

python
然后在浏览器打开 http://localhost:8765

功能:
- 可视化填写和保存 .env 配置
- 一键启动/停止对冲机器人
- 实时查看运行日志和账户状态
"""

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · web_server.py (reported line 9)May include surrounding context.

python
然后在浏览器打开 http://localhost:8765

功能:
- 可视化填写和保存 .env 配置
- 一键启动/停止对冲机器人
- 实时查看运行日志和账户状态
"""

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · web_server.py (reported line 27)May include surrounding context.

python
from urllib.parse import urlparse

BASE_DIR = Path(__file__).parent.resolve()
ENV_FILE = BASE_DIR / ".env"
ENV_EXAMPLE = BASE_DIR / ".env.example"
HTML_FILE = BASE_DIR / "index.html"
LOG_FILE = BASE_DIR / "bot.log"

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · web_server.py (reported line 239)May include surrounding context.

python
from urllib.parse import urlparse

BASE_DIR = Path(__file__).parent.resolve()
ENV_FILE = BASE_DIR / ".env"
ENV_EXAMPLE = BASE_DIR / ".env.example"
HTML_FILE = BASE_DIR / "index.html"
LOG_FILE = BASE_DIR / "bot.log"

Static analysis

Detected: suspicious.exposed_secret_literal

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
index.html:451

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
main.py:38

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
README.md:91

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
SKILL.md:128