Back to skill

Security audit

prompt-token-analyzer

Security checks for vulnerabilities and agentic risk

Overview

The skill is a simple token-counting CLI, but its setup asks for unnecessary system-wide installation with elevated privileges.

Review the generated script before installing it. Prefer running it locally or placing it in a user-owned bin directory instead of using sudo, and pin or verify the gpt-tokenizer package version before installation.

Vulnerability Patterns
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T08 · Insecure Dependencies

Warning
Location
SKILL.md:29
Finding
Unpinned Third-Party Package Installed Globally<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 29–33; repeated at lines 199–203 **Vulnerability Type**: Unpinned and globally installed third-party dependency **Risk Level**: Medium ### Vulnerable Code ```bash npm install -g gpt-tokenizer ``` The same installation command is repeated in the troubleshooting section: ```bash npm install -g gpt-tokenizer ``` ### Technical Analysis The installation instructions retrieve the current version of `gpt-tokenizer` and its transitive dependencies without specifying an exact version, lockfile, or integrity hash. Consequently, the code executed by this instruction may change after the Skill has been reviewed. Installing through npm can also execute package lifecycle scripts, such as `preinstall`, `install`, and `postinstall`, with the permissions of the user running npm. The global installation mode increases exposure by adding the package to the user's global Node.js environment. No evidence establishes that the referenced package is currently malicious. The vulnerability is the mutable and insufficiently verified dependency acquisition process, which exposes users to package-account compromise, malicious future releases, or compromised transitive dependencies. ### Attack Path 1. An attacker compromises the `gpt-tokenizer` publishing account, one of its transitive dependencies, or the relevant package distribution channel. 2. The attacker publishes a malicious release or injects a malicious lifecycle script. 3. A user follows the Skill instructions and runs `npm install -g gpt-tokenizer`. 4. npm resolves the unpinned package reference to the attacker-controlled release. 5. Malicious package code or lifecycle scripts execute with the installing user's privileges. 6. The payload can access data available to that user, modify user-owned files, or alter the user's global Node.js environment. ### Impact Assessment Successful exploitation could provide arbitrary code execution under the accoun ...[truncated 340 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Pin `gpt-tokenizer` to an exact, reviewed version rather than installing the latest release. - Maintain a lockfile that records exact transitive dependency versions and package integrity metadata. - Prefer a project-local dependency over `npm install -g`, for example: ```bash npm install --save-exact gpt-tokenizer@<reviewed-version> ``` - Use `npm ci` with a committed lockfile for reproducible installation. - Where package functionality permits it, disable lifecycle scripts during installation: ```bash npm ci --ignore-scripts ``` - Verify the package publisher, source repository, integrity, and dependency tree before approving upgrades. - Run dependency vulnerability and provenance checks in CI, and review every dependency update before distribution. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:92
Finding
Unnecessary Privileged Installation into a System-Wide Executable Directory<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 92–101 **Vulnerability Type**: Unnecessary privilege elevation and system-wide executable installation **Risk Level**: Medium ### Vulnerable Code ```bash chmod +x prompt-token ``` The generated executable is then moved into a shared system path using elevated privileges: ```bash sudo mv prompt-token /usr/local/bin/ ``` ### Technical Analysis The token-analysis function does not require administrative privileges. Nevertheless, the documented procedure asks the user to elevate privileges and move a file from the current working directory into `/usr/local/bin`, a system-wide executable location. The privileged operation trusts the current `prompt-token` path without validating its ownership, file type, content, hash, or final destination state. If the source file is replaced or modified between creation and the privileged move, an attacker-controlled executable can be installed into a trusted PATH directory. The command may also replace an existing `/usr/local/bin/prompt-token`, depending on filesystem permissions and command behavior, without requiring explicit confirmation. This violates least privilege and turns the integrity of a working-directory file into the integrity of a system-wide command. ### Attack Path 1. A user creates `prompt-token` in a directory that another local process or account can modify, or the file is otherwise altered before installation. 2. An attacker replaces or modifies the source file with a malicious executable. 3. The user follows the documentation and approves `sudo mv prompt-token /usr/local/bin/`. 4. The privileged `mv` installs the attacker-controlled file in `/usr/local/bin`. 5. The malicious executable runs whenever the affected user or another system user invokes `prompt-token`. 6. Code executes with the privileges of each account invoking the installed command. The installation itself also causes an unauthorized privileged filesystem modificat ...[truncated 651 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Avoid `sudo` and install the executable into a user-owned directory such as `~/.local/bin`: ```bash install -d -m 0755 "$HOME/.local/bin" install -m 0755 prompt-token "$HOME/.local/bin/prompt-token" ``` - Instruct users to add `~/.local/bin` to `PATH` if it is not already present. - Refuse unintended replacement of an existing executable, or require the user to inspect and explicitly approve an update. - Create the file in a private directory owned by the user and inaccessible to other accounts. - Validate that the source is a regular file, is owned by the current user, and has not changed before installation. - If system-wide installation is genuinely required, use a reviewed installation process that verifies a cryptographic digest and installs atomically with explicit ownership and permissions. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
Move it into PATH:

```bash
sudo mv prompt-token /usr/local/bin/
```

---
Confidence
97% confidence
Finding
The explicit use of sudo to move an executable into /usr/local/bin requires root privileges and creates a direct path for privileged modification of the host if followed automatically. Although the script itself appears simple, the skill asks the user to create the executable from inline content and then install it as root, which is a risky pattern because any hidden or later-modified content would execute with elevated trust on a persistent system path.

Context-Inappropriate Capability

Low
Confidence
94% confidence
Finding
The skill instructs users to move a custom script into /usr/local/bin using elevated privileges, which is a privileged system modification not strictly necessary to perform token analysis. While common in CLI setup guides, this increases risk because agents may execute a root-level file operation on unreviewed content from the skill, expanding impact if the generated script or path is tampered with.

Missing User Warnings

Low
Confidence
96% confidence
Finding
The installation steps include a privileged system modification command without any warning, causing a user or agent to normalize use of sudo for routine setup. In an agent context, this is dangerous because it encourages elevated execution of instructions derived from potentially adversarial skill content without emphasizing review or safer non-privileged alternatives.

Static analysis

No suspicious patterns detected.