Back to skill

Security audit

PocketLens

Security checks for vulnerabilities and agentic risk

Overview

The skill matches its expense-tracking purpose, but it needs review because it handles sensitive financial data with a write-capable API key and has unsafe command and endpoint handling.

Review before installing. Use a write-only key rather than full access, avoid setting a custom API URL unless you fully trust that server, redact unnecessary card or statement details before upload, and confirm transactions before allowing the skill to record them.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/pocket-lens.mjs:21
Finding
Arbitrary API Endpoint Can Receive Bearer Credentials and Financial Data<![CDATA[ ## Vulnerability Details **File Location**: `scripts/pocket-lens.mjs:21-24, 35-40, 61-71` **Vulnerability Type**: Unrestricted sensitive-data transmission endpoint **Risk Level**: High ### Vulnerable Code ```js const API_KEY = process.env.POCKET_LENS_API_KEY; const API_URL = (process.env.POCKET_LENS_API_URL || "https://pocketlens.app").replace( /\/$/, "" ); function headers() { return { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", Accept: "application/json", }; } async function request(method, path, body) { const url = `${API_URL}${path}`; const opts = { method, headers: headers() }; if (body !== undefined) { opts.body = typeof body === "string" ? body : JSON.stringify(body); } let res; try { res = await fetch(url, opts); } catch (err) { exitWithError(`Network error: ${err.message}`); } ``` The custom endpoint is also explicitly documented in `SKILL.md:33-36`: ```md - `POCKET_LENS_API_URL` (optional): Base URL for the PocketLens API. Defaults to `https://pocketlens.app` if not set. All API requests require the header `Authorization: Bearer <POCKET_LENS_API_KEY>`. ``` ### Technical Analysis `POCKET_LENS_API_URL` is trusted without validating its scheme, hostname, port, path, or ownership. The script subsequently attaches the PocketLens bearer credential to every request made through this endpoint. When creating a transaction, the request body can contain sensitive personal financial information, including merchant names, transaction amounts, timestamps, card issuer names, categories, and descriptions. Read operations can also expose account identity, spending summaries, category information, and card billing details. Although network transmission to the default PocketLens service is necessary for the declared functionality, allowing an arbitrary endpoint to receive the production bearer credential and financial records is not necessary for normal operation and exc ...[truncated 1624 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove support for arbitrary API origins unless self-hosting is an explicit product requirement. 2. Allowlist the production origin exactly, for example: - Scheme: `https:` - Hostname: `pocketlens.app` - Expected port only - No embedded username or password 3. Parse custom values with `new URL()` and reject: - Plaintext HTTP. - Unexpected hosts or ports. - Embedded credentials. - Unexpected base paths. - Malformed or non-network schemes. 4. If custom or self-hosted servers must be supported, require an explicit trusted-host allowlist and use a separate credential scoped to that server. Never reuse the production PocketLens credential automatically. 5. Bind credentials to an expected audience or origin on the server side where possible. 6. Recommend only the minimum API permission required for each operation. Do not recommend `full` access where `write` or read-only credentials are sufficient. 7. Warn users that changing the endpoint changes the party receiving their credential and financial records. 8. Consider splitting read and write operations across separate least-privilege credentials. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:42
Finding
Shell Command Injection Through Untrusted Transaction JSON<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:42-84` **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Instructions ```md When a user sends an image that appears to be a receipt, credit card statement, bank notification, or any payment-related screenshot: **Step 1 - Analyze the image:** Use the `image` tool to analyze the uploaded image with the following prompt: ``` Extract all payment/transaction information from this image. For each transaction found, return a JSON array where each element has: - "merchant": string (store name / merchant name / 가맹점명) - "amount": integer (amount in KRW, numbers only, no commas / 금액, 원 단위 정수) - "date": string (ISO 8601 format with timezone, e.g. "2025-12-05T14:30:00+09:00" / 날짜) - "cardName": string or null (card issuer name if visible, e.g. "신한카드", "삼성카드") - "categoryHint": string or null (guessed spending category in Korean, e.g. "식비", "교통", "쇼핑", "카페", "편의점", "의료", "통신", "구독") If the date is ambiguous or only shows month/day, assume the current year and KST timezone (+09:00). If multiple transactions are visible, return all of them as an array. Respond ONLY with valid JSON. No explanation, no markdown fences. ``` **Step 2 - Parse the result:** Parse the JSON array from the Vision response. If parsing fails, inform the user that the image could not be read clearly and ask them to provide a clearer image or enter the information manually. **Step 3 - Submit transactions to PocketLens:** For each parsed transaction, call the PocketLens API using the helper script: ```bash node pocket-lens.mjs create-transaction '<JSON>' ``` Where `<JSON>` is a JSON object with the transaction fields. For multiple transactions, wrap them in a `transactions` array: ```bash node pocket-lens.mjs create-transaction '{"transactions": [{"merchant": "스타벅스", "amount": 5500, "date": "2025-12-05T14:30:00+09:00", "cardName": "신한카드", "categoryHint": "카페"}]}' ``` ``` The receiving command in ...[truncated 2662 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not interpolate transaction JSON into a shell command. 2. Invoke Node.js through a structured process API that accepts an argument array and disables shell parsing, such as an API equivalent to: - Executable: `node` - Arguments: `["scripts/pocket-lens.mjs", "create-transaction", serializedJson]` - Shell: disabled 3. Prefer passing transaction data through standard input. Update the helper to read JSON from stdin so financial text never becomes part of shell source. 4. Alternatively, write the JSON to a securely created file with restrictive permissions and pass only the generated filename through a structured argument API. 5. Update `SKILL.md` to explicitly prohibit shell-string construction and require argv-based execution. 6. Do not rely on quote escaping as the primary defense. Different shells and execution environments have incompatible escaping rules. 7. Retain and strengthen application validation: - Enforce documented string-length limits. - Validate that each transaction is a non-null plain object. - Validate ISO 8601 dates. - Reject unexpected fields where practical. - Restrict transaction count and payload size. 8. Run the helper in a sandbox with minimal filesystem, environment, and network access to reduce impact if another command-execution flaw is introduced. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (4)

Session Persistence

Medium
Category
Rogue Agent
Content
1. Log in to [PocketLens](https://pocketlens.app).
2. Go to **Settings > API Keys**.
3. Click **Create New Key**.
4. Set the permission to **write** (or **full**).
5. Copy the generated key (starts with `pk_`).
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.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The README encourages users to upload receipts and card-statement screenshots and states these will be analyzed by AI and recorded to PocketLens, but it does not clearly warn that sensitive financial data in those images may be transmitted to external services and stored automatically. This can lead to uninformed consent, accidental disclosure of card or transaction data, and privacy/compliance issues when users share highly sensitive financial documents.

Lp3

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding
The skill invokes external code paths and uses sensitive environment credentials plus network access, but it does not declare an explicit tool scope such as allowed tools or permissions. That creates an authorization gap where the runtime may permit broader execution than users or reviewers expect, increasing the chance of unintended command execution or data egress involving financial data and API keys.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill instructs the agent to process receipts, card statements, and payment screenshots and send extracted transaction data to an external service, but it does not require an explicit user-facing warning or consent step before that transfer. Because the data includes highly sensitive financial information, users may unknowingly disclose card billing details, merchants, spending patterns, and other personal data to a third party.

Static analysis

Detected: suspicious.env_credential_access

Environment variable access combined with network send.

Critical
Code
suspicious.env_credential_access
Location
scripts/pocket-lens.mjs:20