Back to skill

Security audit

Obscure Package Master

Security checks for vulnerabilities and agentic risk

Overview

This skill has a coherent coding-assistance goal, but it should be reviewed carefully because it downloads arbitrary PyPI source, extracts it unsafely, and installs generated agent skills from untrusted package text.

Review before installing. Use this only in a sandbox or with an explicit safe output directory, only for package versions you intentionally chose, and avoid letting it write generated mirrors into global agent skill folders. Treat generated mirrors as untrusted reference data, not as instructions.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (4)

T08 · Insecure Dependencies

Error
Location
scripts/generate_mirror.py:60
Finding

Package-Controlled Build Code May Execute During Source Download

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_mirror.py, lines 60-62
Vulnerability Type: Unsafe processing of untrusted source distributions
Risk Level: High

python
def download_package(package, version, tmp_dir):
    print(f"Downloading {package}=={version}...")
    cmd = ["pip", "download", "--no-binary=:all:", f"{package}=={version}", "-d", tmp_dir]
    subprocess.run(cmd, check=True)

Technical Analysis

The generator invokes pip download with --no-binary=:all:, forcing pip to retrieve a source distribution rather than a prebuilt wheel. Processing a source distribution can cause pip to create an isolated build environment and invoke package-controlled PEP 517 build-backend hooks to obtain metadata or prepare the distribution. Legacy package formats may similarly involve execution of packaging code.

The package name and version are accepted directly from command-line arguments. There is no package allowlist, artifact hash verification, trusted publisher validation, build-backend restriction, or execution sandbox. Although the command uses an argument array and is not vulnerable to shell metacharacter injection, it still intentionally passes an untrusted package to a tool capable of invoking package-controlled build logic.

Attack Path

  1. An attacker publishes a malicious or typo-squatted package, compromises an existing package, or gains control of a selected release.
  2. The package includes a malicious build backend or other packaging code that runs while pip processes source-distribution metadata.
  3. A user or Agent invokes the generator with the attacker-controlled package and version.
  4. The generator runs pip download --no-binary=:all:.
  5. Pip processes the source distribution and invokes package-controlled build behavior.
  6. The malicious code executes with the operating-system privileges and environment available to the generator process.

Impact Assessment

Successful exploitation can provide arbit ...[truncated 577 chars]

Remediation
View remediation

Remediation Suggestions

  • Do not use pip to process untrusted source distributions merely to retrieve source files.
  • Retrieve artifacts through a data-only mechanism, such as the PyPI JSON API followed by a direct HTTPS artifact download.
  • Require an expected cryptographic hash and verify it before processing the artifact.
  • Prefer verified wheels when static source inspection is sufficient, while still treating their contents as untrusted.
  • Maintain an explicit package and repository allowlist where operationally possible.
  • If source-distribution processing is unavoidable, perform it inside a disposable sandbox or container with:
    • No host credentials or API keys.
    • No writable access to the user’s home directory or Agent configuration.
    • No privileged filesystem mounts.
    • Restricted outbound network access.
    • CPU, memory, process, and execution-time limits.
  • Record the resolved artifact URL, hash, package version, and index origin for auditability.
  • Consider passing explicit index configuration rather than inheriting potentially unsafe pip configuration from the environment.

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/generate_mirror.py:83
Finding

Archive Path Traversal Through Unsafe Tar Extraction

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_mirror.py, lines 83-84
Vulnerability Type: Unvalidated extraction of an untrusted archive
Risk Level: High

python
    if archive_path.endswith(".tar.gz") or archive_path.endswith(".tar.bz2"):
        with tarfile.open(archive_path) as tar:
            tar.extractall(path=extract_path)

Technical Analysis

The generator extracts package-controlled tar archives using tarfile.extractall() without validating archive member paths or types. The project declares support for Python 3.9+, including versions where safe extraction filters are not applied automatically.

A malicious tar archive can contain absolute paths, .. traversal components, symbolic links, hard links, device entries, or combinations of links and later file entries. Without explicit validation, extraction may create or overwrite files outside the intended tmp_download/extracted directory.

The same routine handles content downloaded from a package repository, so archive contents cross an external trust boundary before being written to the local filesystem.

Attack Path

  1. An attacker supplies or compromises a package source distribution.
  2. The source archive contains a member such as ../../target-file, an absolute path, or a link that redirects a later extraction outside the staging directory.
  3. The generator downloads and selects the malicious archive.
  4. tar.extractall(path=extract_path) processes the malicious member without a containment check.
  5. A file is created or overwritten at an attacker-selected location writable by the current user.
  6. If the target is an Agent configuration, Skill file, shell startup file, or executable script, the overwrite may lead to subsequent instruction manipulation or code execution.

Impact Assessment

The attacker can potentially write outside the extraction directory anywhere permitted by the invoking user’s filesystem privileges. This may allow modification ...[truncated 367 chars]

Remediation
View remediation

Remediation Suggestions

  • Validate every archive member before extraction.
  • Reject:
    • Absolute paths.
    • Paths containing traversal components.
    • Members whose resolved destination escapes the extraction root.
    • Symbolic links and hard links unless they are strictly required and safely validated.
    • Device files, FIFOs, sockets, and other special entries.
  • Resolve the intended extraction root and each destination with os.path.realpath() or pathlib.Path.resolve(), then enforce containment with os.path.commonpath().
  • On Python versions that support extraction filters, use tar.extractall(path=extract_path, filter="data") as defense in depth. Do not rely on it as a substitute for version-independent containment validation.
  • Extract only regular files and directories needed for static analysis.
  • Apply equivalent path and entry validation to ZIP and wheel extraction.
  • Perform extraction inside a disposable sandbox with no writable access to sensitive host paths.
  • Add security tests using absolute-path, traversal, symbolic-link, hard-link, and special-file archive fixtures.

T01 · Skill Instruction Hijacking

Error
Location
scripts/generate_mirror.py:144
Finding

Untrusted Package Content Is Promoted Into Agent Skill Instructions

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_mirror.py, lines 144-163
Vulnerability Type: Generated Skill instruction injection
Risk Level: High

python
    # Build SKILL.md
    skill_md_path = os.path.join(skill_dir, "SKILL.md")
    with open(skill_md_path, "w") as f:
        f.write(f"---\nname: {skill_name}\ndescription: Deterministic API mirror for {package} v{version}. Use this skill to grounded exploration of {package} API when uncertainty is high.\n---\n\n")
        f.write(f"# {package} v{version} Grep Map\n\n")
        f.write("This map provides a deterministic coordinate system for the package source. All paths are relative to `references/`.\n\n")
        
        # Organize by file
        by_file = {}
        for item in grep_map:
            by_file.setdefault(item['file'], []).append(item)
            
        for file_path, items in sorted(by_file.items()):
            f.write(f"## File: `{file_path}`\n\n")
            # Sort items by line range to be deterministic
            items.sort(key=lambda x: x['range'][0])
            for item in items:
                f.write(f"- **`{item['signature']}`**\n")
                f.write(f"  - Range: `lines {item['range'][0]}-{item['range'][1]}`\n")
                if item['doc']:
                    f.write(f"  - Doc: {item['doc']}\n")

Technical Analysis

Function signatures and first-line docstrings are read from an externally downloaded package and inserted directly into a generated SKILL.md. Package and path values are also interpolated into Markdown and YAML frontmatter without a strict escaping or validation policy.

The parent Skill instructs the Agent to activate and read the generated Skill. Consequently, package-authored prose is moved from an untrusted source-code artifact into an instruction-bearing Agent document. A malicious package author can place prompt-like directives in a function docstring. When the generated Skill is loaded, the Agent may interpre ...[truncated 1712 chars]

Remediation
View remediation

Remediation Suggestions

  • Do not insert package-controlled docstrings, source comments, or other natural-language package content into SKILL.md.
  • Store the grep map in a data-only format such as JSON with a defined schema.
  • Keep the generated SKILL.md static and include only trusted instructions explaining how to access the data file.
  • Omit docstrings from the instruction document. If documentation is needed, retain it only inside reference source files or a separately labeled untrusted-data artifact.
  • Ensure the Agent-facing loader explicitly states that all package-derived content is untrusted reference data and must never be followed as instructions.
  • Apply strict validation to package names and versions before using them in directory names, YAML, or Markdown.
  • Serialize YAML frontmatter through a safe YAML library rather than string interpolation.
  • Escape Markdown control characters and reject control bytes or unexpected line breaks in generated display fields.
  • Prefer installing generated mirrors in an isolated per-task data directory rather than a global skills directory.
  • Require explicit user approval before registering any generated artifact as an Agent Skill.
  • Add tests containing adversarial docstrings, Markdown directives, YAML delimiters, and instruction-like text to verify that they remain inert.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/generate_mirror.py:244
Finding

Predictable Temporary Directory Is Recursively Deleted

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_mirror.py, lines 244-246 and 264-265
Vulnerability Type: Unsafe temporary-directory handling and destructive path reuse
Risk Level: Medium

python
    tmp = "tmp_download"
    if os.path.exists(tmp):
        shutil.rmtree(tmp)
    os.makedirs(tmp)
python
    finally:
        if os.path.exists(tmp):
            shutil.rmtree(tmp)

Technical Analysis

The generator uses the fixed relative path tmp_download under the current working directory. If that path already exists, it is recursively deleted before processing begins and again during cleanup.

The code does not verify that the existing path was created by the current process, does not use an exclusive temporary-directory primitive, and does not protect against concurrent generator executions. A legitimate directory with the same name can therefore be deleted. Concurrent runs can also delete or replace each other’s staging data, producing integrity failures and race conditions.

Because the path is relative, its target depends on the caller’s current working directory rather than a controlled system temporary location.

Attack Path

  1. A legitimate directory named tmp_download exists in the directory from which the generator is launched, or another process is using that path.
  2. The generator starts and observes that the path exists.
  3. It invokes shutil.rmtree(tmp) without checking ownership or provenance.
  4. The entire pre-existing directory tree is deleted.
  5. Alternatively, two concurrent generator runs use the same path and one run removes files while the other is downloading, extracting, or analyzing them.

Impact Assessment

The primary impact is deletion or corruption of files writable by the current user beneath a pre-existing tmp_download directory. The issue can also cause denial of service, inconsistent generated mirrors, or analysis of unintended files during concurrent execution.

The deletio ...[truncated 161 chars]

Remediation
View remediation

Remediation Suggestions

  • Replace the fixed directory with tempfile.TemporaryDirectory():
python
import tempfile

with tempfile.TemporaryDirectory(prefix="package-mirror-") as tmp:
    extract_path = download_package(pkg, ver, tmp)
    # Continue processing inside the unique directory.
  • Never recursively delete a pre-existing path that the current process did not create.
  • Use the unique path returned by the temporary-directory API and keep cleanup scoped to that path.
  • Avoid current-working-directory-relative staging paths.
  • If manual temporary-directory management is unavoidable:
    • Create the directory atomically with a random name.
    • Use restrictive permissions.
    • Record that the current process created it.
    • Reject symbolic links and unexpected file types.
    • Remove only that exact verified directory.
  • Add concurrency tests to ensure multiple generator instances cannot delete or corrupt one another’s temporary files.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • 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 (11)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
4. **Use the Grep Map:** Read the `SKILL.md` of the newly created skill. It contains a map of all classes and functions with their exact line ranges.

Session Persistence

Medium
Category
Rogue Agent
Confidence
82% confidence
Finding

The skill explicitly instructs the agent to download arbitrary PyPI packages and persist a full local copy of their source in .skills/ and references/. This creates durable session-to-session state from untrusted external content, which can later influence agent behavior if the mirrored code or generated skill artifacts are referenced without strong trust boundaries.

Content

Scanner excerpt · README.md (reported line 9)May include surrounding context.

md
## How it works

1.  **Grep Map Generation:** The `scripts/generate_mirror.py` script downloads any Python package from PyPI and uses AST parsing to create a "grep map".
2.  **Coordinate System:** The map identifies every class and function, its full signature, first-line docstring, and exact line ranges.
3.  **Deterministic Mirror:** The script creates a local skill for that specific package version in `.skills/`, including a full copy of the source code in `references/`.
4.  **Zero Hallucination:** When the agent needs to use the package, it refers to the grep map and performs surgical `read_file` calls on the local source.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README says the skill should trigger when an agent's uncertainty with a package API is '> 5%', but it does not define how uncertainty is measured or when the threshold applies. This leaves activation scope unclear and could cause inconsistent or unintended invocations across many normal coding situations.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill instructs the agent to execute a Python script, read environment-derived configuration, and write a new installed skill, but it declares no explicit tool restrictions or permissions. That combination increases the chance an agent will grant broad shell and filesystem access implicitly, enabling unintended code execution, persistence through skill installation, or writing into provider-specific skill directories.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger criteria are broad and subjective, such as using the skill whenever uncertainty exceeds 5% or when documentation feels sparse, so the skill may activate in many normal development contexts. Because activation leads to code execution and creation of a new skill artifact, vague invocation boundaries materially increase the likelihood of unnecessary risky operations.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The hardcoded provider-specific installation paths cause the script to place generated artifacts into live agent skill directories by default, expanding its behavior from local generation into automatic installation. That increases the blast radius of any generated or mirrored content and can modify agent behavior without an explicit, narrowly scoped install step.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/generate_mirror.py (reported line 69)May include surrounding context.

python
def download_package(package, version, tmp_dir):
    print(f"Downloading {package}=={version}...")
    cmd = ["pip", "download", "--no-binary=:all:", f"{package}=={version}", "-d", tmp_dir]
    subprocess.run(cmd, check=True)
    
    # Find the downloaded file that best matches the package name
    files = os.listdir(tmp_dir)

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script inspects provider-identifying and API-key environment variables to infer which agent platform is active, even though generating a package mirror does not require reading credential-related environment state. This creates unnecessary secret-adjacent access and enables behavioral changes based on the host environment, which is risky in a skill that should be deterministic and minimally scoped.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The code checks for sensitive environment variable names associated with API credentials without user-facing disclosure or strict necessity. Even if it only tests for presence, this is still sensitive-environment inspection that can reveal host context and condition behavior on secrets-related state in a way users may not expect.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
93% confidence
Finding

The test dependency is specified as pytest>=7.0 without an upper bound or exact pin, which makes builds non-reproducible and can pull in newly released versions with security or compatibility regressions. In this file the dependency is only for testing, so the security impact is limited, but it is still a real supply-chain hygiene weakness.

Content

Scanner excerpt · requirements.txt (reported line 6)May include surrounding context.

text
# Requirement: 'pip' command available in PATH

# Test dependencies
pytest>=7.0

Unverifiable Dependency: pytest has 2 known advisory(ies) (CVE-2025-71176 (pytest has vulnerable tmpdir handling); CVE-2025-71176 (pytest has vulnerable tmpdir handling)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
84% confidence
Finding

The manifest references pytest without pinning to a specific version, so there is no way to verify whether installation will select a release affected by the cited advisory. Because this is a test-only dependency, the practical impact is lower than a runtime dependency, but it still introduces avoidable uncertainty and potential exposure in developer or CI environments.

Content

No source excerpt is available for this finding.