T09 · Insecure Skill Coding Practices
- Location
scripts/scaffold.sh:4- Finding
Command and Generated-Configuration Injection Through an Unvalidated Project Name
- Content
View full analysis
}" LANG="${2:?Specify python or typescript}" DIR="$NAME-mcp-server" mkdir -p "$DIR" ``` ```bash sed -i "s/REPLACE_NAME/$NAME/g" "$DIR/server.py" ``` ```bash cat > "$DIR/package.json" <- Remediation
View remediation
&2 exit 1 fi ``` - Generate JSON through a JSON-aware utility or language runtime rather than an interpolated heredoc. - Avoid constructing `sed` programs with untrusted values. Pass the name to a small Python or Node.js template renderer that performs literal replacement. - Canonicalize the destination path and verify that it remains beneath an explicitly selected output directory. - Add tests for quotes, slashes, ampersands, backslashes, newlines, traversal components, and shell metacharacters. ]]>
