Back to skill

Security audit

spanDEX Trader

Security checks for vulnerabilities and agentic risk

Overview

This is a real Base trading skill, but it needs review because it handles wallet private keys and can create persistent token approvals or sign remotely supplied order data without enough safeguards.

Install only after reviewing the financial-risk tradeoffs. Use a dedicated low-balance wallet, prefer dry-run and quote commands first, verify token addresses, amounts, chain, slippage, spender addresses, and order terms before any live action, and be prepared to revoke ERC-20 approvals after use. Avoid putting a valuable private key in shell history or broad environment scope, and prefer pinned dependencies or a reviewed lockfile before running the npm install step.

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 (5)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/spandex_trade.mjs:499
Finding

Remote EIP-712 Order Data Is Signed Without Local Intent Validation

Content
View full analysis
r.json()); if (signMsgRes.code !== 0) die(`KyberSwap sign-message failed: ${signMsgRes.message}`); const eip712Data = signMsgRes.data; // Sign + submit const signature = await walletClient.signTypedData({ domain: { ...eip712Data.domain, chainId: parseInt(eip712Data.domain.chainId) }, types: { Order: eip712Data.types.Order }, primaryType: 'Order', message: eip712Data.message, }); const createRes = await fetch(`${KYBER_LO_DOMAIN}/write/api/v1/orders`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ...unsignedBody, salt: eip712Data.message.salt, signature }), }).then(r => r.json()); ``` The same pattern is used when canceling an order: ```js const cancelSignRes = await fetch(`${KYBER_LO_DOMAIN}/write/api/v1/orders/cancel-sign`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ chainId: '8453', maker: account.address, orderIds: [parseInt(args['order-id'])] }), }).then(r => r.json()); if (cancelSignRes.code !== 0) die(`KyberSwap cancel-sign failed: ${cancelSignRes.message}`); const eip712Data = cancelSignRes.data; const signature = await walletClient.signTypedData({ domain: { ...eip712Data.domain, chainId: parseInt(eip712Data.domain.chainId) }, types: { CancelOrder: eip712Data.types.CancelOrder }, primaryType: 'CancelOrder', message: eip712Data.message, }); const cancelRes = await fetch(`${KYBER_LO_DOMAIN}/write/api/v1/orders/cancel`, { method: 'POST', headers: { 'Content-Type': 'applicatio ...[truncated 1938 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/spandex_trade.mjs:350
Finding

Persistent Unlimited Token Allowances Exceed Required Trading Privileges

Content
View full analysis
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/spandex_trade.mjs:210
Finding

Read-Only Operations Unnecessarily Load the Wallet Private Key

Content
View full analysis
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
SKILL.md:20
Finding

Unpinned Runtime Dependency Installation Creates Supply-Chain Exposure

Content
View full analysis
/scripts && npm init -y && npm i viem @spandex/core ``` ### Technical Analysis The setup instructions initialize a new package dynamically and install the latest versions of `viem` and `@spandex/core`. The project does not provide a reviewed manifest and lockfile in the audited directory. As a result, the dependency graph can change between installations. npm packages may also execute lifecycle scripts during installation. This is especially sensitive because the resulting modules execute in a process that may load a wallet private key and construct or sign asset-transfer transactions. No malicious package was identified in the audited files; the issue is the unsafe, mutable installation mechanism. ### Attack Path 1. An attacker compromises a dependency publisher, npm account, package release process, or transitive dependency. 2. A malicious version is published before a user follows the setup instructions. 3. `npm i viem @spandex/core` resolves and installs the affected version. 4. Malicious lifecycle or runtime code executes in the Skill environment. 5. The code can access environment variables, key files readable by the process, RPC configuration, or transaction data. 6. It may exfiltrate credentials or alter transaction destinations and approval parameters. ### Impact Assessment A successful supply-chain compromise would execute with the permissions of the user running the Skill. Because the process handles wallet signing credentials, the potential impact includes private-key theft, arbitrary local file access within user permissions, transaction manipulation, and wallet asset loss. ]]>
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/spandex_trade.mjs:158
Finding

User-Supplied Slippage Is Accepted Without Safety Bounds

Content
View full analysis
t.address.toLowerCase()); const isMajorSell = majorTokens.includes(sellAddress.toLowerCase()); const isMajorBuy = majorTokens.includes(buyAddress.toLowerCase()); if (!isMajorSell && !isMajorBuy) return 500; // 5% microcap↔microcap if (!isMajorSell || !isMajorBuy) return 300; // 3% major↔microcap return 50; // 0.5% major↔major } ``` The returned value is placed into swap parameters: ```js const slippageBps = getSlippageBps(args, sellInfo.address, buyInfo.address); const strategy = args.strategy || DEFAULT_STRATEGY; ``` ### Technical Analysis The `--slippage` argument is parsed with `parseInt()` but is not checked for: - A finite integer result - Non-negative value - Basis-point range - A conservative maximum - Trailing invalid characters A very large slippage value weakens minimum-output protections and can permit execution at a substantially worse price than the user reasonably expects. Depending on downstream validation, malformed values may also cause provider failures or inconsistent behavior. ### Attack Path 1. A user, automation layer, or untrusted command generator supplies an excessive value such as a very large number of basis points. 2. `parseInt()` accepts the value without enforcing an upper bound. 3. The value is included in quote and swap parameters. 4. The transaction is built with weak price protection if accepted by the provider. 5. Market movement, low liquidity, price manipulation, or sandwich activity causes execution at an unfavorable rate. 6. T ...[truncated 315 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (15)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/spandex_trade.mjs quote --sell USDC --buy 0xTOKEN --amount 50

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill describes execution features like automatic fallback, quote racing, and transaction submission but does not prominently warn that swaps and limit-order actions are irreversible, may incur gas costs, and can result in loss from slippage or wrong token selection. In the context of an on-chain trading skill handling private keys, missing such warnings increases the likelihood of unsafe user authorization and accidental financial loss.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
80% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/spandex_trade.mjs (reported line 100)May include surrounding context.

js
try {
      return fs.readFileSync(KEY_PATH, 'utf8').trim();
    } catch (e) {
      die(`Cannot read private key from ${KEY_PATH}: ${e.message}`);
    }
  }
  die('Set SPANDEX_PRIVATE_KEY (hex) or SPANDEX_KEY_PATH (file) env var');

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill requires access to environment variables and networked execution to install dependencies, read a private key, query quotes, and submit transactions, but it declares no explicit tool scope or permissions. In an agent setting, this can lead to the skill being invoked with broader-than-intended capabilities, increasing the chance of secret exposure or unauthorized on-chain actions.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger list includes very broad terms such as "buy," "sell," "swap," and "trade," which can match many unrelated conversations and cause unintended activation of a skill capable of executing blockchain transactions. Because this skill can place orders and spend wallet funds, accidental routing is materially more dangerous than for a read-only skill.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
81% confidence
Finding

This function loads a raw private key from SPANDEX_PRIVATE_KEY or from a file path in SPANDEX_KEY_PATH, which is a safety-sensitive credential operation. While the code comments describe precedence, there is no user-facing warning in the CLI usage or output about the sensitivity of these inputs or the need to protect them.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The swap path explicitly builds calls with allowanceMode: 'unlimited', which can leave a standing ERC-20 approval after the immediate trade completes. If the approved spender or routing contract is later compromised, upgraded maliciously, or misused, it may drain all approved tokens from the wallet without further user consent. In a trading skill that executes live on-chain transactions, this is more dangerous because approvals are likely to be exercised against real user funds.

Content

No source excerpt is available for this finding.