Back to skill

Security audit

okx-cex-trade

Security checks for vulnerabilities and agentic risk

Overview

The skill is a real OKX trading assistant, but it needs review because it can place real-money trades and one event-contract workflow weakens the live/demo and authentication preflight.

Install only if you understand it can use your OKX credentials to submit, amend, cancel, and close real trades. Prefer demo mode first, verify that the CLI redacts credentials in config/status output, and require explicit live/demo plus order-detail confirmation before every write, especially event-contract trades.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:54
Finding
Credential-bearing configuration is exposed to the Agent context<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:54-63` **Vulnerability Type**: `T05: Unauthorized Access and Privilege Escalation` **Risk Level**: Medium ### Vulnerable Code ```markdown Run **both** commands — the `apiKey` field from `okx auth status --json` is the auth-binary's internal state and is always `false` regardless of whether `~/.okx/config.toml` has an API-key profile. `okx config show --json` is the only authoritative source for API-key presence. ```bash okx config show --json # reveals API-key profiles (TOML config) okx auth status --json # reveals OAuth session state (auth-binary state) ``` Apply **in this order** — first match wins: - `config show --json` has any profile with a non-empty `api_key` field → **API Key mode**. Proceed to Step B. ``` ### Technical Analysis The Skill requires both authentication commands to be executed before every authenticated operation. In particular, `okx config show --json` reads API-key profiles from the user's local OKX configuration and returns the result through the command-output channel visible to the Agent. The documented decision logic explicitly expects the Agent to inspect a non-empty `api_key` field. Therefore, the output is not described as a minimal Boolean status response, and the Skill does not establish that API keys, secrets, passphrases, or other sensitive profile fields are redacted before entering the Agent context. Authentication detection only requires profile names, environment information, and a Boolean indicating whether usable credentials exist. Returning complete profile objects violates least-privilege and data-minimization principles. ### Attack Path 1. A user requests any authenticated trading or account operation. 2. The Skill mandates execution of `okx config show --json`. 3. The CLI reads the user's credential profiles from `~/.okx/config.toml`. 4. The JSON output enters the Agent's tool context and may also be retained in transcripts or execut ...[truncated 926 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace `okx config show --json` with a dedicated status command that returns only: - Profile name - Live or demo environment - Authentication method - Boolean credential-presence state 2. Ensure the CLI always masks API keys, secrets, passphrases, access tokens, refresh tokens, and session cookies before producing output. 3. Perform authentication checks inside the CLI process so raw configuration never enters the Agent context. 4. If a full configuration command must remain available, add an explicit redacted mode and require it in the Skill: ```bash okx config status --json ``` 5. Document and test redaction behavior. Add regression tests that fail if sensitive TOML fields appear in JSON output. 6. Avoid retaining authentication-status output in persistent transcripts or verbose logs. ]]>

T08 · Insecure Dependencies

Warning
Location
SKILL.md:13
Finding
Globally installed npm dependency lacks an auditable integrity guarantee<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:13-17` and `SKILL.md:32-35` **Vulnerability Type**: `T08: Insecure Dependencies` **Risk Level**: Medium ### Vulnerable Code ```yaml install: - id: npm kind: node package: "@okx_ai/okx-trade-cli@1.4.6" bins: ["okx"] label: "Install okx CLI (npm)" ``` ```markdown 1. Install `okx` CLI: ```bash npm install -g @okx_ai/okx-trade-cli ``` ``` ### Technical Analysis The dependency is pinned to version `1.4.6`, which reduces accidental version drift, but the Skill does not include the package source, a lockfile, an integrity hash, a signature-verification procedure, or an independently verifiable artifact digest. The documented command installs the package globally. npm packages and their transitive dependencies may execute lifecycle scripts during installation with the privileges of the invoking user. The dependency is particularly sensitive because it is expected to access local OKX credentials and perform authenticated financial transactions. This audit did not inspect the external npm package, so it does not establish that the named package is malicious. The issue is that the Skill delegates high-impact operations to an external component without providing a reproducible integrity or provenance control. ### Attack Path 1. The user follows the prerequisite and runs the global npm installation command. 2. npm retrieves the named package and its transitive dependencies from the configured registry. 3. Installation lifecycle scripts, if present, execute as the installing user. 4. If the publisher account, registry response, package version, or a transitive dependency has been compromised, attacker-controlled code can run locally. 5. Such code could access files available to the user, including OKX configuration, and could spoof or alter subsequent trading operations. ### Impact Assessment A compromised dependency would execute with the local permissions of the user perfo ...[truncated 522 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Publish and verify cryptographic integrity hashes for the exact CLI release and its distributable artifact. 2. Provide signed release artifacts and document signature verification before installation. 3. Include an audited lockfile or software bill of materials covering transitive dependencies. 4. Prefer a project-local, isolated installation rather than a global installation. 5. Disable npm lifecycle scripts where operationally feasible: ```bash npm install --ignore-scripts ``` If lifecycle scripts are required, document and audit each one. 6. Pin the package by exact version and integrity digest, not version alone. 7. Verify package ownership and provenance through npm trusted publishing or equivalent controls. 8. Run the CLI under a least-privileged account and restrict filesystem access to only the configuration and network resources it requires. 9. Make the CLI source available for review or link the package to a reproducible build process. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
references/event-workflows.md:243
Finding
Event-contract workflow bypasses mandatory authentication and live/demo preflight<![CDATA[ ## Vulnerability Details **File Location**: `references/event-workflows.md:243` **Conflicting Controls**: `SKILL.md:48-103` and `SKILL.md:326-330` **Vulnerability Type**: `T09: Insecure Skill Coding Practices` **Risk Level**: High ### Vulnerable Code The event-specific workflow states: ```markdown ## Key Rules for AI Agents 1. **Place directly after user confirms** — no pre-flight check required. ``` This conflicts with the global requirements: ```markdown ## Credential & Profile Check **Run this check before any authenticated command.** ``` ```markdown **Resolution rules:** 1. Current message intent is clear (e.g. "real" / "实盘" / "live" → live; "test" / "模拟" / "demo" → demo) → use it and inform the user 2. Current message has no explicit declaration → check conversation context for a previous choice: - Found → reuse it, inform user - Not found → ask: `"Live (实盘) or Demo (模拟盘)?"` — wait for answer before proceeding ``` ```markdown | Auth method | Live (实盘) | Demo (模拟盘) | |---|---|---| | **API Key** | `--profile <live-profile>` | `--profile <demo-profile>` | | **OAuth** | *(no flag needed, live is default)* | `--demo` | ``` ```markdown ### Step 0 — Credential & Profile Check Before any authenticated command: see [Credential & Profile Check](#credential--profile-check). Determine auth method and trading mode before executing. After every command result: append `[mode: live]` or `[mode: demo]`. ``` ### Technical Analysis The project establishes a global safeguard requiring authentication verification and explicit selection of live or demo mode before every authenticated command. The event-specific workflow then instructs the Agent to place an order without that preflight after the user confirms order parameters. This creates contradictory control flow. An Agent following the more specific event workflow may treat confirmation of instrument, direction, outcome, size, and order type as sufficient authorization to execute, even when t ...[truncated 1675 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove the event-specific exception: ```markdown Place directly after user confirms — no pre-flight check required. ``` 2. Replace it with an explicit requirement: ```markdown Before every authenticated event command, complete the global Credential & Profile Check and determine live or demo mode. Confirmation of order parameters does not replace confirmation of execution environment. ``` 3. Require live mode to be explicitly selected for every write operation. Do not treat an omitted flag as authorization for real-money trading. 4. Consider making demo mode the fail-safe default when no mode has been established. 5. Separate confirmations into two clearly labeled decisions: - Execution environment: live or demo - Order details: instrument, side, outcome, size, price, and type 6. Add automated consistency checks that detect reference files which weaken or contradict global write-operation safeguards. 7. Ensure every event write command records and displays `[mode: live]` or `[mode: demo]` before and after execution. 8. Abort rather than execute if authentication method, selected profile, or execution mode cannot be determined unambiguously. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (15)

Description-Behavior Mismatch

Medium
Confidence
92% confidence
Finding
The skill explicitly says it should not be used for market data or account balance tasks, yet its workflow requires instrument lookups, contract face-value checks, leverage/account config checks, and even references to account positions. This inconsistency can cause an agent to bypass intended skill boundaries and invoke broader account/market capabilities under a trading skill, increasing the chance of over-privileged actions or accidental disclosure/use of unrelated account context.

Context-Inappropriate Capability

Low
Confidence
77% confidence
Finding
The skill documents a capability-discovery command (`okx list-tools --json`) that can enumerate all CLI commands and parameters, including commands outside the skill's stated trading scope. In a tool-using agent, this broad discovery surface can enable unintended expansion of accessible actions and weaken least-privilege assumptions.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
This guidance expands an order-execution skill into market-data interpretation and trading advice, including analysis of candles and a recommended direction. In a trading context, that scope creep is risky because the agent may act as an investment advisor without explicit user consent, suitability checks, or controls separating informational data retrieval from recommendation-making.

Context-Inappropriate Capability

Medium
Confidence
98% confidence
Finding
The file explicitly instructs the agent to produce a 'Recommended direction: UP or DOWN' with confidence and reasoning. That turns a transactional trading tool into a source of personalized investment-style recommendations, which can induce users to place risky trades based on thin heuristics and without adequate disclosures or authorization boundaries.

Description-Behavior Mismatch

Medium
Confidence
93% confidence
Finding
The reference expands futures algo support to additional order types (`trigger`, `chase`, `iceberg`, `twap`) that are not clearly included in the skill’s declared scope. In an agent setting, this documentation can cause the model to invoke or construct higher-risk order workflows beyond the intended interface, increasing the chance of unintended trading actions or use of unsupported tooling.

Context-Inappropriate Capability

Medium
Confidence
90% confidence
Finding
The troubleshooting guidance tells the agent to check bots (`okx bot grid-orders`) when leverage changes fail, even though the skill explicitly says it should not be used for bots. This creates cross-skill scope bleed: an agent following the docs may access or influence unrelated trading automation contexts, leading to unauthorized bot interaction or unsafe recommendations around active strategies.

Intent-Code Divergence

Medium
Confidence
93% confidence
Finding
The documentation states both that `okx option algo amend` exists and should be used, and later that there is 'No TP/SL algo on options' and that swap/spot algo commands do not apply to option positions. This inconsistency can cause an agent or operator to issue the wrong command sequence, fail to manage attached TP/SL orders correctly, or assume certain risk controls are unavailable when they are actually required. In a trading skill that can place and amend live exchange orders, such ambiguity materially increases the chance of execution errors and unmanaged exposure.

Description-Behavior Mismatch

Medium
Confidence
91% confidence
Finding
The reference expands the spot trading surface to include advanced algo order types such as trigger, chase, iceberg, and TWAP that are not clearly declared in the skill's described scope. In an agent setting, this creates capability drift: a model may invoke higher-risk order behaviors than policy reviewers or users expect, increasing the chance of unintended live trading actions.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The rule 'Place directly after user confirms — no pre-flight check required' reduces friction before irreversible financial actions. In a trading skill, skipping a final risk/parameter validation increases the chance of accidental or manipulated orders, especially for leveraged or event-contract products where losses can occur quickly.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
This file documents numerous live trading commands that can place, amend, and cancel real orders, including advanced conditional and automated execution types, without an explicit warning that these actions affect real funds and may cause immediate financial loss. In an AI-agent context, omission of strong transactional warnings and confirmation guidance materially increases the risk of accidental or misunderstood execution.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
This section documents position-closing and leverage-changing commands that can directly alter or liquidate live exposure, but it does not require or strongly signal user confirmation before execution. In an agent setting, that omission is dangerous because ambiguous or impulsive user requests could be translated into irreversible financial actions without a deliberate confirmation step.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The file describes order-placement commands as normal operational steps but does not prominently warn that they submit real orders to OKX rather than simulations or dry runs. In a trading agent skill, this increases the chance that an LLM or user mistakes reference examples for harmless examples, leading to unintended live trades and immediate financial loss.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
This section includes a destructive trading workflow ('cancel all open spot orders') without requiring an explicit confirmation or warning about the financial consequences of canceling live orders. In a trading skill, cancel/close actions are high-risk because they can immediately change market exposure or remove protective orders if a user request is ambiguous or misinterpreted.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The input/output examples show live order placement, leverage changes, trailing stops, TP/SL placement, and position-closing commands as directly executable examples without consistent warnings, simulation markers, or confirmation gates. Because this skill is specifically designed for real exchange trading with API credentials, these examples materially increase the chance of accidental execution causing financial loss, unintended leverage exposure, or removal of hedges/protection.

Session Persistence

Medium
Category
Rogue Agent
Content
For cross-skill workflows and step-by-step examples, read `{baseDir}/references/workflows.md`.

### Step 2 — Confirm profile, then confirm write parameters

**Read commands** (orders, positions, fills, get, get-leverage, algo orders): run immediately.
Confidence
71% confidence
Finding
The skill instructs the agent to reuse prior conversation context for trading-mode selection and to run read commands immediately, which creates session-persistence risk for a high-impact trading workflow. In practice, stale mode, profile, or account context could carry over between requests and cause queries or subsequent trading actions against the wrong environment or account assumptions.

Static analysis

No suspicious patterns detected.