Back to skill

Security audit

Clean Code

Security checks for vulnerabilities and agentic risk

Overview

The skill content is ordinary clean-code guidance, but its installation instructions use mutable unpinned remote commands and one README command names a different skill.

Review the install path before using this skill. Prefer a pinned ClawHub version or an audited local checkout, and verify whether you intend to install `clean-code` rather than `clean-code-review`. After installation, expect the skill to influence coding/refactoring style in the selected project or global agent environment.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T03 · Remote Payload Retrieval and Execution

Warning
Location
README.md:23
Finding
Mutable Remote Source Passed to an Unpinned npx Package<![CDATA[ ## Vulnerability Details **File Location**: `README.md:23-27` **Vulnerability Type**: Remote payload retrieval through an unpinned package and mutable GitHub source **Risk Level**: Medium ### Vulnerable Code ```markdown ## Installation ```bash npx add https://github.com/wpank/ai/tree/main/skills/testing/clean-code ``` ``` ### Technical Analysis The installation command uses `npx` to retrieve and execute the package named `add` without specifying a version. It also supplies a GitHub tree URL that refers to mutable content rather than an immutable commit. This creates two trust dependencies that can change after the skill has been audited: 1. The package resolved by `npx add` is not version-pinned. 2. The content under the GitHub branch or tree URL can be changed by the repository owner or by an attacker who compromises the repository. Because `npx` executes the resolved package as the current user, compromise of the npm package, package publisher, GitHub repository, or associated accounts could turn the documented installation command into arbitrary local code execution. The URL is also associated with a personal GitHub namespace rather than an immutable, integrity-verified release artifact. ### Attack Path 1. An attacker compromises the publisher of the npm package resolved as `add`, or compromises the referenced GitHub repository. 2. The attacker publishes a malicious package version or modifies the mutable repository content. 3. A user follows the documented installation command. 4. `npx` downloads and executes the currently resolved package code. 5. The malicious code runs with the permissions of the user who invoked the command. 6. The payload can access files and credentials available to that user, alter local development configuration, or download additional payloads. ### Impact Assessment Successful exploitation would provide code execution with the invoking user's privileges. The affected scope could include: - Reading or modify ...[truncated 524 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not use an unversioned generic package such as `npx add`. 2. Use a verified installer from a trusted package namespace. 3. Pin the installer to an exact reviewed version rather than using implicit latest-version resolution. 4. Reference an immutable Git commit or signed release artifact instead of a mutable branch URL. 5. Verify artifact integrity with a documented checksum or package-lock integrity value. 6. Prefer downloading and inspecting the skill before installation rather than executing remote code directly. 7. Document the expected publisher, repository, commit, and checksum so users can verify provenance. A hardened installation flow should follow this model: ```bash npx trusted-installer@<reviewed-exact-version> \ https://github.com/<verified-owner>/<verified-repository>/tree/<immutable-commit>/skills/testing/clean-code ``` The exact package, version, commit, and integrity value should be selected and verified by the project maintainer. ]]>

T08 · Insecure Dependencies

Warning
Location
README.md:29
Finding
Installation Instructions Execute Unpinned Latest-Version Packages<![CDATA[ ## Vulnerability Details **File Locations**: `README.md:29-33` and `SKILL.md:14-20` **Vulnerability Type**: Unpinned third-party installer dependency **Risk Level**: Medium ### Vulnerable Code From `README.md:29-33`: ```markdown ### OpenClaw / Moltbot / Clawbot ```bash npx clawhub@latest install clean-code-review ``` ``` From `SKILL.md:14-20`: ```markdown ## Installation ### OpenClaw / Moltbot / Clawbot ```bash npx clawhub@latest install clean-code ``` ``` ### Technical Analysis Both installation instructions explicitly execute `clawhub@latest`. The `latest` tag is mutable and may resolve to a different package version at any time. Consequently, the code executed by users is not necessarily the version that was reviewed during this audit. If the package publisher, registry account, release pipeline, or dependency chain is compromised, a malicious version can be assigned to the `latest` tag. Users following the documentation would then retrieve and execute that version through `npx`. The README and skill manifest also specify inconsistent skill names: - `README.md` installs `clean-code-review`. - `SKILL.md` installs `clean-code`. This inconsistency creates an additional provenance risk because users may install a different or unintended skill rather than the audited `clean-code` content. ### Attack Path 1. An attacker compromises the `clawhub` package publisher, registry credentials, build pipeline, or a package dependency. 2. The attacker publishes a malicious release and causes `@latest` to resolve to it. 3. Alternatively, an attacker registers or compromises the unintended `clean-code-review` skill referenced by the README. 4. A user runs one of the documented commands. 5. `npx` downloads and executes the currently resolved `clawhub` package. 6. The installer installs attacker-controlled or unintended skill content. 7. Malicious installer code runs with the user's permissions, or malicious skill instructions affect subsequent agent ...[truncated 931 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace `clawhub@latest` with an exact, reviewed package version: ```bash npx clawhub@<exact-reviewed-version> install clean-code ``` 2. Ensure the package name, publisher, and registry provenance are verified before documenting the command. 3. Make the skill identifier consistent across all documentation. Based on the audited metadata, both files should refer to `clean-code`, not `clean-code-review`. 4. Commit and distribute a lockfile or integrity metadata where the installation mechanism supports it. 5. Prefer signed releases and verify package signatures or checksums before execution. 6. Consider using `npx --package=clawhub@<exact-version>` or an equivalent explicit invocation that makes the executed package identity clear. 7. Add installation guidance warning that npm packages execute with the current user's permissions and should not be run with elevated privileges. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (12)

Ae1

High
Category
analysis-evasion
Content
| [Code Smells](references/code-smells.md) | Classic code smells catalog with detection patterns — Bloaters, OO Abusers, Change Preventers, Dispensables, Couple
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Self-Modification

High
Category
Rogue Agent
Content
1. Create new function named after what it does (not how)
2. Copy the code fragment to the new function
3. Pass any needed variables as parameters
4. Replace the original code with a call to the new function

---
Confidence
85% confidence
Finding
Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
The README instructs users to execute a remote package/installer command via `npx add` without pinning to a specific immutable version or commit. This creates a supply-chain risk because the content fetched at install time can change, allowing a compromised upstream package, repo, or tag to execute unexpected code on the user's machine.

Rp1

Medium
Category
MCP Rug Pull
Confidence
95% confidence
Finding
Using `npx clawhub@latest install clean-code-review` explicitly tracks the moving `latest` release, so users will execute whatever code is published most recently. If the package is compromised or a bad release is pushed, installation can run attacker-controlled code in the local environment.

Session Persistence

Medium
Category
Rogue Agent
Content
From your project root:

```bash
mkdir -p .cursor/skills
cp -r ~/.ai-skills/skills/testing/clean-code .cursor/skills/clean-code
```
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.

Skill Enumeration

Medium
Category
Agent Snooping
Content
From your project root:

```bash
mkdir -p .claude/skills
cp -r ~/.ai-skills/skills/testing/clean-code .claude/skills/clean-code
```
Confidence
85% confidence
Finding
Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Skill Enumeration

Medium
Category
Agent Snooping
Content
#### Claude Code (global)

```bash
mkdir -p ~/.claude/skills
cp -r ~/.ai-skills/skills/testing/clean-code ~/.claude/skills/clean-code
```
Confidence
85% confidence
Finding
Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

External Model or Provider Selection

Medium
Category
Excessive Agency
Content
---
name: clean-code
model: standard
category: testing
description: Pragmatic coding standards for writing clean, maintainable code — naming, functions, structure, anti-patterns, and pre-edit safety checks. Use when writing new code, refactoring existing code, reviewing code quality, or establishing coding standards.
version: 2.0
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
93% confidence
Finding
The description says the skill should be used for writing new code, refactoring, reviewing code quality, or establishing coding standards, which are broad triggers that could activate across many ordinary development tasks. Overly broad activation increases the chance this skill influences tasks outside its narrow intended scope, potentially overriding more task-specific safeguards or introducing unintended autonomous behavior in coding workflows.

Rp1

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding
The installation command uses `npx clawhub@latest install clean-code`, which fetches and executes the latest package version at runtime rather than a pinned, reviewed release. This creates a supply-chain risk: if the upstream package is compromised or a breaking/malicious version is published, users of the skill could execute untrusted code during installation.

Autonomous Decision Making

Medium
Category
Excessive Agency
Content
4. **NEVER write functions longer than 20 lines** — extract sub-functions until each does one thing
5. **NEVER nest deeper than 2 levels** — use guard clauses, early returns, or extract functions
6. **NEVER use magic numbers or strings** — define named constants with clear semantics
7. **NEVER edit a file without checking what depends on it** — broken imports and missing updates are the most common source of bugs in multi-file changes
8. **NEVER leave a task with failing lint or type checks** — fix all errors before marking complete

---
Confidence
75% confidence
Finding
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Missing User Warnings

Low
Confidence
81% confidence
Finding
This markdown file includes example code that performs safety-relevant actions such as charging via Stripe, writing orders to a database, sending email, and mutating inventory. Under the markdown-file criteria, the description does not provide any warning that these behaviors affect external systems or user data, so readers could reuse the example without seeing disclosure of those impacts.

Static analysis

No suspicious patterns detected.