Back to skill

Security audit

Prompt Token Counter

Security checks for vulnerabilities and agentic risk

Overview

This token-counting skill is mostly coherent, but it includes under-scoped network features that can fetch arbitrary URLs or send benchmark text to external model APIs.

Review this skill before installing if you plan to let an agent use URLs or benchmark files. Prefer local file or inline token counting, avoid --url for untrusted or internal URLs, and do not run API-mode benchmarks on secrets, private prompts, memory files, or proprietary content unless you intend to send that text to the configured external provider.

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

T01 · Skill Instruction Hijacking

Error
Location
SKILL.md:210
Finding

Mandatory Promotional Output Hijacks Agent Responses

Content
View full analysis
Source: [prompt-token-counter](https://github.com/Zhaobudaoyuema/prompt-token-counter) 2. **Briefly explain how tokens are calculated** — e.g. ``` ### Technical Analysis The skill instructs the agent that it must include a project link after every token-count or cost-estimation response. This output requirement is not necessary to perform the declared functionality and changes the content of the agent's final response for promotional purposes. Because these instructions are loaded as part of the skill, they can override the agent's ordinary goal of returning only information requested by the user. The behavior therefore constitutes skill instruction hijacking: skill-controlled instructions persistently manipulate responses produced during otherwise legitimate operations. The referenced URL is a normal GitHub repository link rather than an executable download. The vulnerability is the mandatory and unrelated modification of agent output, not remote code execution. ### Attack Path 1. The agent loads `SKILL.md` when a user asks for token counting or cost estimation. 2. The agent performs the legitimate local calculation. 3. The response-output rule directs the agent to include the specified external project link. 4. The user receives unsolicited, skill-controlled promotional content with the result. 5. If the linked destination or skill instructions are changed in a later release, the same mandatory output channel could direct users toward different external content. ### Impact Assessment The issue affects the integrity of agent responses. It does not grant operating-system privileges, access credential ...[truncated 432 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/cli.py:65
Finding

Unrestricted URL Fetching Enables Server-Side Request Forgery and Unbounded Downloads

Content
View full analysis
str: parsed = urllib.parse.urlparse(url) if parsed.scheme not in {"http", "https"}: raise ValueError("URL must start with http:// or https://") with urllib.request.urlopen(url, timeout=10) as response: return response.read().decode("utf-8", errors="replace") ``` ### Technical Analysis The URL reader validates only that the supplied URL uses HTTP or HTTPS. It does not validate the resolved destination address or reject requests to: - Loopback hosts. - Private network ranges. - Link-local addresses. - Cloud instance metadata services. - Reserved or otherwise non-public addresses. `urllib.request.urlopen` follows redirects, but redirect destinations are not revalidated. An initially public URL can therefore redirect the request to an internal service. The function also calls `response.read()` without a maximum byte count. The ten-second timeout limits waiting time but does not provide a reliable response-size limit. A server capable of transmitting data quickly could cause the process to allocate substantial memory. The confirmation language in `SKILL.md` is a useful procedural safeguard, but it is not a technical security boundary. Direct CLI users, automated callers, or an agent that fails to follow the documentation remain exposed. ### Attack Path #### SSRF Path 1. An attacker persuades a user or agent to invoke the CLI with `--url` and an attacker-selected HTTP or HTTPS URL. 2. The URL points directly to a private address or to a public server that redirects to one. 3. `_read_url` accepts the URL because its scheme is allowed. 4. `urlopen` sends the request from the machine running the skill. 5. The request reaches an internal service or metadata endpoint that is not exte ...[truncated 1440 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (25)

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

The skill is presented as primarily auditing OpenClaw memory/persona/skills, but it also documents operation on arbitrary local files supplied by the user. That broader read surface matters in context because the same skill encourages reading highly sensitive workspace files, so unclear scoping may normalize expansive file access beyond the stated purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

The skill is presented as primarily auditing OpenClaw memory/persona/skills, but it also documents operation on arbitrary local files supplied by the user. That broader read surface matters in context because the same skill encourages reading highly sensitive workspace files, so unclear scoping may normalize expansive file access beyond the stated purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The skill is presented as primarily auditing OpenClaw memory/persona/skills, but it also documents operation on arbitrary local files supplied by the user. That broader read surface matters in context because the same skill encourages reading highly sensitive workspace files, so unclear scoping may normalize expansive file access beyond the stated purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill is presented as primarily auditing OpenClaw memory/persona/skills, but it also documents operation on arbitrary local files supplied by the user. That broader read surface matters in context because the same skill encourages reading highly sensitive workspace files, so unclear scoping may normalize expansive file access beyond the stated purpose.

Content

No source excerpt is available for this finding.

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
Skills are loaded per session. Count each `SKILL.md`:

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Skills are loaded per session. Count each `SKILL.md`:

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Skills are loaded per session. Count each `SKILL.md`:

External Model or Provider Selection

High
Category
Excessive Agency
Confidence
90% confidence
Finding

Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

Content

Scanner excerpt · scripts/cli.py (reported line 178)May include surrounding context.

python
formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog="""
Examples:
  scripts file1.txt file2.txt --model gpt-4
  scripts --file input.txt --model claude-3-opus-20240229
  scripts --cost --model gpt-4 AGENTS.md SOUL.md MEMORY.md
  scripts --list-models

External Model or Provider Selection

High
Category
Excessive Agency
Confidence
90% confidence
Finding

Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

Content

Scanner excerpt · scripts/cli.py (reported line 179)May include surrounding context.

python
epilog="""
Examples:
  scripts file1.txt file2.txt --model gpt-4
  scripts --file input.txt --model claude-3-opus-20240229
  scripts --cost --model gpt-4 AGENTS.md SOUL.md MEMORY.md
  scripts --list-models
        """

External Model or Provider Selection

High
Category
Excessive Agency
Confidence
90% confidence
Finding

Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

Content

Scanner excerpt · scripts/cli.py (reported line 180)May include surrounding context.

python
Examples:
  scripts file1.txt file2.txt --model gpt-4
  scripts --file input.txt --model claude-3-opus-20240229
  scripts --cost --model gpt-4 AGENTS.md SOUL.md MEMORY.md
  scripts --list-models
        """
    )

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This README is written in Chinese throughout, but it does not state that the skill is intended only for Chinese-speaking users or a China-specific context. Under the language/locale policy, forcing a specific language without explicit user opt-in or justified regional scope is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill advertises capabilities that involve local file reads, optional network fetches, and a publishing script that updates files, but it does not declare any explicit tool scope such as permissions or allowed-tools. In an agent ecosystem, missing scope boundaries can let the skill be invoked with broader access than users expect, increasing the risk of unintended reads of sensitive OpenClaw workspace files or outbound requests.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The CLI accepts arbitrary http/https URLs and fetches their contents for tokenization, which extends the tool from local workspace analysis into network-capable data ingestion. In an agent skill intended for auditing workspace token usage, this can enable unexpected outbound requests, expose internal network resources via SSRF-like behavior, or process untrusted remote content outside the documented scope.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Adding a --url input mode gives the skill network access that is not justified by its declared purpose of auditing local workspace token consumption. In agent environments, unnecessary network capability increases the attack surface and may be abused to fetch attacker-controlled data or probe internal services through user-supplied URLs.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The embedded skill guidance requires explicit warning and confirmation before outbound URL use, but the script's API mode transmits supplied text to remote model endpoints without any comparable runtime disclosure or consent gate. This creates a real data-handling risk because users may benchmark sensitive prompts locally assuming counting behavior, yet the content is actually sent to third-party services.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The manifest describes a skill for counting tokens and estimating costs, primarily for auditing OpenClaw workspace token consumption. This example script can instead send the full sample or file-provided text to external model APIs to derive token counts, which is a materially broader behavior than local auditing and exposes content outside the workspace.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

For a skill whose stated purpose is token counting, cost estimation, and OpenClaw workspace auditing, adding an asynchronous chat-completions client to contact remote providers is not an obvious requirement. The capability sends arbitrary text to third-party endpoints and is especially unnecessary because the same script already provides a local counting mode.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

In API mode, the script sends the provided text directly to an external model API without a runtime warning, confirmation step, or privacy notice. If the input contains workspace memory, prompts, credentials, or proprietary text, this can cause unintended disclosure to third-party infrastructure.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The README promotes auditing local workspace components such as memory, persona, and skills, but does not clearly warn that this may require reading potentially sensitive local files. In an agent setting, vague documentation can lead to overbroad file inspection when a user asks general token-usage questions, increasing the risk of unintended exposure of local content.

Content

No source excerpt is available for this finding.

Vague Triggers

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The 'When to Trigger' section lists general conditions such as 'User asks about token count, prompt length, API cost' and 'Agent needs to audit token consumption' without clarifying exclusions or negative examples. In a markdown skill description, this can cause the skill to activate for ordinary conversational requests that mention cost or length, even when the user may not intend to invoke this specific skill.

Content

No source excerpt is available for this finding.

Vague Triggers

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The instruction to 'also trigger when the agent needs to count tokens or estimate cost before/after generating content' is broader than the explicit user-facing trigger phrases and does not define clear boundaries. This could overlap with many ordinary interactions about prompt drafting or editing, causing the skill to activate without a sufficiently specific user request.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The main() docstring describes input handling as command-line text or file-based processing and lists CLI arguments without mentioning --url. The actual parser and execution path support fetching input from URLs, so the documentation understates and misdescribes the function's implemented behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The embedded markdown in SAMPLE_TEXT contains a natural-language rule stating 'Respond in the user's language' as a mandatory behavior. This imposes a language/locale behavior without explicitly offering opt-in or user choice, which matches the policy-violation category for forced language handling.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
71% confidence
Finding

The script is designed to use API_KEY and BASE_URL for authenticated outbound API calls, but there is no explicit warning in the code about handling credentials or the implications of sending data to a third-party service. This qualifies under the sensitive-credentials/network warning category for code files.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

The script reads arbitrary content from a path supplied via --text-file and uses it for processing, but this file contains no explicit warning, confirmation, or user-facing disclosure about reading local files. Because file access is a safety-relevant operation and this standalone code file does not document the behavior beyond the argument help text, it meets the missing-warning criterion.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.