Back to skill

Security audit

Date Calculator

Security checks for vulnerabilities and agentic risk

Overview

The skill is a simple medical date calculator, but its optional output path can overwrite any file the running process can write, despite documentation implying workspace-limited output.

Review before installing. Use the skill only in a sandbox or read-only workspace unless the --output option is removed or restricted to a dedicated output directory with overwrite protection. Do not let an agent pass untrusted or broad filesystem paths to --output.

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 (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/main.py:130
Finding

Unrestricted Output Path Allows Arbitrary File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/main.py:130-144
Vulnerability Type: Unrestricted user-controlled file write
Risk Level: Medium

Vulnerable Code

python
parser.add_argument(
    "--output", "-o",
    type=str,
    help="Output JSON file path (optional)"
)

args = parser.parse_args()

# Output
output = json.dumps(result, indent=2)

if args.output:
    with open(args.output, 'w', encoding='utf-8') as f:
        f.write(output)
    print(f"Result saved to: {args.output}")
else:
    print(output)

Technical Analysis

The --output argument is accepted as an unrestricted path and passed directly to open() in write mode. The implementation does not resolve and validate the destination against an approved workspace directory, reject path traversal, detect symbolic links, or prevent replacement of an existing file.

Because mode 'w' truncates an existing file before writing, any file writable by the process can be replaced with the generated JSON. Relative traversal paths, absolute paths, and paths referencing symbolic links can all potentially reach files outside the intended project workspace. This also conflicts with the output-directory restriction identified in the security checklist in SKILL.md.

Attack Path

  1. An attacker or untrusted caller controls the command-line arguments used to invoke the Skill.
  2. The caller supplies a destination outside the intended workspace, such as:
    bash
    python scripts/main.py \
      --type followup \
      --date 2024-03-01 \
      --output ../../writable-target
    
  3. Alternatively, the caller points --output to a symbolic link whose target is a sensitive writable file.
  4. The path is passed to open(args.output, 'w') without validation.
  5. Python follows the path and truncates the target.
  6. The target's previous contents are replaced with the calculation result.

Impact Assessment

E ...[truncated 481 chars]

Remediation
View remediation

Remediation Suggestions

  1. Define an explicit approved output directory and resolve both it and the requested destination with pathlib.Path.resolve().
  2. Reject the destination unless it is a descendant of the approved directory.
  3. Reject absolute paths when they are not required.
  4. Reject symbolic-link destinations and verify that relevant parent directories are not symbolic links.
  5. Avoid silently overwriting existing files. Use exclusive creation mode ('x') where replacement is unnecessary.
  6. If replacement is required, write to a securely created temporary file in the same approved directory and atomically replace the intended destination.
  7. Run the Skill under a least-privileged operating-system account with write permission restricted to the designated output directory.
  8. Return a sanitized error when validation fails without exposing sensitive filesystem details.

Example workspace-bound validation:

python
from pathlib import Path

output_root = (Path.cwd() / "output").resolve()
output_root.mkdir(parents=True, exist_ok=True)

requested = Path(args.output)
if requested.is_absolute():
    raise ValueError("Absolute output paths are not allowed")

destination = (output_root / requested).resolve()
if output_root not in destination.parents:
    raise ValueError("Output path must remain within the output directory")

if destination.exists() or destination.is_symlink():
    raise ValueError("Refusing to overwrite an existing destination")

with destination.open("x", encoding="utf-8") as f:
    f.write(output)
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (4)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
84% confidence
Finding

The skill documentation indicates file write capability via the --output parameter and explicitly mentions saving output files, but it does not declare any tool scope such as permissions or allowed-tools. This creates a governance gap: an agent or reviewer cannot clearly enforce or audit what file operations are intended, increasing the risk of unintended file writes or misuse if the implementation is broader than described.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script accepts a user-controlled --output path and writes results directly to that location without restriction. In an agent or automated execution context, this creates an unintended arbitrary file write primitive that exceeds the stated purpose of a date-calculation skill and could overwrite files the process has permission to modify.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The arbitrary file output capability is not justified by the advertised functionality of a medical date calculator, so it meaningfully expands the attack surface with no clear operational need. In a skill ecosystem, unnecessary filesystem access is dangerous because it can be abused to plant, overwrite, or redirect data in ways unrelated to the calculation task.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The skill supports writing results to a user-specified output path, but the description and usage do not clearly warn users that running the skill may create or overwrite files. While not inherently dangerous, this omission can lead to accidental data exposure, overwriting of expected files, or misuse in automated agent workflows where file side effects must be explicit.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.