Back to skill

Security audit

Agentic X402

Security checks for vulnerabilities and agentic risk

Overview

This skill is not clearly malicious, but it should be reviewed carefully because it can automatically spend cryptocurrency while storing raw wallet keys and its advertised payment limits are not reliably enforced.

Install only with a dedicated low-balance wallet, preferably on testnet first. Avoid using x402 fetch or unattended pay flows for untrusted URLs until payment-limit enforcement is fixed, and do not expose the private key in agent transcripts, terminal logs, screenshots, or shell history.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/commands/fetch-paid.ts:65
Finding

Automatic Fetch Performs Payments Without Enforcing the Configured Spending Limit

Content
View full analysis
0 ? headers : undefined, }); ``` ### Technical Analysis The `fetch` command passes an arbitrary user-supplied URL directly to the x402 payment wrapper. If the endpoint returns an HTTP 402 response, the wrapper can create a signed payment authorization automatically. This execution path neither reads nor enforces `X402_MAX_PAYMENT_USD`. It also provides no command-specific maximum to the payment wrapper. Consequently, the documented default limit of USD 10 does not protect payments initiated through `x402 fetch`. Because enforcement is absent at the signing boundary, a malicious or compromised resource server can request a substantially larger payment than the user or agent expects. ### Attack Path 1. An attacker hosts an HTTP endpoint that returns a valid x402 payment requirement with an excessive amount. 2. The user or agent executes `x402 fetch https://attacker.example/resource`. 3. `fetchWithPayment` processes the HTTP 402 response automatically. 4. No application-level amount validation occurs before signing. 5. The wallet signs the payment authorization, subject only to any protections provided externally by the SDK or available wallet balance. 6. The attacker settles the authorization and receives the requested funds. ### Impact Assessment Successful exploitation can cause unauthorized or unexpectedly large USDC payments from the configured wallet. The practical scope is limited by the wallet balance, protocol authorization constraints, and any independent SDK-level restrictions, but the project itself does not enforce its advertised USD 10 ...[truncated 142 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/commands/pay.ts:126
Finding

Payment Limit Check Fails Open and Is Not Bound to the Signed Requirement

Content
View full analysis
effectiveMax) { console.error(`Payment of ${formatUsd(priceNum)} exceeds max limit of ${formatUsd(effectiveMax)}`); console.error('Use --max to increase the limit if desired.'); process.exit(1); } if (dryRun) { console.log('Dry run - payment not executed.'); console.log(`Would pay: ${formatUsd(priceNum)}`); return; } // Make payment request using x402 wrapped fetch console.log('Processing payment...'); const response = await client.fetchWithPayment(url, { ``` ### Technical Analysis The limit check fails open in several ways: 1. If `priceStr` is absent or malformed, `parseFloat` returns `NaN`. 2. JavaScript evaluates `NaN > effectiveMax` as `false`, allowing execution to continue. 3. The configured or command-line maximum is itself not checked with `Number.isFinite`, so values such as `NaN` can also disable the comparison. 4. Only `paymentInfo.accepts[0]` is inspected. 5. After validation, `fetchWithPayment` makes another request. The validated payment requirement is not passed to or cryptographically bound to that signing operation. 6. A server can therefore change the payment requirement between the initial inspection and the wrapped payment request. The local comparison is consequently not a reliable authorization control. ### Attack Path 1. A malicious endpoint responds to the initial request with a malformed, missing, deceptively low, or otherwise check-bypassing first payment offer. 2. `parseFloat` produces `NaN` or a value below the confi ...[truncated 817 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
bin/cli.ts:129
Finding

CLI Executes a Mutable Runtime Package Through npx

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/commands/setup.ts:174
Finding

Wallet Setup Exposes Private Keys Through Echoed Input, Terminal Output, and Return Values

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (81)

Credential Access

High
Category
Privilege Escalation
Confidence
91% confidence
Finding

The README explicitly tells users to display their private key in plaintext with cat ~/.x402/.env | grep EVM_PRIVATE_KEY. In agentic or logged environments, this can leak the wallet key into shell history, terminal scrollback, telemetry, screenshots, CI logs, or LLM conversation context, enabling full wallet compromise.

Content

Scanner excerpt · README.md (reported line 290)May include surrounding context.

View Your Private Key

bash
cat ~/.x402/.env | grep EVM_PRIVATE_KEY

Recovery

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill’s headline purpose emphasizes paying for gated resources, but the document also instructs users to generate/import a private key, persist it to ~/.x402/.env, back it up, display it, and restore it. Those sensitive key-management operations materially increase risk beyond a simple payment/fetch utility because compromise of the local environment exposes direct control over funds.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The skill’s headline purpose emphasizes paying for gated resources, but the document also instructs users to generate/import a private key, persist it to ~/.x402/.env, back it up, display it, and restore it. Those sensitive key-management operations materially increase risk beyond a simple payment/fetch utility because compromise of the local environment exposes direct control over funds.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The skill’s headline purpose emphasizes paying for gated resources, but the document also instructs users to generate/import a private key, persist it to ~/.x402/.env, back it up, display it, and restore it. Those sensitive key-management operations materially increase risk beyond a simple payment/fetch utility because compromise of the local environment exposes direct control over funds.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

The skill instructs users to place an EVM private key in a plaintext ~/.x402/.env file. Even with 600 permissions, storing raw signing keys in a predictable on-disk location creates substantial theft risk from local compromise, backups, shell history mistakes, or other tools with file access; in this skill context that directly exposes cryptocurrency funds.

Content

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

bash
mkdir -p ~/.x402
echo "EVM_PRIVATE_KEY=0x..." > ~/.x402/.env
chmod 600 ~/.x402/.env

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

This step completes persistence of the private key to disk and normalizes a sensitive secret-handling pattern that is risky for automated agents. The combination of autonomous network payment behavior and locally accessible signing material makes compromise more damaging than in ordinary app configuration.

Content

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

bash
mkdir -p ~/.x402
echo "EVM_PRIVATE_KEY=0x..." > ~/.x402/.env
chmod 600 ~/.x402/.env

Verify setup:

Credential Access

High
Category
Privilege Escalation
Confidence
89% confidence
Finding

Creating an encrypted backup of ~/.x402/.env is safer than plaintext backup, but it still encourages packaging the raw private key into files that may be copied, synced, or mishandled. The danger is moderate because encryption reduces risk, yet the underlying practice still centers on exportable raw key material.

Content

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

  1. Encrypted File
    bash
    # Encrypt with GPG
    gpg -c ~/.x402/.env
    # Creates ~/.x402/.env.gpg - store this backup securely
    

Credential Access

High
Category
Privilege Escalation
Confidence
99% confidence
Finding

The documentation explicitly tells the user how to display the private key with cat | grep. Printing a wallet private key to terminal output is dangerous because it may be captured in logs, terminal scrollback, screen recordings, remote session tools, or observed by other software; for this skill, exposure means full wallet compromise.

Content

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

View Your Private Key

bash
cat ~/.x402/.env | grep EVM_PRIVATE_KEY

Recovery

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

Recovery instructions again place a raw private key into a plaintext file in a known location. This repeats the core secret-management weakness and makes wallet compromise straightforward if the host or user workflow is insecure.

Content

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

To restore from backup:

bash
mkdir -p ~/.x402
echo "EVM_PRIVATE_KEY=0x...your_backed_up_key..." > ~/.x402/.env
chmod 600 ~/.x402/.env
x402 balance  # verify

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

This line is part of the same plaintext key-restoration flow and reinforces persistence of credential material on disk. Because this skill authorizes crypto payments, compromise of the stored secret directly enables unauthorized fund movement.

Content

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

bash
mkdir -p ~/.x402
echo "EVM_PRIVATE_KEY=0x...your_backed_up_key..." > ~/.x402/.env
chmod 600 ~/.x402/.env
x402 balance  # verify

Lp1

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'env' capability that is not listed in its permissions. This may indicate deceptive intent or missing permission declarations.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · README.md (reported line 58)May include surrounding context.

md
# x402 Agent Skill Configuration
# Copy this file to .env in your working directory

# =============================================================================
# REQUIRED: Wallet Configuration

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · README.md (reported line 59)May include surrounding context.

md
# x402 Agent Skill Configuration
# Copy this file to .env in your working directory

# =============================================================================
# REQUIRED: Wallet Configuration

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · README.md (reported line 279)May include surrounding context.

md
# x402 Agent Skill Configuration
# Copy this file to .env in your working directory

# =============================================================================
# REQUIRED: Wallet Configuration

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · README.md (reported line 297)May include surrounding context.

md
# x402 Agent Skill Configuration
# Copy this file to .env in your working directory

# =============================================================================
# REQUIRED: Wallet Configuration

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · README.md (reported line 298)May include surrounding context.

md
# x402 Agent Skill Configuration
# Copy this file to .env in your working directory

# =============================================================================
# REQUIRED: Wallet Configuration

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · config/example.env (reported line 2)May include surrounding context.

text
# x402 Agent Skill Configuration
# Copy this file to .env in your working directory

# =============================================================================
# REQUIRED: Wallet Configuration

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · scripts/core/config.ts (reported line 11)May include surrounding context.

ts
# x402 Agent Skill Configuration
# Copy this file to .env in your working directory

# =============================================================================
# REQUIRED: Wallet Configuration

Lp1

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'network' capability that is not listed in its permissions. This may indicate deceptive intent or missing permission declarations.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
87% confidence
Finding

The script stores an EVM private key in a plaintext ~/.x402/.env file, making credential persistence a real secret-exposure risk if the host is compromised, backups are synced insecurely, or other tools read env-style files. Because this skill is specifically for making automated payments, compromise of that file directly enables unauthorized transaction signing and fund theft.

Content

Scanner excerpt · scripts/commands/setup.ts (reported line 13)May include surrounding context.

ts
// Global config directory: ~/.x402/
const CONFIG_DIR = path.join(homedir(), '.x402');
const CONFIG_PATH = path.join(CONFIG_DIR, '.env');

interface SetupResult {
  success: boolean;

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

At this location the script constructs and writes the full private key into the config file content, confirming actual credential material is persisted to disk rather than merely referencing a config path. In this context, the risk is heightened because the same setup flow also displays the private key to the console for new wallets, increasing opportunities for leakage through shell history, logs, screenshots, or terminal capture.

Content

Scanner excerpt · scripts/commands/setup.ts (reported line 202)May include surrounding context.

ts
ensureConfigDir();

  const envContent = `# x402 Agent Skill Configuration
# Location: ~/.x402/.env
# Created: ${new Date().toISOString()}
#
# WARNING: Keep this file secret! Never share your private key!

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · scripts/core/config.ts (reported line 13)May include surrounding context.

ts
// Priority: env vars > local .env > global ~/.x402/.env
  const envPaths = [
    resolve(globalConfigDir, '.env'),
    resolve(cwd, '.env'),
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · scripts/core/config.ts (reported line 14)May include surrounding context.

ts
// Priority: env vars > local .env > global ~/.x402/.env
  const envPaths = [
    resolve(globalConfigDir, '.env'),
    resolve(cwd, '.env'),
  ];

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · README.md (reported line 30)May include surrounding context.

Configure

Run the interactive setup to create a new wallet:

bash
x402 setup

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · README.md (reported line 275)May include surrounding context.

  1. Password Manager (Recommended)

    • Store in 1Password, Bitwarden, or similar
    • Create a secure note with your private key
  2. Encrypted File

    bash

Static analysis

Detected: suspicious.dangerous_exec, suspicious.exposed_secret_literal

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
bin/cli.ts:133

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
bin/x402.js:37

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
scripts/commands/setup.ts:148