T09 · Insecure Skill Coding Practices
- Location
SKILL.md:387- Finding
Unsafe Bulk Source Modification Through Whitespace-Unsafe Shell Pipeline
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 387–393
Vulnerability Type: Unsafe destructive command generation
Risk Level: MediumComplete Code Snippet
bash # Preview (does not modify): grep -rn "console\.log" src/ --include="*.ts" --include="*.js" # Remove (careful — review first): find src/ -name "*.ts" -o -name "*.js" | xargs sed -i '/console\.log/d'Technical Analysis
The Skill recommends a destructive shell command that passes newline-delimited
findoutput toxargs. Becausexargssplits input on whitespace, source paths containing spaces, tabs, quotes, backslashes, or newlines will not be passed tosedas intact filenames. A split path component may consequently be interpreted as a separate file located outside the intendedsrc/tree.The command also deletes entire lines based on a textual pattern rather than parsing JavaScript or TypeScript syntax. A line containing
console.logmay include additional expressions, control flow, callbacks, or security-relevant side effects. Deleting that entire line can therefore alter application behavior rather than merely remove diagnostic output.The
findpredicates are not grouped, no-type frestriction is used, no backup is created, and there is no transactional rollback or mandatory review stage. These characteristics exceed the minimum privilege necessary for a static logging auditor, whose core function only requires read access. The optional fix guidance introduces broad write access over project source files.Attack Path
- An attacker or untrusted project contributor creates a matching source path containing whitespace, such as
src/placeholder target.js. - A separate file named
target.jsexists in the command's working directory and contains a line matchingconsole.log. - A user invokes the Skill's fix workflow and executes the recommended command.
xargssplitssrc/placeholder target.jsinto ...[truncated 1033 chars]
- An attacker or untrusted project contributor creates a matching source path containing whitespace, such as
- Remediation
View remediation
Remediation Suggestions
-
Do not generate automatic line-deletion commands for JavaScript or TypeScript. Use a language-aware parser or formatter to remove only the logging call while preserving surrounding expressions and control flow.
-
Generate a reviewable patch instead of modifying files directly. Require the user to inspect and approve the patch before application.
-
If a shell-based fallback is retained, use null-delimited paths and grouped predicates:
bash find src/ -type f \( -name '*.ts' -o -name '*.js' \) -print0 | xargs -0 grep -nH 'console\.log'This should remain preview-only; it should not be converted directly into a destructive
sedoperation. -
If automated edits are essential, restrict changes to explicitly selected files, create backups or use version-control patches, validate that resolved paths remain under the intended source directory, and provide a rollback mechanism.
-
Keep the default audit workflow read-only so that its filesystem privileges remain aligned with the declared static-analysis functionality.
-
