T09 · Insecure Skill Coding Practices
- Location
SKILL.md:104- Finding
Unsafe Recursive Deletion of a Predictable Staging Directory
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 104-109
Vulnerability Type: Unsafe recursive deletion using a fixed directory path
Risk Level: MediumTechnical Analysis
The documented synchronization workflow assigns a predictable, relative path to
STAGING_DIRand recursively deletes that path before creating the staging structure:bash SOURCE_DIR="./files" STAGING_DIR="./staging" BUCKET="my-bucket" # Create staging directory with prefix structure rm -rf "$STAGING_DIR" mkdir -p "$STAGING_DIR"The quoting prevents argument splitting, but it does not make the deletion intrinsically safe. If
./stagingalready contains unrelated user data, following the documented example permanently deletes that data. The example also does not verify that the path was created exclusively for this operation, reject symbolic-link components in the path, or constrain deletion to a securely generated temporary directory.The executable script uses
mktemp -d, so this finding specifically concerns the alternative workflow provided in the skill documentation.Attack Path
- A user has an existing directory named
stagingunder the working directory, or runs the example from an unexpected directory containing such a path. - The user copies and executes the documented “Efficient Bulk Sync” workflow.
STAGING_DIRresolves to the pre-existing relative path./staging.rm -rf "$STAGING_DIR"recursively deletes its contents before the upload begins.
Impact Assessment
Exploitation does not grant additional operating-system privileges; deletion occurs with the permissions of the user executing the example. Within that privilege boundary, all accessible content under the selected
./stagingpath can be permanently removed. The primary impact is local data loss and disruption of other processes that use the same directory.- A user has an existing directory named
- Remediation
View remediation
Remediation Suggestions
-
Replace the fixed staging directory with a securely generated temporary directory:
bash STAGING_DIR=$(mktemp -d) || exit 1 cleanup() { rm -rf -- "$STAGING_DIR" } trap cleanup EXIT -
Refuse to continue if temporary-directory creation fails.
-
Use
rm -rf -- "$STAGING_DIR"so a path beginning with a hyphen cannot be interpreted as an option. -
Keep the staging directory outside the source directory and document that it is temporary.
-
Do not present destructive cleanup of a fixed relative directory as the recommended workflow.
-
