Back to skill

Security audit

Polygon Agents CLI

Security checks for vulnerabilities and agentic risk

Overview

The skill matches its Polygon wallet-agent purpose, but it asks the agent to run mutable remote executables and handle wallet credentials in ways that need careful review.

Install only if you are comfortable with an agent-assisted wallet tool handling project keys and session authority. Prefer pinning and verifying the CLI and cloudflared versions, avoid global installs, run it in a constrained environment, use low session spend limits and recipient/contract allowlists, inspect every recipient and amount before using --broadcast, and rotate or remove stored sessions, keys, and /tmp session blobs when done.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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 (3)

T08 · Insecure Dependencies

Error
Location
SKILL.md:10
Finding
Unpinned Remote npm Package Is Installed and Executed<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 10–13 **Additional Location**: `QUICKSTART.md`, lines 10–14 **Vulnerability Type**: Unpinned third-party executable dependency **Risk Level**: High ### Vulnerable Code ```markdown ## Prerequisites - Node.js 22+ - Run via npx: `npx @polygonlabs/agent-cli <command>` - Storage: `~/.polygon-agent/` (AES-256-GCM encrypted) ``` The quick-start guide additionally recommends a global installation: ```markdown ## Prerequisites - Node.js 22+ - Run via npx: `npx @polygonlabs/agent-cli <command>` - Or install globally for the shorter `polygon-agent` command: `npm install -g @polygonlabs/agent-cli` ``` ### Technical Analysis The documentation instructs the Agent to retrieve and execute `@polygonlabs/agent-cli` without pinning an exact package version or integrity digest. Depending on local npm behavior and cache state, `npx` can download the current registry release and execute it immediately. Consequently, the effective executable can change after the Skill has been reviewed. A compromised npm account, package registry, maintainer environment, or future malicious release could introduce arbitrary code without any modification to this Skill. Global installation further expands the exposure because the package remains available to later shell sessions. This risk is particularly significant because the package is expected to operate in a context containing wallet credentials, project access keys, encrypted wallet sessions, and authority to broadcast financial transactions. ### Attack Path 1. An attacker compromises the package publisher, publication pipeline, or registry entry for `@polygonlabs/agent-cli`. 2. The attacker publishes a modified release containing malicious install-time or runtime behavior. 3. The Agent follows the Skill and invokes `npx @polygonlabs/agent-cli` or installs the package globally without specifying an audited version. 4. npm retrieves and executes the attacker-cont ...[truncated 905 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin the CLI to a specific audited version, for example: ```bash npx --no-install @polygonlabs/agent-cli ``` after installing an exact version through a lockfile-controlled process. 2. Commit and enforce a package lockfile containing npm integrity hashes. 3. Prefer a project-local installation over global installation. 4. Disable npm lifecycle scripts during installation where they are not required: ```bash npm ci --ignore-scripts ``` 5. Verify the package's provenance, signatures, maintainers, and published checksums before use. 6. Require explicit user approval before downloading or upgrading executable dependencies. 7. Execute wallet tooling in a sandbox with access only to the files and network endpoints required for the requested operation. 8. Separate dependency installation from sessions in which high-value wallet credentials are loaded. ]]>

T03 · Remote Payload Retrieval and Execution

Error
Location
SKILL.md:157
Finding
Automatic Download and Execution of an Unverified Cloudflared Binary<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 157–160 **Additional Location**: `QUICKSTART.md`, lines 40–43 **Vulnerability Type**: Remote payload retrieval and execution without documented integrity verification **Risk Level**: High ### Vulnerable Code ```markdown ## Callback Modes The `wallet create` command automatically starts a local HTTP server and opens a **Cloudflare Quick Tunnel** (`*.trycloudflare.com`) — no account or token required. The `cloudflared` binary is auto-downloaded to `~/.polygon-agent/bin/cloudflared` on first use if not already installed. The connector UI POSTs the encrypted session back through the tunnel regardless of where the agent is running. The tunnel and server are torn down automatically once the session is received. ``` ### Technical Analysis The documented workflow automatically downloads an executable to `~/.polygon-agent/bin/cloudflared` and runs it as part of wallet creation. The reviewed documentation does not specify: - The binary's download URL - An exact pinned version - A trusted checksum - Cryptographic signature or provenance verification - Secure file-creation and replacement behavior - An explicit user-approval boundary before download and execution This creates a mutable remote execution channel. If the download source, redirect chain, release artifact, DNS resolution, TLS trust boundary, or CLI download implementation is compromised, a substituted executable could run with the Agent's privileges. The binary also participates in a security-sensitive callback flow that exposes a local HTTP endpoint through a public tunnel and carries an encrypted wallet-session blob. Encryption reduces direct disclosure risk but does not eliminate the danger of executing a substituted local binary. The implementation was not included in the audited project, so download validation and callback authentication could not be independently verified. ### Attack Path 1. The user or Agent runs `polygon- ...[truncated 1156 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not automatically download and execute the binary without explicit user consent. 2. Prefer an operating-system package manager or a preinstalled administrator-approved `cloudflared` binary. 3. Pin an exact binary version and platform-specific artifact. 4. Verify a published SHA-256 or stronger digest before execution. 5. Verify the vendor's cryptographic release signature or supported provenance attestation. 6. Download into a securely created temporary file, validate it, set restrictive permissions, and then atomically move it into place. 7. Refuse to execute the binary if validation fails or if the destination is a symbolic link or has unsafe ownership. 8. Run the tunnel process in a sandbox with restricted filesystem access, network destinations, and process privileges. 9. Authenticate callback requests and bind the local callback listener to the narrowest required interface. 10. Document the download source, verification process, version-update policy, and security assumptions. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:15
Finding
Raw Project Access Key Is Loaded into Agent Context and Replicated Across Environment Variables<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 15–29 **Additional Location**: `QUICKSTART.md`, lines 16–30 **Vulnerability Type**: Excessive credential access and insecure secret propagation **Risk Level**: Medium ### Vulnerable Code ```markdown ## Session Initialization **Before running any commands**, use the Read tool to check `~/.polygon-agent/builder.json`: - **If it exists** — extract `accessKey` from the JSON and export as plain shell vars (no `$()` subshells): ```bash export SEQUENCE_PROJECT_ACCESS_KEY=<accessKey> export SEQUENCE_INDEXER_ACCESS_KEY=$SEQUENCE_PROJECT_ACCESS_KEY export TRAILS_API_KEY=$SEQUENCE_PROJECT_ACCESS_KEY ``` - **If it doesn't exist** — the user hasn't completed setup yet. Proceed to Phase 1 (`setup`) which will create the file. ``` ### Technical Analysis The Skill explicitly directs a general-purpose Agent to read `~/.polygon-agent/builder.json`, extract an access credential, and place the same credential into three environment variables. Wallet operations legitimately require authentication, but exposing the raw key to the Agent is broader than necessary. A safer architecture would have trusted wallet software retrieve the credential internally from a protected store. Once loaded into Agent context or shell environment, the credential may become available to: - Child processes inheriting the environment - Debugging and diagnostic tools - Error reports or command transcripts - Prompt-injected tool calls - Untrusted dependencies executed in the same process context Reusing one key under three service-specific variable names also enlarges the credential's effective trust boundary. A compromise of any process expecting one of those variables may expose access used for the other services. The project claims that storage is protected with AES-256-GCM, but no implementation is present to verify key management, decryption behavior, access-key scope, or file permissions. Reading the stored key ...[truncated 1271 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove the instruction requiring the Agent to read or display the raw access key. 2. Have the audited CLI retrieve credentials directly from an operating-system credential manager or permission-restricted configuration store. 3. Use separate, narrowly scoped credentials for Sequence project access, indexer access, and Trails instead of duplicating one key across all services. 4. Apply short expiration periods, rotation, revocation, audience restrictions, and operation-specific scopes. 5. Pass credentials only to the exact process that requires them rather than exporting them into a shared shell environment. 6. Ensure credential files and encryption keys use restrictive ownership and `0600` permissions. 7. Redact access keys from command output, logs, traces, crash reports, and debugging files. 8. Prevent wallet subprocesses from launching unrelated commands while credentials are present. 9. Clear temporary environment variables immediately after the operation completes. 10. Require explicit user confirmation before any operation that broadcasts a transaction or grants a wallet session spending authority. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Rogue AgentSelf-Modification, Session Persistence
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (15)

Session Persistence

Medium
Category
Rogue Agent
Content
---
name: polygon-agent-cli-quickstart
description: Quick start guide for Polygon Agent CLI. Get project access key, create wallet with session permissions, register agent onchain, perform token operations. Context-efficient workflow for autonomous agents.
---

# Polygon Agent CLI - Quick Start
Confidence
78% confidence
Finding
The skill explicitly promotes a session-based autonomous-agent workflow that can create wallets, persist credentials, and perform token operations. In this context, session persistence expands the blast radius of compromise: if the host, encrypted storage, exported environment variables, callback blob, or active session is exposed, an attacker may gain ongoing ability to transact within the session's permissions.

Rp1

Medium
Category
MCP Rug Pull
Confidence
89% confidence
Finding
The quickstart instructs users to run the CLI via `npx @polygonlabs/agent-cli` without pinning an exact version. That causes the latest published package to be fetched and executed at runtime, which increases supply-chain risk: a compromised maintainer account, malicious update, or typo/squat replacement could result in arbitrary code execution on the user's machine.

Whitespace Padding

Medium
Category
Prompt Injection
Content
## Error Recovery

| Issue                            | Fix                                                                                                         |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Session expired                  | Re-run `wallet create`                                                                                      |
| Insufficient funds               | Fund wallet address with POL                                                                                |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| Issue                            | Fix                                                                                                         |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Session expired                  | Re-run `wallet create`                                                                                      |
| Insufficient funds               | Fund wallet address with POL                                                                                |
| Fee errors                       | Set `POLYGON_AGENT_DEBUG_FEE=1` to inspect                                                                  |
| Tx failed                        | Omit `--broadcast` for dry-run first                                                                        |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| Issue                            | Fix                                                                                                         |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Session expired                  | Re-run `wallet create`                                                                                      |
| Insufficient funds               | Fund wallet address with POL                                                                                |
| Fee errors                       | Set `POLYGON_AGENT_DEBUG_FEE=1` to inspect                                                                  |
| Tx failed                        | Omit `--broadcast` for dry-run first                                                                        |
| Callback timeout                 | `--timeout 600`                                                                                             |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Rp1

Medium
Category
MCP Rug Pull
Confidence
92% confidence
Finding
The skill instructs users to run the CLI via `npx @polygonlabs/agent-cli` without pinning an exact package version. That creates a supply-chain risk because future package updates, compromised maintainer accounts, or a typosquatted/transitively altered release could change behavior at execution time and lead to arbitrary code execution on the user's machine.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill explicitly tells the operator to extract an `accessKey` from local storage and export it as plaintext environment variables, but gives no warning about credential sensitivity, shell history leakage, process-list exposure in some environments, accidental logging, or inheritance into child processes. Because the same key is reused for multiple services, compromise of that one value could enable unauthorized wallet/indexer/Trails operations within the project scope.

Session Persistence

Medium
Category
Rogue Agent
Content
## Key Behaviors

- **Dry-run by default** — all write commands require `--broadcast` to execute
- **Smart defaults** — `--wallet main`, `--chain polygon`, auto-wait on `wallet create`
- **Fee preference** — auto-selects USDC over native POL when both available
- **`fund`** — reads `walletAddress` from the wallet session and sets it as `toAddress` in the Trails widget URL. Always run `polygon-agent fund` to get the correct URL — never construct it manually or hardcode any address. The returned JSON contains `fundingUrl` and `walletAddress` so you can confirm the pre-filled recipient before sharing.
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.

Whitespace Padding

Medium
Category
Prompt Injection
Content
## Troubleshooting

| Issue                                 | Fix                                                                                                                             |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `Builder configured already`          | Add `--force`                                                                                                                   |
| `Missing SEQUENCE_PROJECT_ACCESS_KEY` | Run `setup` first                                                                                                               |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| Issue                                 | Fix                                                                                                                             |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `Builder configured already`          | Add `--force`                                                                                                                   |
| `Missing SEQUENCE_PROJECT_ACCESS_KEY` | Run `setup` first                                                                                                               |
| `Missing wallet`                      | `wallet list`, re-run `wallet create`                                                                                           |
| `Session expired`                     | Re-run `wallet create` (24h expiry)                                                                                             |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| Issue                                 | Fix                                                                                                                             |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `Builder configured already`          | Add `--force`                                                                                                                   |
| `Missing SEQUENCE_PROJECT_ACCESS_KEY` | Run `setup` first                                                                                                               |
| `Missing wallet`                      | `wallet list`, re-run `wallet create`                                                                                           |
| `Session expired`                     | Re-run `wallet create` (24h expiry)                                                                                             |
| `Fee option errors`                   | Set `POLYGON_AGENT_DEBUG_FEE=1`, ensure wallet has funds                                                                        |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `Builder configured already`          | Add `--force`                                                                                                                   |
| `Missing SEQUENCE_PROJECT_ACCESS_KEY` | Run `setup` first                                                                                                               |
| `Missing wallet`                      | `wallet list`, re-run `wallet create`                                                                                           |
| `Session expired`                     | Re-run `wallet create` (24h expiry)                                                                                             |
| `Fee option errors`                   | Set `POLYGON_AGENT_DEBUG_FEE=1`, ensure wallet has funds                                                                        |
| `Timed out waiting for callback`      | Add `--timeout 600`                                                                                                             |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| `Builder configured already`          | Add `--force`                                                                                                                   |
| `Missing SEQUENCE_PROJECT_ACCESS_KEY` | Run `setup` first                                                                                                               |
| `Missing wallet`                      | `wallet list`, re-run `wallet create`                                                                                           |
| `Session expired`                     | Re-run `wallet create` (24h expiry)                                                                                             |
| `Fee option errors`                   | Set `POLYGON_AGENT_DEBUG_FEE=1`, ensure wallet has funds                                                                        |
| `Timed out waiting for callback`      | Add `--timeout 600`                                                                                                             |
| `callbackMode: manual` (no tunnel)    | cloudflared unavailable — paste blob from browser when prompted; blob saved to `/tmp/polygon-session-<rid>.txt`                 |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| `Builder configured already`          | Add `--force`                                                                                                                   |
| `Missing SEQUENCE_PROJECT_ACCESS_KEY` | Run `setup` first                                                                                                               |
| `Missing wallet`                      | `wallet list`, re-run `wallet create`                                                                                           |
| `Session expired`                     | Re-run `wallet create` (24h expiry)                                                                                             |
| `Fee option errors`                   | Set `POLYGON_AGENT_DEBUG_FEE=1`, ensure wallet has funds                                                                        |
| `Timed out waiting for callback`      | Add `--timeout 600`                                                                                                             |
| `callbackMode: manual` (no tunnel)    | cloudflared unavailable — paste blob from browser when prompted; blob saved to `/tmp/polygon-session-<rid>.txt`                 |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Whitespace Padding

Medium
Category
Prompt Injection
Content
| `Missing wallet`                      | `wallet list`, re-run `wallet create`                                                                                           |
| `Session expired`                     | Re-run `wallet create` (24h expiry)                                                                                             |
| `Fee option errors`                   | Set `POLYGON_AGENT_DEBUG_FEE=1`, ensure wallet has funds                                                                        |
| `Timed out waiting for callback`      | Add `--timeout 600`                                                                                                             |
| `callbackMode: manual` (no tunnel)    | cloudflared unavailable — paste blob from browser when prompted; blob saved to `/tmp/polygon-session-<rid>.txt`                 |
| `404` on `*.trycloudflare.com`        | CLI timed out and tunnel is gone — re-run `wallet create`, open the new `approvalUrl` immediately                               |
| `"Auto-send failed"` in browser       | Copy the ciphertext shown below that message; run `wallet import --ciphertext '<blob>'`                                         |
Confidence
70% confidence
Finding
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.