Back to skill

Security audit

Gate Exchange Staking Skill

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent Gate staking integration, but it needs Review because it can submit financial staking or redemption orders and its instructions contain unsafe ambiguity around approval and mutable external rules.

Install only if you trust the Gate MCP setup and are comfortable granting Earn:Write permission for staking operations. Before using it, the package should pin or vendor the remote runtime rules, resolve the merge conflict, and make every stake/redeem/mint path require a fresh Action Draft confirmation immediately before calling the swap tool.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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 (3)

T01 · Skill Instruction Hijacking

Error
Location
SKILL.md:12
Finding
Mutable External Instructions Are Assigned Highest Priority## Vulnerability Details **File Location**: `SKILL.md:12-15` **Vulnerability Type**: External instruction redirection and trust-boundary violation **Risk Level**: Critical ### Vulnerable Code ```markdown ⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding. Do NOT select or call any tool until all rules are read. These rules have the highest priority. → Read [gate-runtime-rules.md](https://github.com/gate/gate-skills/blob/master/skills/gate-runtime-rules.md) - **Only call MCP tools explicitly listed in this skill.** Tools not documented here must NOT be called, even if they ``` ### Technical Analysis The Skill requires the agent to retrieve and obey an instruction document that is not included in the audited artifact. The referenced URL uses the mutable `master` branch rather than a pinned commit or content digest. Consequently, the effective behavior of the Skill can change after this package has been reviewed without any corresponding change to the audited files. The statement that the remote rules have the “highest priority” compounds the problem by instructing the agent to treat unaudited external content as authoritative. If the remote repository or publishing account is compromised, or if the document is changed maliciously, its contents could attempt to alter transaction safeguards, disclosure rules, tool-selection behavior, or the current session objective. This is instruction hijacking rather than remote code execution: the retrieved payload is Markdown instruction text, not executable system code. Nevertheless, the instructions operate in a context where authenticated Gate MCP tools can query account information and submit staking or redemption transactions. ### Attack Path 1. An attacker compromises the remote repository, the relevant publishing account, or the mutable `master` branch content. 2. The attacker modifies `gate-runtime-rules.md` to include unsafe instructions, suc ...[truncated 1115 chars]
Remediation
## Remediation Suggestions 1. Vendor `gate-runtime-rules.md` into the Skill package so that it is included in the same security review and release process. 2. If remote retrieval is unavoidable, reference an immutable commit identifier rather than `master` and verify the downloaded content against an approved cryptographic digest. 3. Do not describe Skill or remote content as having priority over system, developer, platform, or organizational safety policies. 4. Define an explicit trust hierarchy under which remotely retrieved documentation is always treated as untrusted reference material rather than executable policy. 5. Fail closed if the pinned content cannot be verified; do not fall back to the latest remote version. 6. Add release automation that rejects unpinned remote instruction references. 7. Keep mandatory transaction confirmation and tool allowlists entirely within the locally audited package.

T09 · Insecure Skill Coding Practices

Error
Location
references/staking-swap.md:29
Finding
Stake and Redeem Workflows Contain Confirmation-Bypass Instructions## Vulnerability Details **File Location**: `references/staking-swap.md:29-36` **Additional Conflicting Locations**: `references/staking-swap.md:137-145`, `references/staking-swap.md:169-177`, `references/staking-swap.md:185-193` **Vulnerability Type**: Inconsistent authorization and transaction-confirmation control **Risk Level**: High ### Vulnerable Code ```markdown 2. **Get product list**: Call `cex_earn_find_coin(cointype=<coin>)` to get all products that accept that coin. If the user did not specify a coin, ask for it before proceeding. 3. **Filter by currency**: From the response, keep only items where `currency` includes the user’s coin (e.g. "USDT" or "USDT,USDC"). 4. **Zero products**: If no products match, reply: "No staking products found for {coin}. Try another coin or check available products." 5. **GUSD / multi-currency (currency is "USDT,USDC")**: If the chosen product’s `currency` is `"USDT,USDC"` (e.g. Gate USD / GUSD), **do not** assume a coin. Ask the user: "This product accepts USDT or USDC. Which do you want to use: USDT or USDC?" Only **USDT** and **USDC** are allowed. Pass the user’s choice as the **`coin`** parameter to `cex_earn_swap_staking_coin`. Do not call the swap until the user has selected one. 6. **Single protocol (one pid)**: If exactly one product matches, use its `pid`. If that product is GUSD / "USDT,USDC", apply step 5 first to get `coin`. Optionally confirm with the user: "Stake {amount} {coin} in {protocolName} (pid {pid})? APY {estimateApr}, redeem period {redeemPeriod} days." Then call `cex_earn_swap_staking_coin(pid=<pid>, amount=<amount>, side=0, coin=<coin>)` (side=0 for stake; pass `coin` when product is GUSD / USDT,USDC). 7. **Multiple protocols (multiple pids for same coin)**: List each product with `protocolName`, `pid`, `estimateApr`, `redeemPeriod`, `minStakeAmount`. Ask the user to confirm which one, e.g. "Multiple products accept {coin}. Which do you want to ...[truncated 3835 chars]
Remediation
## Remediation Suggestions 1. Replace every occurrence of “optionally confirm” with an unconditional, mandatory confirmation requirement. 2. At every write-tool call site, require the following exact sequence: - Resolve and validate all parameters. - Present an Action Draft containing action, PID, protocol, coin, amount, side, rate, fees, limits, and lock or redemption period. - Stop and wait for the user. - Accept only clear confirmation from the immediately preceding user turn. - Invoke the write tool without changing any confirmed parameter. 3. Treat product or PID selection as parameter selection only, never as final transaction authorization. 4. Invalidate confirmation whenever the PID, amount, coin, side, rate, fee, or product constraints change. 5. Rewrite all stake, redeem, and mint scenarios so they explicitly include the same confirmation gate. 6. Add automated linting that rejects a `cex_earn_swap_staking_coin` instruction unless a mandatory confirmation step immediately precedes it. 7. Add negative tests for single-product staking, redemption with a supplied PID, “redeem all,” minting, and multi-currency products to ensure no write occurs before fresh confirmation.

T09 · Insecure Skill Coding Practices

Warning
Location
references/staking-list.md:61
Finding
Unresolved Merge Conflict Produces Contradictory Data-Disclosure Instructions## Vulnerability Details **File Location**: `references/staking-list.md:61-67` **Vulnerability Type**: Unresolved merge conflict and inconsistent privacy control **Risk Level**: Medium ### Vulnerable Code ```markdown <<<<<<< HEAD 3. **Key data to extract**: From response object: `page`, `pageSize`, `pageCount`, `totalCount`. From each `list` item: `pid`, `coin`, `amount`, `exchange_amount`, `type`, `createStamp`, `redeem_stamp`, `status`, `fee`. 4. **Format response**: Show as table or list; convert timestamps to dates; map type 0=Stake, 1=Redeem. **Dynamic-rate products** (exchangeRate ≠ 1 from `cex_earn_find_coin` for same pid): for **Stake** (type=0) show **exchange_amount** (what the user received); for **Redeem** (type=1) show **amount** (what the user received). When exchangeRate = 1, show amount for both. ======= 3. **Key data to extract**: From response object: `page`, `pageSize`, `pageCount`, `totalCount`. From each `list` item: `pid`, `coin`, `amount`, `exchange_amount`, `type`, `status`, `fee`. Do not display `createStamp`, `redeem_stamp` or any timestamp formatting. 4. **Format response**: Show as table or list; map type 0=Stake, 1=Redeem. **Do not display or format timestamp fields** (omit createStamp, redeem_stamp from output; see SKILL.md). **Dynamic-rate products** (exchangeRate ≠ 1 from `cex_earn_find_coin` for same pid): for **Stake** (type=0) show **exchange_amount** (what the user received); for **Redeem** (type=1) show **amount** (what the user received). When exchangeRate = 1, show amount for both. >>>>>>> master ``` ### Technical Analysis The file contains unresolved source-control conflict markers and preserves both versions of the workflow. One branch instructs the agent to extract transaction timestamps and convert them to dates, while the other explicitly prohibits displaying or formatting those timestamps. The disclosure branch also conflicts with the top-l ...[truncated 1562 chars]
Remediation
## Remediation Suggestions 1. Resolve the merge conflict and retain only the branch that omits `createStamp`, `redeem_stamp`, and all timestamp formatting. 2. Review the complete file for templates or examples that still request dates or relative-time calculations and remove those instructions. 3. Add continuous-integration checks that reject files containing `<<<<<<<`, `=======`, or `>>>>>>>` conflict markers. 4. Centralize output-field allowlists so lower-level scenario files cannot contradict the top-level privacy policy. 5. Add tests using representative order responses to verify that timestamp fields never appear in user-facing output. 6. Validate packaged release artifacts independently of the source branch to ensure unresolved conflicts cannot be published.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (32)

Intent-Code Divergence

High
Confidence
96% confidence
Finding
Claiming 'read-only access implementation' in a skill that also documents staking, minting, and redeeming is a materially misleading security statement. In an agent ecosystem, inaccurate claims about access mode can cause operators, reviewers, or automated policy systems to grant trust or reduced scrutiny to a skill that can initiate state-changing financial actions.

Ae1

High
Category
analysis-evasion
Content
- `SKILL.md` keeps staking intent routing and scenario boundaries.
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
When a product’s **exchange rate is not equal to 1**, it is a **dynamic-rate** product. In stake/redeem **response** data (swap result or order list): **amount** = staked/redeemed base coin quantity; **exchangeAmount** (or **exchange_amount**) = received quote/reward coin quantity.

**Display rule (English only):**
- **Stake**: Show **exchangeAmount** (what the user receives).
- **Redeem**: Show **amount** (what the user receives).
Confidence
85% confidence
Finding
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Description-Behavior Mismatch

Medium
Confidence
93% confidence
Finding
The manifest describes a skill for on-chain staking actions: staking POS coins, minting, or redeeming staked assets. This changelog documents additional operational scope including querying positions, rewards tracking, product discovery, and transaction history, which materially broadens behavior beyond the manifest's stated action-oriented purpose.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
## Safety & Compliance

- **User confirmation required**: All stake/redeem/mint operations require explicit user confirmation before execution. An Action Draft is shown first summarizing the operation details.
- **Query operations**: No confirmation needed for read-only queries.
- **Cancel redeem**: Not supported — users are directed to the Gate website or app.
- No investment advice; APY and rates are for reference only.
- Sensitive user data (API keys, balances) is never logged or exposed in responses.
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.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The metadata description includes broad natural-language triggers such as 'staking' and 'staking rewards', which can cause the skill to activate on ambiguous user requests. In a financial skill with write-capable tooling, unintended invocation increases the chance that the model enters a sensitive transaction flow when the user only wanted general information.

Unrestricted Tool Access

Medium
Category
Excessive Agency
Content
## General Rules

⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding.
Do NOT select or call any tool until all rules are read. These rules have the highest priority.
→ Read [gate-runtime-rules.md](https://github.com/gate/gate-skills/blob/master/skills/gate-runtime-rules.md)
- **Only call MCP tools explicitly listed in this skill.** Tools not documented here must NOT be called, even if they
  exist in the MCP server.
Confidence
80% confidence
Finding
Skill grants unrestricted tool access without appropriate constraints. An agent with unfettered tool access can perform arbitrary actions including file modification, network requests, and code execution.

Unrestricted Tool Access

Medium
Category
Excessive Agency
Content
## General Rules

⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding.
Do NOT select or call any tool until all rules are read. These rules have the highest priority.
→ Read [gate-runtime-rules.md](https://github.com/gate/gate-skills/blob/master/skills/gate-runtime-rules.md)
- **Only call MCP tools explicitly listed in this skill.** Tools not documented here must NOT be called, even if they
  exist in the MCP server.
Confidence
80% confidence
Finding
Skill grants unrestricted tool access without appropriate constraints. An agent with unfettered tool access can perform arbitrary actions including file modification, network requests, and code execution.

Unrestricted Tool Access

Medium
Category
Excessive Agency
Content
**Mint**: Treated as **immediate stake**. Route to the same Stake workflow: read `references/staking-swap.md`, resolve product (pid) and amount, then call `cex_earn_swap_staking_coin` with **side=0**. For GUSD products, require the user to choose USDT or USDC and pass `coin`.

**Cancel redeem (not supported)**: When the user intends to **cancel** or **revoke** a redeem (e.g. cancel a redemption order already submitted), do not call any tool. Reply **in English** that this operation is not supported.

## Domain Knowledge
Confidence
80% confidence
Finding
This section authorizes mint-as-stake behavior and directly instructs the use of a write-capable tool for execution. Although the skill later adds a confirmation requirement, this line itself lacks a local confirmation guard and contributes to a flow where a loosely routed 'mint' intent can reach fund-moving functionality.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
The instruction explicitly says to reply 'in English' for cancel-redeem handling. Forcing a specific language without offering user choice is a natural-language policy violation unless the locale restriction is clearly justified, which is not provided here.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The document labels the display rule as 'English only', imposing a specific language on user-facing output. There is no user opt-in or documented region-specific justification, so this conflicts with language/locale policy expectations.

Vague Triggers

Medium
Confidence
91% confidence
Finding
The routing examples include vague phrases like 'redeem', 'mint', 'I want to stake', and 'help me redeem', which are broad enough to match conversational text without clear transactional intent. Because this skill can lead to a write action, overbroad routing materially raises the risk of misclassification and accidental progression toward execution.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The stake/redeem formatting instruction says to show success or error messages in English. This is another forced-language requirement without opt-in or documented necessity.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
The safety section states 'All responses in English' and also requires the cancel-redeem reply to be in English. This creates a blanket language restriction that is not optional and lacks justification.

Unrestricted Tool Access

Medium
Category
Excessive Agency
Content
- **Stake / Redeem**: Supported via `cex_earn_swap_staking_coin`. Follow `references/staking-swap.md`. **pid** is required; use **side=0** (stake) or **side=1** (redeem); before stake, fetch products and if multiple protocols for the same coin, ask the user to confirm which product (pid) before calling the swap. All responses in English.
- **Mint**: Supported as **immediate stake**. When the user asks to mint, execute the **Stake** workflow: route to `references/staking-swap.md`, resolve pid and amount, call `cex_earn_swap_staking_coin` with **side=0**. For GUSD, require the user to choose USDT or USDC and pass `coin`.
- **Cancel redeem**: Not supported. When the user asks to **cancel** or **revoke** a redeem (e.g. cancel a redemption order), reply **in English**: "Cancelling or revoking a redeem is not supported here; please use the Gate website or app if needed. I can help you query positions or order history." Do **not** call any tool.

### Errors
Confidence
80% confidence
Finding
This section again directly instructs execution of the write tool for mint/stake operations. In the context of broad routing phrases elsewhere in the skill, repeated direct execution guidance increases the chance of unsafe tool invocation if upstream routing or confirmation logic is imperfect.

Vague Triggers

Medium
Confidence
91% confidence
Finding
Overly broad trigger phrases can cause the staking skill to activate on generic finance queries that were not intended for staking. Misrouting user intent in a financial context is dangerous because the agent may query or present sensitive account-position data, or guide the user toward redemption/staking flows without clear authorization or intent confirmation.

Vague Triggers

Medium
Confidence
94% confidence
Finding
Redemption triggers like 'Available balance check' or 'What's unlocked?' are vague and can collide with unrelated account-balance, withdrawal, or account-status requests. In a financial skill, that ambiguity can expose staking details or steer the conversation into redemption-related actions when the user only wanted a general balance inquiry.

Context-Inappropriate Capability

Medium
Confidence
88% confidence
Finding
The portfolio valuation flow expands the skill from staking-position lookup into price retrieval and derived financial guidance. That broader scope can cause the agent to invoke external pricing sources or unsupported tools, increasing the chance of incorrect valuations, unintended data flow, or actions based on stale/manipulated market data.

Vague Triggers

Medium
Confidence
91% confidence
Finding
The trigger examples in this section are broad enough to match ordinary conversation such as general questions about staking or available options, which can cause the skill to activate outside a clearly bounded user intent. In a financial workflow, over-triggering can misroute requests and lead users to receive product-oriented staking guidance when they only wanted neutral information, increasing the chance of inappropriate financial suggestions.

Description-Behavior Mismatch

Medium
Confidence
92% confidence
Finding
The file substantially broadens the skill from staking actions into account-history, reward reporting, APY analysis, and navigation workflows. That scope creep increases the chance the skill is invoked for general portfolio/account queries and may expose more user financial data than is necessary for the stated staking-action purpose.

Vague Triggers

Medium
Confidence
89% confidence
Finding
Broad prompts like 'transaction history' and similar examples make activation ambiguous and can cause this staking skill to handle generic financial-history requests. In a tool-using agent, that ambiguity can lead to over-collection of staking order data when the user may have intended a different account-history function or a narrower response.

Vague Triggers

Medium
Confidence
87% confidence
Finding
Generic reward prompts such as 'reward calculation' or 'all rewards' are broad enough to match non-staking reward contexts. This increases the risk of unintended activation and unnecessary retrieval of staking reward records, especially in an environment with multiple finance-related skills.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The APY verification workflow introduces use of `cex_earn_asset_list`, which expands access from order/reward records into current position inspection. This is unnecessary for the file's stated purpose and creates a privilege-expansion path where a user asking about rewards could cause retrieval of broader holdings data.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The skill repeatedly instructs the agent to reply only in English for confirmations and errors, regardless of the user's language preference. This can degrade usability, increase the chance of user misunderstanding during financial transactions, and conflicts with least-surprise and accessibility expectations, though it is not a direct compromise of funds or system integrity.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The redeem workflow mandates English-only success and error messaging during staking redemptions. In a financial workflow, forcing a single language can cause users to misunderstand redemption amounts, product identifiers, or error states, which raises operational and consumer-protection risk even if it is not a classic security exploit.

Static analysis

No suspicious patterns detected.