Back to skill

Security audit

Phy Monorepo Dep Graph

Security checks for vulnerabilities and agentic risk

Overview

The skill’s purpose is coherent, but its workspace-discovery instructions can be steered by a repository to read package manifests outside the chosen project.

Install only if you are comfortable with the agent reading local package manifests during analysis. Use it on trusted repositories, and prefer a version that rejects absolute workspace patterns, '..' path components, and symlink escapes before reading any discovered manifest.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:120
Finding

Workspace Manifest Patterns Can Escape the Authorized Repository Root

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:120-132 and SKILL.md:175-188
Vulnerability Type: Unvalidated path traversal through repository-controlled workspace glob patterns
Risk Level: Medium

Vulnerable Code

python
workspace_patterns = root_pkg.get('workspaces', [])

# pnpm-workspace.yaml format
pnpm_cfg = f'{root}/pnpm-workspace.yaml'
if os.path.exists(pnpm_cfg):
    import yaml  # pyyaml
    cfg = yaml.safe_load(Path(pnpm_cfg).read_text())
    workspace_patterns = cfg.get('packages', [])

# Expand glob patterns to actual directories
pkg_dirs = []
for pattern in workspace_patterns:
    matched = glob.glob(f'{root}/{pattern}', recursive=True)

The same weakness is present in Cargo workspace discovery:

python
workspace_toml = Path(f'{root}/Cargo.toml').read_text()

# Extract workspace members
member_match = re.search(r'members\s*=\s*\[(.*?)\]', workspace_toml, re.DOTALL)
if not member_match:
    return packages

members = re.findall(r'"([^"]+)"', member_match.group(1))
for pattern in members:
    for pkg_dir in glob.glob(f'{root}/{pattern}'):
        toml_path = f'{pkg_dir}/Cargo.toml'
        if not os.path.exists(toml_path):
            continue
        content = Path(toml_path).read_text()

Technical Analysis

Workspace patterns are obtained from repository-controlled package.json, pnpm-workspace.yaml, and Cargo.toml files. These patterns are concatenated with the selected repository root and passed directly to glob.glob() without canonicalization or containment checks.

A workspace pattern can contain parent-directory components such as ../../other-project/*. Although the resulting string begins with the selected root, filesystem path resolution processes the .. components and may locate directories outside that root. A symlinked workspace directory can produce a similar boundary escape.

Once an external directory matches, the d ...[truncated 2241 chars]

Remediation
View remediation

Remediation Suggestions

Enforce repository-root containment before accepting or reading any workspace match:

  1. Resolve the configured root once with Path(root).resolve().
  2. Reject absolute workspace patterns.
  3. Reject patterns containing parent-directory traversal components.
  4. Resolve every matched directory before use.
  5. Verify that each resolved candidate remains beneath the resolved root.
  6. Apply the same validation to npm, pnpm, Yarn, and Cargo discovery.
  7. Define an explicit symlink policy. For strict isolation, reject workspace directories that resolve through symlinks outside the root.
  8. Skip invalid entries and report them as security warnings rather than processing them.

Example containment helper:

python
from pathlib import Path

def require_within_root(root: Path, candidate: Path) -> Path:
    resolved_root = root.resolve(strict=True)
    resolved_candidate = candidate.resolve(strict=True)

    if not resolved_candidate.is_relative_to(resolved_root):
        raise ValueError(
            f"Workspace path escapes repository root: {resolved_candidate}"
        )

    return resolved_candidate

Validate patterns before glob expansion and validate every result afterward:

python
root_path = Path(root).resolve(strict=True)

for pattern in workspace_patterns:
    pattern_path = Path(pattern)

    if pattern_path.is_absolute() or '..' in pattern_path.parts:
        raise ValueError(f"Unsafe workspace pattern: {pattern}")

    for match in root_path.glob(pattern):
        pkg_dir = require_within_root(root_path, match)

        manifest = require_within_root(
            root_path,
            pkg_dir / 'package.json'
        )
        if manifest.is_file():
            content = manifest.read_text()

Because glob patterns and symlink resolution have separate security implications, both pre-expansion pattern validation and post-expansion canonical-path cont ...[truncated 34 chars]

Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

These phrases are broad natural-language requests that could arise in many package-management or architecture discussions. Without explicit scoping to internal workspace packages or monorepo manifests, the activation boundary is unclear.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger list includes "dependency graph" as a standalone activation phrase. That phrase is common across many domains and does not clearly constrain invocation to monorepo internal dependency analysis, increasing the risk of unintended activation.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.