Back to skill

Security audit

safe-subagent-spawn

Security checks for vulnerabilities and agentic risk

Overview

This skill is understandable, but it needs review because it permanently stores full subagent history and one helper can append to any writable file path it is given.

Install only if you are comfortable with permanent plaintext subagent audit files in the workspace. Avoid using it for secrets, credentials, regulated personal data, or sensitive business material unless you add retention, redaction, and path-containment safeguards first.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/append_to_context.py:123
Finding

Unrestricted Context Path Allows Arbitrary File Modification

Content
View full analysis

Vulnerability Details

File Location: scripts/append_to_context.py, lines 123–127 and 174–175
Vulnerability Type: Arbitrary file append through insufficient path validation
Risk Level: High

Vulnerable Code:

python
context_path = Path(args.context_file).expanduser().resolve()
if not context_path.is_file():
    print(f"Error: context file not found: {context_path}", file=sys.stderr)
    sys.exit(1)
python
with open(context_path, "a", encoding="utf-8") as f:
    f.write(entry)

Technical Analysis

The --context-file argument is entirely caller-controlled. Although the path is normalized with resolve() and checked with is_file(), the implementation does not verify that it is located inside the intended sub-agents context directory. It also does not validate that the target has the expected context-file format.

Consequently, any existing file writable by the current process can be selected as the append target. Resolving the path does not provide authorization; it only creates an absolute canonical path. Symlinks are also followed during resolution without an explicit policy rejecting them.

The appended body can come from --content, --content-file, or standard input. Although the helper surrounds most content with Markdown-style headers, the operation can still corrupt arbitrary files or inject data into formats where appended content has semantic meaning.

Attack Path

  1. An attacker directly invokes the helper or influences an Agent-generated invocation.
  2. The attacker supplies an existing writable file outside the context directory through --context-file.
  3. The attacker supplies controlled data through --content, --content-file, or standard input.
  4. The script resolves the path but performs no containment or context-format validation.
  5. The generated entry is appended to the selected file.
  6. The target is corrupted or, where the target format pro ...[truncated 1082 chars]
Remediation
View remediation

Remediation Suggestions

  1. Define one authoritative context root and require every target to remain within it after canonicalization:

    python
    context_root = CONTEXT_DIR.resolve()
    context_path = Path(args.context_file).expanduser().resolve(strict=True)
    
    if not context_path.is_relative_to(context_root):
        print("Error: context file is outside the permitted directory.", file=sys.stderr)
        sys.exit(1)
    
  2. Reject symbolic links explicitly when the security model does not require them. Where supported, use no-follow file-opening semantics to reduce time-of-check/time-of-use and symlink-swap risks.

  3. Require the .md extension and validate the expected context structure, including the metadata header and context-file declaration, before appending.

  4. Verify that the metadata path matches the actual canonical path.

  5. Open the target using descriptor-based APIs with restrictive flags, then validate and append through the same descriptor to reduce race conditions.

  6. Add negative tests covering absolute paths outside the context root, .. traversal, symlinks, malformed context files, and race-condition scenarios.

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:17
Finding

Permanent Plaintext Retention of Full Subagent Interaction History

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 17–18; implemented by scripts/create_context.py, lines 69–76, and scripts/append_to_context.py, lines 174–175
Vulnerability Type: Insecure storage and excessive retention of potentially sensitive data
Risk Level: Medium

Vulnerable Policy:

markdown
5. No summary mechanism. Every child output is preserved verbatim.
6. Context files are permanent and must not be deleted.

Relevant Implementation:

python
CONTEXT_DIR.mkdir(parents=True, exist_ok=True)
now = datetime.now().astimezone()
slug = validate_task_slug(args.task)
filename = f"{now.strftime('%Y%m%d-%H%M%S')}-{slug}.md"
context_path = CONTEXT_DIR / filename

content = build_context(slug, context_path, args.background, args.directive, now.isoformat())
context_path.write_text(content, encoding="utf-8")
python
with open(context_path, "a", encoding="utf-8") as f:
    f.write(entry)

Technical Analysis

The documented design requires all child output to be stored verbatim and retained permanently. The implementation writes that information to ordinary plaintext Markdown files without explicit restrictive permissions, encryption, secret filtering, retention limits, or secure deletion support.

File and directory permissions therefore depend on the runtime environment's default umask and existing parent-directory permissions. In shared workspaces, permissive environments, backups, or archived development artifacts, other principals may gain access to retained content.

Subagent history may include user-provided secrets, proprietary source code, credentials discovered during diagnostics, personal data, or sensitive command output. Preserving all output indefinitely violates data-minimization and storage-limitation principles and increases the consequences of a later workspace compromise.

Attack Path

  1. A user delegates a task containing sensitive ba ...[truncated 1287 chars]
Remediation
View remediation

Remediation Suggestions

  1. Replace permanent retention with a configurable retention period and provide an authenticated deletion mechanism.

  2. Create the context directory with owner-only permissions such as 0700 and context files with mode 0600, without relying solely on the process umask.

  3. Minimize stored information. Preserve only content necessary for task continuity rather than requiring complete verbatim history.

  4. Apply secret detection and redaction before writing backgrounds, directives, external messages, and child outputs. Cover common API keys, access tokens, private keys, passwords, and credential-bearing URLs.

  5. Warn users before storing content likely to contain sensitive data and provide a mode that avoids persistence for sensitive tasks.

  6. Encrypt retained context at rest where the workspace threat model includes other local users, shared storage, backups, or artifact collection.

  7. Ensure backup and logging systems inherit the same retention and access-control policy.

  8. Document who can access context files, how long they remain, and how users can securely remove them.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (11)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared description presents this skill as the mandatory safe wrapper for creating and managing subagents, specifically replacing direct sessions_spawn usage. The supplied code does not create subagents, invoke any spawning/session API, or manage detached helpers/workers. Its actual function is much narrower: it appends structured entries to an already existing context file and enforces ordering rules for directive/child-output/external-message sections. While this supports the described 'multi-round continuity via shared context files' aspect, it does not implement the primary declared purpose of subagent creation and management. Therefore the description materially overstates and misrepresents the code's behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The declared description presents this skill as the mandatory wrapper for creating and managing subagents, implying actual subagent spawning/delegation behavior and lifecycle support. The supplied code does not spawn, attach, manage, or otherwise control subagents at all. It only creates an initial markdown context file in a sub-agents directory and outputs its path. While that file may support a larger subagent workflow, the code chunk itself implements only one supporting piece: context initialization. It also does not implement full-text history sharing or multi-round continuity beyond writing the initial file contents. Therefore the description materially overstates the actual behavior of this code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The description claims a mandatory safe wrapper used to create and manage subagents, implying actual orchestration around subagent spawning and lifecycle management. The code instead is a narrow utility that reads a supplied context file, verifies it exists and contains a matching 'Directive' heading, then prints a JSON payload that could later be used to spawn a subagent. It neither calls sessions_spawn nor performs any direct creation, delegation, detachment, management, or continuity handling beyond pointing the child prompt at a context file. The actual behavior is therefore materially narrower than the declared purpose.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill explicitly mandates permanent retention of full context files containing user requests and child outputs, but it provides no privacy warning, retention limit, consent check, or guidance on sensitive data handling. In a subagent workflow, this creates a durable store of potentially confidential information that can later be exposed, reused, or over-shared across rounds.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

By requiring preservation and reuse of all user background and child content verbatim across rounds, the skill creates a persistent natural-language data channel that can accumulate sensitive data and replay it to later subagents. This increases confidentiality risk because each new round receives the full historical corpus, regardless of whether all prior data remains necessary.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

Mandating storage of the child's full verbatim output is dangerous because child agents may emit secrets, personal data, copyrighted content, unsafe instructions, or prompt-injected material. Persisting and replaying that output without review or filtering turns transient disclosure into durable disclosure and can amplify compromise across later subagent rounds.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The instructions encourage appending external messages and API-derived information into persistent context without any warning about sensitive data, origin trust, or downstream disclosure. This can cause operators to ingest and retain secrets, personal data, or untrusted content that is then replayed to future subagents.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Accumulating external messages for later directives enables gradual collection and replay of sensitive or manipulative content from outside sources. Because these messages are preserved and later fed back into delegated tasks, the pattern increases both data leakage risk and prompt-injection propagation risk.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The design principles explicitly require full-text retention and permanent storage of all subagent interactions, creating an ongoing accumulation of sensitive data with no expiry, minimization, or access-control discussion. In the context of delegated agents that may process varied user tasks, this materially raises confidentiality, privacy, and secondary disclosure risk over time.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The wrapper is presented as a safe mechanism for spawning subagents, but it explicitly sets cleanup to keep, preserving spawned sessions and their state instead of minimizing residual artifacts. In a delegation workflow, retained sessions can expose prior prompts, context paths, outputs, or agent state to later reuse or inspection, undermining the safety claim and increasing persistence of sensitive data.

Content

No source excerpt is available for this finding.