Back to skill

Security audit

Longbridge Openapi

Security checks for vulnerabilities and agentic risk

Overview

This is a legitimate brokerage helper, but it combines broad auto-invocation, private financial account access, persistent money-related actions, and unsafe temporary-file handling that warrant manual review.

Install only if you trust Longbridge and are comfortable giving the agent access to brokerage account data. Before use, avoid authenticated workflows that write output to fixed /tmp files, review every watchlist, alert, or DCA preview carefully, and do not confirm DCA changes unless every amount, currency, frequency, start date, and end condition is exactly right.

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
SKILL.md:82
Finding
Predictable Shared Temporary Files May Expose Private Brokerage Data<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, line 82; repeated at lines 587–592 and 623 **Vulnerability Type**: Predictable temporary-file creation and plaintext storage of sensitive data **Risk Level**: Medium ### Vulnerable Code Snippets At line 82, the Skill establishes this as a general rule: ```markdown - When piping JSON into Python, **save to a temp file first** (`longbridge … --format json > /tmp/x.json`, then `python3 -c "import json; d=json.load(open('/tmp/x.json'))"`). The CLI sometimes appends version-notification lines to stdout that break direct pipes. ``` The unsafe pattern is repeated at lines 587–592: ```markdown **CLI + Python pattern**: prefer reading from a file over piping into `python3 -c`. Multi-line JSON with embedded quotes can hit shell-quoting edge cases (especially under zsh's `-c` argument handling): ```bash longbridge institution-rating 700.HK --format json > /tmp/rating.json python3 -c "import json; d = json.load(open('/tmp/rating.json')); print(d)" ``` ``` It is mandated again at line 623: ```markdown **JSON output handling**: always save to a temp file first (`longbridge <cmd> --format json > /tmp/data.json`), then read the file. Do not pipe directly — the CLI may append version notification lines that break JSON parsing. ``` ### Technical Analysis The Skill instructs the Agent to redirect Longbridge CLI output into fixed, predictable paths in the shared `/tmp` directory, including `/tmp/x.json`, `/tmp/rating.json`, and `/tmp/data.json`. Shell redirection to a predictable path does not provide exclusive file creation, does not reject symbolic links, and relies on the process umask for file permissions. On systems with a permissive umask, newly created JSON files may be readable by other local users. An attacker may also pre-create the expected path as a symbolic link, causing shell redirection to follow the link and truncate or overwrite another file writable by the Agent process. The instruction ...[truncated 2695 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Avoid disk storage for sensitive responses where possible.** Capture subprocess output directly through an execution API that keeps stdout in memory and separates version notices from structured JSON. 2. **Use a private randomized directory when a file is unavoidable:** ```bash umask 077 tmpdir="$(mktemp -d)" trap 'rm -rf -- "$tmpdir"' EXIT longbridge portfolio --format json > "$tmpdir/result.json" python3 -c 'import json, sys; print(json.load(open(sys.argv[1])))' \ "$tmpdir/result.json" ``` 3. **Set restrictive permissions before creating any temporary artifact.** Use `umask 077` so files are accessible only to the current user. 4. **Create files atomically and exclusively.** Prefer language-level temporary-file APIs such as Python's `tempfile.TemporaryDirectory` or `NamedTemporaryFile`, which generate unpredictable names and can prevent accidental reuse. 5. **Defend against symbolic links.** Use creation methods supporting exclusive creation and no-follow semantics rather than ordinary shell redirection into a known path. 6. **Guarantee cleanup.** Install a cleanup trap immediately after creating the private directory and remove all temporary files on success, failure, or interruption. 7. **Separate public and private workflows.** Explicitly prohibit writing authenticated account responses to shared temporary locations. Statement exports should only be written to a filesystem location confirmed by the user. 8. **Replace every fixed `/tmp` example.** Update the instructions at lines 82, 587–592, and 623 so Agents do not reproduce the unsafe pattern in any workflow. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (4)

Vague Triggers

High
Confidence
95% confidence
Finding
The skill is marked as PREFERRED for an extremely broad set of finance-related prompts, including common conversational phrases, which makes accidental or over-broad invocation likely. In this skill, unintended invocation is more dangerous than a normal read-only mismatch because the same skill also exposes authenticated account data and mutating actions such as watchlist edits, alerts, and DCA plan creation.

Credential Access

High
Category
Privilege Escalation
Content
description: Optional — paired with LONGBRIDGE_APP_KEY when bypassing the OAuth flow.
      - name: LONGBRIDGE_ACCESS_TOKEN
        required: false
        description: Optional — OAuth access token, also exposed by `longbridge auth login`.
  author: longbridge
  category: finance
  markets: [US, HK, CN, SG, Crypto]
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
| `longbridge anomaly --market <HK\|US\|CN\|SG> [--count N] [--symbol <SYM>] --format json` | Unusual movements (market-wide or filtered to one symbol). Default `HK`. Max `--count 100`, default 50. |
| `longbridge trade-stats <SYMBOL> --format json` | Intraday price-by-volume distribution — bucketed price levels with volume at each. |

**Output rule (trade-stats)**: do **not** label any range "support" or "resistance" — call it the *heaviest-traded zone* / *most-traded zone*. Render top 5 buckets with VWAP and day high/low.

---
Confidence
85% confidence
Finding
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Vague Triggers

Medium
Confidence
88% confidence
Finding
These section triggers include generic phrases like briefings and broad account/watchlist queries that can match ordinary conversation without enough disambiguation. While the document includes confirmation gates for mutations, over-triggering still increases the chance of unnecessary access to private financial context or steering the agent into higher-risk workflows.

Static analysis

No suspicious patterns detected.