shell-safety

Validates URLs, DOIs, and filesystem paths before constructing shell commands with untrusted input.

43|8|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/buriedsignals/spotlight --skill shell-safety-buriedsignals
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shell-safety
Source: https://github.com/buriedsignals/spotlight/tree/main/skills/shell-safety
Command: npx skills add https://github.com/buriedsignals/spotlight --skill shell-safety-buriedsignals

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Shell commands built by interpolating user, model, scraped, or generated strings are vulnerable to injection, path traversal, and accidental destructive operations. This Skill enforces safe command construction by validating untrusted values before they reach a shell. ## Core Features & Use Cases - Input Validation: Rejects shell metacharacters, invalid URL schemes, credential-bearing URLs, malformed DOIs, NUL bytes, and leading-dash path segments. - Path Containment: Resolves candidate paths and confirms they stay inside an allowed base directory, blocking traversal attacks. - Destructive Operation Probes: Runs a non-destructive probe with the same resolved arguments before any copy, move, delete, or archive extraction, and records results in a run log. - Use Case: An agent needs to download a file from a user-supplied URL into a case directory. It validates the URL scheme and host, resolves the output path against the allowed base, then builds the curl command with --data-urlencode instead of string interpolation. ## Quick Start Before running any shell command containing user-provided values, use the shell-safety helper to validate the URL and resolve the output path within the allowed base directory.

Frequently Asked Questions about shell-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely pass user input into shell commands?

Pass untrusted values as argv, stdin, environment variables, temp files, or structured JSON instead of interpolating them into command strings. Validate values first to reject shell metacharacters like backticks, $, ;, &, |, <, and >.

How to validate a URL before using it with curl in Python?

Parse the URL with urllib.parse and require an http or https scheme, a present host, no embedded credentials, and no fragments. Also reject control characters and shell metacharacters before passing it to curl, preferably with --data-urlencode for query values.

How do I prevent path traversal when resolving file paths?

Resolve the candidate path against an allowed base directory and verify the resolved path equals the base or sits under it. Reject leading-dash segments, NUL bytes, and any path that escapes the base after resolution.

Why is quoting a CLI argument not enough to stop shell injection?

Shell-quoted arguments still let the shell interpret quotes, backticks, and $ substitutions. Prefer stdin, validated temp files, environment variables, or structured JSON, and reject dangerous characters if a single quoted argument is unavoidable.

What should I check before running destructive file operations?

Resolve all paths, confirm each is inside the expected base directory, and run a non-destructive probe with the same resolved arguments first. Record the probe output, inspect it, then execute and log the real operation.