Back to skill

Security audit

Bitget Wallet

Security checks for vulnerabilities and agentic risk

Overview

The skill is a Bitget Wallet API helper, but it includes under-scoped wallet signing and transaction submission paths that can move funds and expose private keys.

Review this carefully before installing. Treat it as a trading and wallet-signing skill, not just a market-data tool. Do not pass valuable wallet private keys on the command line, do not use the self-update flow from a mutable branch without separate review, and only use signing or order submission with a dedicated low-value wallet after independently checking the transaction details.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • 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
Findings (5)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/order_sign.py:31
Finding

Blind Signing of Server-Controlled Hashes and Transactions

Content
View full analysis
list[str]: acct = Account.from_key(private_key) signed_list = [] sigs = order_data.get("signatures", []) if not sigs: raise ValueError("No signatures in order data. Is this a 'txs' mode order?") for item in sigs: api_hash = item.get("hash") if not api_hash: raise ValueError(f"Missing 'hash' field in signature item: {item}") hash_bytes = bytes.fromhex(api_hash[2:]) signed = acct.unsafe_sign_hash(hash_bytes) sig_hex = "0x" + signed.signature.hex() signed_list.append(sig_hex) return signed_list ``` The normal transaction mode similarly trusts every transaction field supplied by the API: ```python for tx_item in txs: tx_data = tx_item["data"] cid = chain_id or int(tx_item.get("chainId", 1)) tx_dict = { "to": tx_data["to"], "data": tx_data["calldata"], "gas": int(tx_data["gasLimit"]), "nonce": int(tx_data["nonce"]), "chainId": cid, } if tx_data.get("supportEIP1559") or tx_data.get("maxFeePerGas"): tx_dict["maxFeePerGas"] = int(tx_data["maxFeePerGas"]) tx_dict["maxPriorityFeePerGas"] = int(tx_data["maxPriorityFeePerGas"]) tx_dict["type"] = 2 else: tx_dict["gasPrice"] = int(tx_data["gasPrice"]) value = tx_data.get("value", "0") if isinstance(value, str) and "." in value: tx_dict["value"] = int(float(value) * 1e18) else: tx_dict["value"] = int(value) signed_tx = acct.sign_transaction(tx_dict) signed_list.append("0x" + signed_tx.raw_transaction.hex()) ``` ### Technical ...[truncated 2464 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/order_sign.py:9
Finding

Wallet Private Key Exposed Through Command-Line Arguments

Content
View full analysis
' --private-key # Or pipe order-create output: python3 scripts/bitget_api.py order-create ... | python3 scripts/order_sign.py --private-key ``` ```python def main(): parser = argparse.ArgumentParser(description="Sign order-create response") parser.add_argument("--order-json", help="Order-create response JSON string") parser.add_argument("--private-key", required=True, help="Hex private key") args = parser.parse_args() ``` ### Technical Analysis The signing helper requires the complete wallet private key to be supplied as a command-line argument. Command-line arguments are not a suitable secret transport mechanism because they may be recorded or exposed through: - Shell history; - Process inspection utilities and `/proc`; - Agent command transcripts; - Terminal logging; - CI/CD logs; - Monitoring and telemetry; - Error reports or debugging output. This contradicts the Skill’s stated key-management principle of minimal privilege and no persistence. Deleting the in-process Python variable later would not remove copies retained by the shell, operating system, agent runtime, or logging infrastructure. ### Attack Path 1. A user or agent follows the documented command and includes the wallet private key after `--private-key`. 2. The shell, agent runtime, or process table records the command-line argument. 3. A local process, administrator, monitoring service, transcript reader, or later log consumer accesses the recorded argument. 4. The attacker extracts the private key. 5. The attacker imports the key into another wallet and signs arbitrary transactions independently of the Skill’s confir ...[truncated 507 chars]
Remediation
View remediation

T03 · Remote Payload Retrieval and Execution

Error
Location
SKILL.md:25
Finding

Mutable Remote Self-Update Replaces Audited Skill Code and Instructions

Content
View full analysis
Remediation
View remediation

T07 · Tool Hijacking and Spoofing

Error
Location
SKILL.md:797
Finding

Secret Retrieval Workflow Executes an Unverified Relative-Path Helper

Content
View full analysis
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
README.md:159
Finding

Unpinned and Incompletely Declared Python Dependencies

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (24)

Tainted flow: 'headers' from os.environ.get (line 65, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/bitget_api.py (reported line 76)May include surrounding context.

python
headers["Partner-Code"] = os.environ.get("BGW_PARTNER_CODE", DEFAULT_PARTNER_CODE)

    try:
        resp = requests.post(url, data=body_str if body_str else None, headers=headers, timeout=30)
        if resp.status_code != 200:
            return {"error": f"HTTP {resp.status_code}", "message": resp.text[:500]}
        return resp.json()

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The documented behavior includes private-key handling and direct signing of API-provided hashes via unsafe_sign_hash, which is materially more sensitive than the declared token-info and quote functionality. Hidden signing capability is especially dangerous because it can authorize asset transfers or approvals under the guise of a data-retrieval skill.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The documented behavior includes private-key handling and direct signing of API-provided hashes via unsafe_sign_hash, which is materially more sensitive than the declared token-info and quote functionality. Hidden signing capability is especially dangerous because it can authorize asset transfers or approvals under the guise of a data-retrieval skill.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The skill is framed as an API client for market data and quotes, yet it operationally supports trade execution by creating orders, preparing calldata, signing, and broadcasting transactions. This is a scope deception issue: reviewers or users may invoke it expecting passive information access while it can actively move funds.

Content

No source excerpt is available for this finding.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

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

md
8. Token safety status
9. EIP-712 verification (domain, msgSender, calls summary)

**Gas mode display rules:**
- Gasless with 7702 bound → "Gasless ✅ (EIP-7702 已绑定)"
- Gasless first time → "Gasless ✅ (EIP-7702 首次绑定, 2 signatures)"
- User override → "User Gas (native token)"

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The documentation instructs the agent to retrieve a private key from local secrets tooling and use it for transaction and hash signing. Embedding secret-retrieval and signing workflows inside a broadly described API skill greatly increases the blast radius: compromise of the skill or upstream API responses could lead to direct wallet authorization and loss of assets.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill metadata frames the capability as market data, token info, quotes, and security checks, but the implementation also supports creating swap orders, submitting signed transactions, and broadcasting them to a third-party API. That hidden expansion from informational queries into transaction execution materially increases risk because an agent or user may invoke the skill without understanding it can facilitate real asset movement.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The swap-send command broadcasts raw signed transactions to an external endpoint and lacks any explicit confirmation or strong warning despite directly enabling on-chain execution. In the context of a wallet-integrated crypto skill, this is especially dangerous because signed raw transactions are effectively authorization artifacts; once relayed, funds can move irreversibly.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

This file introduces transaction and hash-signing behavior that exceeds the skill's stated purpose of market data, token info, quotes, and security checks. In practice, this enables the skill to turn API-supplied payloads into user-authorized signatures, which can be abused to approve malicious swaps, permits, or arbitrary blockchain actions if the upstream response is tampered with or overly trusted.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The script accepts a raw private key and uses it to sign either arbitrary hashes or full transactions derived from external input. Handling raw keys inside a market-data skill is highly dangerous because compromise of the skill, logs, shell history, pipelines, or upstream API responses can directly lead to unauthorized blockchain transactions and irreversible fund loss.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill declares no explicit tool scope or permission boundaries even though its content clearly requires network access and environment/secret access. In a skill that can fetch remote content, use API credentials, and participate in trading workflows, missing scope declarations increase the risk of overbroad execution and make review, sandboxing, and policy enforcement harder.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs the agent to fetch remote files from GitHub and replace local skill files as part of an upgrade flow. This creates a remote self-modification path that can bypass normal review controls and introduces supply-chain risk if the repository, branch, or transport is compromised.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% 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.

Content

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

md
### Pre-Trade Workflow

Before executing any swap, the agent should silently run risk checks and then present a **single confirmation summary** to the user. Do not prompt the user at every step.

**Behind the scenes (agent runs automatically):**

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The markdown includes a prescribed status message of "等待确认..." for user output, which forces a specific language in at least one user-facing flow. The file does not state that responses should follow the user's preferred language or provide an opt-in for Chinese output, so this conflicts with the locale-choice policy.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The instruction says the user must explicitly say "yes" / "confirm" / "执行", embedding a specific non-default language token into the confirmation policy. Because no language selection or multilingual rationale is provided, this is a natural-language locale policy issue.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
85% 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.

Content

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

md
**Why this order matters:**
- order-create before present: user sees real order data, not just estimates
- order-status for toAmount: more accurate than quote (accounts for actual routing)
- present before sign: user controls their funds, agent doesn't auto-execute
- **Skipping the confirmation step is a violation of the agent's operating rules**

**Completion message (same-chain):**

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

The instruction to always default to gasless and not ask the user to choose preselects a financially and trust-significant execution mode. Even if later confirmation is required, auto-opting into a relayer-mediated signing flow changes trust assumptions and fee behavior without obtaining specific informed consent for that mode.

Content

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

md
#### Gas Mode: Default to Gasless

**Always default to gasless** — pass `--feature no_gas` to `order-create` on every trade. Do not check `features` field first, do not ask the user to choose.

**How to detect gasless success vs fallback:**
- Response has `signatures` array (non-empty) → gasless mode active ✅

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The example output hard-codes Chinese text ("gas 从输入金额扣除,小额交易 gas 占比较高") in a confirmation summary the user is expected to see. Since the skill does not frame this as region-specific or user-selected localization, it imposes a specific language/locale.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This line presents another required-looking user-facing warning in Chinese within the confirmation flow. Without any instruction to localize based on user preference, it effectively forces a specific language in normal operation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The display rules explicitly define Chinese phrases like "已绑定" and "首次绑定" for user-visible gas mode labels. This is a policy concern because it mandates a locale-specific output style absent user opt-in or a documented regional scope.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
88% confidence
Finding

The skill directs the agent to check allowance and send an approval transaction when needed, which is an asset-authorizing action. Although approval is operationally necessary for ERC-20 swaps, it is still a sensitive blockchain permission change and should not be automated implicitly because approvals can enable later token spending by a router contract.

Content

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

md
### EVM Token Approval (Critical)

On EVM chains (Ethereum, BNB Chain, Base, Arbitrum, Optimism), tokens require an **approve** transaction before the router contract can spend them. **Without approval, the swap transaction will fail on-chain and still consume gas fees.**

- Before calling `swap-calldata`, check if the token has sufficient allowance for the BGW router (`0xBc1D9760bd6ca468CA9fB5Ff2CFbEAC35d86c973`).
- If allowance is 0 or less than the swap amount, an approve transaction must be sent first.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The order submission path sends signed transaction blobs to an external API endpoint with only a generic command description and no explicit warning that the data authorizes on-chain actions. Even if the transactions are already signed, forwarding them to a remote service can trigger execution, leak sensitive transaction intent, and reduce the user's control over when and where the transaction is submitted.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The docstring frames the helper as only signing API-provided hashes without recomputing EIP-712 data, but the implementation also signs full raw transactions. That mismatch is security-relevant because it can mislead reviewers or users into underestimating the authority granted to the script, reducing scrutiny around a capability that can directly transfer assets or set approvals.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script takes the private key as a command-line argument, which commonly exposes secrets through shell history, process listings, CI logs, and pipeline telemetry. Even if the signing logic were legitimate, this handling materially increases the chance of credential leakage and subsequent wallet compromise.

Content

No source excerpt is available for this finding.