Back to skill

Security audit

Token Estimator

Security checks for vulnerabilities and agentic risk

Overview

This skill appears intended to estimate token usage, but it should be reviewed because its local-only claims conflict with external tokenizer/dependency loading and its triggers are broad.

Review before installing. Use it only if you are comfortable installing the listed Python packages and allowing a tokenizer download, or pin dependencies and pre-cache tokenizer files in a restricted environment. Do not rely on the stated local-only/no-external-transfer guarantee unless the tokenizer is forced to local-only mode.

Vulnerability Patterns
  • 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
  • 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 (1)

T08 · Insecure Dependencies

Warning
Location
SKILL.md:45
Finding
Unpinned Python Dependencies and Mutable Runtime Tokenizer Retrieval## Vulnerability Details **File Location**: `SKILL.md:45-48`, `SKILL.md:306-310`, `scripts/token-estimator.py:15-30`, and `scripts/token-estimator.py:48-53` **Vulnerability Type**: Supply-chain exposure through unpinned dependencies and mutable external artifacts **Risk Level**: Medium ### Vulnerable Code `SKILL.md:45-48`: ```bash # ClAWHub installation clawhub install token-estimator # Install dependencies pip3 install tiktoken transformers dashscope ``` `SKILL.md:306-310`: ```python # requirements.txt tiktoken>=0.5.0 # OpenAI/Gemini tokenizer transformers>=4.30.0 # Qwen tokenizer dashscope>=1.14.0 # Bailian API model information ``` `scripts/token-estimator.py:15-30`: ```python # Attempt to import tokenizer libraries try: import tiktoken TIKTOKEN_AVAILABLE = True except ImportError: TIKTOKEN_AVAILABLE = False try: from transformers import AutoTokenizer TRANSFORMERS_AVAILABLE = True except ImportError: TRANSFORMERS_AVAILABLE = False try: import dashscope DASHSCOPE_AVAILABLE = True except ImportError: DASHSCOPE_AVAILABLE = False ``` `scripts/token-estimator.py:48-53`: ```python if TRANSFORMERS_AVAILABLE: try: print(f"🔧 Using Qwen Tokenizer (transformers)", file=sys.stderr) return AutoTokenizer.from_pretrained("Qwen/Qwen-7B") except Exception as e: print(f"⚠️ Qwen Tokenizer loading failed: {e}", file=sys.stderr) ``` ### Technical Analysis The documented installation command resolves the current available releases of `tiktoken`, `transformers`, and `dashscope` without exact version or artifact-hash verification. The example dependency declarations only specify minimum versions, which also permit future, unaudited releases. These packages are imported when the script starts. Python packages can execute module initialization code during import, so a compromised ups ...[truncated 2336 chars]
Remediation
## Remediation Suggestions 1. Pin every Python dependency to an exact reviewed version in a requirements or lock file. 2. Require package hashes, for example by generating a hash-locked requirements file and installing with `pip --require-hashes`. 3. Remove the unused `dashscope` dependency and import unless they become necessary for implemented functionality. 4. Pin the Hugging Face tokenizer to a reviewed immutable commit: ```python AutoTokenizer.from_pretrained( "Qwen/Qwen-7B", revision="REVIEWED_COMMIT_SHA", trust_remote_code=False, ) ``` 5. Pre-download and verify tokenizer artifacts during a controlled build process. Use local-only loading in production where practical. 6. Document that the first tokenizer load may access an external service; provide an explicitly offline fallback. 7. Run the Skill in a restricted environment with minimal filesystem permissions, filtered environment variables, resource limits, and constrained outbound network access. 8. Use automated dependency vulnerability scanning and review lockfile updates before release.
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 Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (14)

External Model or Provider Selection

High
Category
Excessive Agency
Content
# 指定模型
/token --model=dashscope/qwen3.5-plus [文本]
/token --model=google/gemini-1.5-pro [文本]
/token --model=gpt-4 [文本]

# 带 4D 压缩建议
/token --with-compress [文本]
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.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger list includes broad generic terms like 'token', 'count', 'estimate', and common Chinese words that may match ordinary conversation and cause unintended invocation. In an agent environment, overbroad activation increases the chance the skill processes user content without clear intent, which can lead to accidental data exposure to the skill runtime or unexpected actions.

Vague Triggers

Medium
Confidence
88% confidence
Finding
The documentation encourages unconstrained natural-language activation ('自然语言,随口一说,系统就懂'), which normalizes implicit invocation without defining when the skill should not run. In practice, this increases unintended activation risk and may cause sensitive prompt content or conversation context to be consumed by the skill when the user did not explicitly request it.

Intent-Code Divergence

Medium
Confidence
96% confidence
Finding
The document promises strictly local processing with no external transmission, but the described use of AutoTokenizer.from_pretrained can trigger network access to fetch model files if they are not already cached. This creates a privacy and transparency problem: user text may remain local, but the skill can still make undeclared outbound connections, violating the stated security properties and potentially exposing metadata about usage.

Natural-Language Policy Violations

Medium
Confidence
89% confidence
Finding
This Python file contains user-facing descriptions, help text, and console output almost entirely in Chinese, including the module description, argparse help, and status messages. That imposes a specific language/locale on users without an opt-in or documented justification, which matches the language-policy violation category.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The manifest promises '支持多模型精确计算' (supports precise calculation for multiple models), but the implementation falls back to rough character-based estimation for unknown models and for Qwen when tokenizer loading fails. That creates a semantic mismatch between the advertised precision and the actual best-effort behavior. The mismatch is especially visible because the fallback is explicitly approximate.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This plain-text skill content presents all instructions and material in a single language, which can violate a language/locale policy when no user opt-in or justification is provided. The file does not indicate that the skill is intended only for Chinese-speaking users or offer any alternative language handling.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This plain-text skill content forces a specific language/locale for all users, which can violate language-choice policy when no opt-in or alternative is provided. The document contains only Chinese instructions and slogans, with no indication that the skill is region-specific or intentionally limited to Chinese-speaking users.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
The report explicitly recommends 'default enabling' 4D compression without mentioning consent, visibility, or the possibility that compression may alter, omit, or transform user-provided content before submission. In a token-estimation skill, a feature that changes prompt content by default can create integrity and privacy risks because users may unknowingly send modified instructions or lose important context.

Description-Behavior Mismatch

Low
Confidence
86% confidence
Finding
Manifest 在 L003 将技能范围描述为“预估本次请求的 Token 消耗量”,语义上是单次请求估算;但 L142-L159、L265-L286 描述了 5 小时、日、周、月的用量统计与配额展示,这属于历史使用追踪能力,超出了“本次请求预估”的直观范围。该能力并非实现单次估算所必需,因此存在描述与行为范围不一致。

Natural-Language Policy Violations

Low
Confidence
76% confidence
Finding
The manifest description and the rest of the skill documentation are presented exclusively in Chinese, and the examples and trigger words assume Chinese usage. There is no indication that users may choose another language or that the locale restriction is intentional and justified.

Description-Behavior Mismatch

Low
Confidence
88% confidence
Finding
The manifest describes a skill whose purpose is estimating token consumption for requests across models. However, the code also implements 4D compression cost-savings projections and a token quota/usage meter UI, which are adjacent budgeting features rather than direct token estimation of the current request. These behaviors expand the skill beyond its stated narrow purpose.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
This plain-text file contains user-facing natural language exclusively in Chinese, which can impose a language choice on users without any opt-in or explanation. The policy allows fixed language only when the skill offers a choice or clearly documents a justified locale constraint, neither of which is present here.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The file content is entirely in Chinese and does not indicate any user choice, fallback, or justification for restricting communication to that language. Under the policy, forcing a specific language without opt-in is a natural-language locale violation.

Static analysis

No suspicious patterns detected.