T09 · Insecure Skill Coding Practices
- Location
install.sh:3- Finding
Configuration is created and deleted outside the skill directory
- Content
View full analysis
"$BASE_DIR/.env" << 'EOF' # OpenAI API Configuration OPENAI_API_KEY=your-api-key-here # 可选:使用代理 # HTTP_PROXY= # HTTPS_PROXY= EOF echo "⚠️ 请编辑 $BASE_DIR/.env 文件,填入你的 OPENAI_API_KEY" fi ``` ```bash # uninstall.sh SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BASE_DIR="$(dirname "$SCRIPT_DIR")" read -p "是否删除配置文件和备份数据?(y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then rm -f "$BASE_DIR/.env" rm -rf "$BASE_DIR/.ai_meeting_backup" rm -rf "$BASE_DIR/.ai_meeting_logs" echo "✅ 已删除配置和备份" fi ``` ```python # source/meeting_helper.py BASE_DIR = Path(__file__).parent.parent load_dotenv(BASE_DIR / ".env") ``` ### Technical Analysis The shell scripts are located in the project root. Consequently, `SCRIPT_DIR` is already the project directory, while `BASE_DIR="$(dirname "$SCRIPT_DIR")"` resolves to its parent. The installer therefore creates `.env`, `.ai_meeting_backup`, and `.ai_meeting_logs` in the parent workspace rather than inside the skill. The Python application calculates its base directory differently: the parent of `source/` is the project root. It attempts to load `.env` from the project itself, not from the parent directory used by the installer. This mismatch can cause configuration failure and may encourage users to place an API key in an unintended shared workspace file. The uninstaller uses the same incorrect shell path and can remove the parent directory's `.env` after a generic confirmation. That file may belong to another project or contain unrelated credentials ...[truncated 1257 chars]- Remediation
View remediation
&2; exit 1 ;; esac ``` 6. Use `--` before path operands passed to `rm` and other filesystem utilities. 7. Restrict the credential file to the current user after creation: ```bash chmod 600 "$BASE_DIR/.env" ``` ]]>
