Back to skill

Security audit

okx-cex-portfolio

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly coherent for OKX portfolio management, but it asks agents to inspect credential-related configuration and includes an unpinned global install path for a financial CLI.

Review this skill before installing. Prefer the pinned package version from metadata, avoid unpinned global installation where possible, and only run it with least-privilege OKX credentials. Confirm that `okx config show --json` redacts secrets before allowing an agent to capture or summarize its output, and use demo mode first for testing.

Vulnerability Patterns
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T08 · Insecure Dependencies

Warning
Location
SKILL.md:30
Finding
Global Installation of an Unverified Third-Party npm Package## Vulnerability Details **File Location**: `SKILL.md`, lines 30–34 **Vulnerability Type**: Supply-chain exposure through global package installation **Risk Level**: Medium **Vulnerable Code**: ```markdown 1. Install `okx` CLI: ```bash npm install -g @okx_ai/okx-trade-cli ``` ``` ### Technical Analysis The Skill instructs users or agents to install `@okx_ai/okx-trade-cli` globally from the npm registry. This installation command does not specify the declared Skill version, verify a package integrity hash, validate package provenance, or provide a lockfile. Consequently, npm resolves the version available under the package name at installation time. npm packages can execute lifecycle scripts during installation. A compromised maintainer account, malicious package release, registry compromise, or package ownership change could therefore result in arbitrary code executing with the privileges of the user running the installation. Global installation also makes the resulting executable available outside the project and increases its exposure to unrelated sessions. This is especially sensitive because the installed CLI is subsequently trusted to process OKX authentication information and perform authenticated financial operations. ### Attack Path 1. An attacker compromises the npm package, a maintainer account, or the associated publishing process. 2. The attacker publishes a malicious release under `@okx_ai/okx-trade-cli`. 3. A user follows the unversioned global installation instruction. 4. npm resolves and installs the malicious release. 5. Malicious lifecycle or runtime code executes with the installing user's privileges. 6. The package accesses local OKX configuration, session information, environment variables, or other files available to that user. 7. Stolen credentials may then be used to inspect the account or perform operations allowed by the affected credentials. ### Impact Assessment Succes ...[truncated 605 chars]
Remediation
## Remediation Suggestions 1. Pin the package to the exact reviewed version: ```bash npm install -g @okx_ai/okx-trade-cli@1.4.7 ``` 2. Verify npm provenance, publisher identity, and the package integrity digest before installation. 3. Publish and document an expected cryptographic checksum or signed release artifact. 4. Prefer a project-local or isolated installation instead of a global installation: ```bash npm install --save-exact @okx_ai/okx-trade-cli@1.4.7 ``` 5. Use a lockfile and a trusted internal registry or allowlist where possible. 6. Review lifecycle scripts and consider installing with `--ignore-scripts` when lifecycle scripts are not required. 7. Execute the CLI in a sandbox or under a dedicated low-privilege account with access only to the necessary configuration. 8. Ensure OKX credentials use least privilege and do not include withdrawal permissions unless strictly necessary.

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:50
Finding
Credential-Bearing Configuration May Be Exposed to Agent Output and Logs## Vulnerability Details **File Location**: `SKILL.md`, lines 50–56 and 79–82 **Vulnerability Type**: Plaintext exposure of sensitive authentication configuration **Risk Level**: Medium **Vulnerable Code**: ```markdown ### Step A — Verify credentials Check **both** sources (see [preflight Step 2](../_shared/preflight.md#step-2--detect-auth-method-once-per-session) for the decision table). `okx auth status --json` alone is insufficient — its `apiKey` field is always `false` and does NOT reflect the TOML config. ```bash okx config show --json # authoritative for API-key presence okx auth status --json # authoritative for OAuth session state ``` ``` The command is repeated as an operational requirement: ```markdown - **API Key users**: run `okx config show --json` to discover available profile names and their `demo` settings. Use `--profile <name>` to select the correct one. ``` ### Technical Analysis The Skill requires an agent to print the complete JSON representation of the OKX configuration to determine whether an API key is present and to discover profile metadata. This exposes more configuration data to the command-output channel than is necessary for the decision being made. If `okx config show --json` includes an API key or other sensitive profile fields, those values can enter model context, terminal history, execution traces, observability systems, chat records, or other logs. The Skill warns users not to submit credentials in chat, but the prescribed command can indirectly introduce credential-bearing configuration into the same processing context. The operation only needs a boolean indicating credential presence, profile names, and demo-mode status. Printing complete configuration objects violates data-minimization and least-exposure principles. ### Attack Path 1. A user configures an OKX profile containing an API key or related sensitive authentication metadata. 2. The agent foll ...[truncated 1362 chars]
Remediation
## Remediation Suggestions 1. Replace the full configuration dump with a dedicated redacted status command that returns only: - Profile name - Whether credentials are configured - Demo/live designation - Authentication type 2. Modify the CLI so secret fields are always omitted or replaced with fixed redaction markers in all human-readable and JSON output. 3. If no safe status command exists, process the configuration locally and emit only non-sensitive derived values. Do not return the source configuration to the agent. 4. Add automated tests confirming that API keys, secrets, passphrases, OAuth tokens, and signing material never appear in standard output or error output. 5. Disable command-output logging for authentication checks or apply deterministic secret redaction before logs and model context are created. 6. Document least-privilege API-key configuration, including restricted permissions and exchange-side IP allowlisting. 7. Rotate any credentials that may already have appeared in agent transcripts, execution traces, or telemetry.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (2)

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
### Step 2: Run read commands immediately — confirm profile (Step 0) then writes

**Read commands** (1–10): run immediately, no confirmation needed.

- `ccy` filter: use currency symbol like `USDT`, `BTC`, `ETH`
- `--instType` for fees/positions: `SPOT`, `SWAP`, `FUTURES`, `OPTION`
Confidence
75% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Session Persistence

Medium
Category
Rogue Agent
Content
## Global Notes

- All write commands require valid credentials (OAuth session or API key in `~/.okx/config.toml`)
- Auth method and trading mode are determined in "Credential & Profile Check"; see that section for parameter rules
- Every command result includes a `[mode: live]` or `[mode: demo]` tag for audit reference
- `--json` returns the raw OKX API v5 response by default. Add `--env` to wrap the output as `{"env": "<live|demo>", "profile": "<name>", "data": <response>}`
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.

Static analysis

No suspicious patterns detected.