T09 · Insecure Skill Coding Practices
- Location
router.sh:50- Finding
Arbitrary Command Execution Through Sourced Model Cache
- Content
View full analysis
"$CACHE_FILE" echo "MODEL_CODE=$MODEL_CODE" >> "$CACHE_FILE" echo "MODEL_WEB=$MODEL_WEB" >> "$CACHE_FILE" echo "MODEL_CHAT=$MODEL_CHAT" >> "$CACHE_FILE" echo "MODEL_DOC=$MODEL_DOC" >> "$CACHE_FILE" echo "MODEL_DATA=$MODEL_DATA" >> "$CACHE_FILE" echo "auto_detected=1" >> "$CACHE_FILE" ``` ```bash load_cached_models() { if [ -f "$CACHE_FILE" ]; then local cache_age=$(($(date +%s) - $(stat -f%m "$CACHE_FILE" 2>/dev/null || stat -c%Y "$CACHE_FILE" 2>/dev/null || echo 0))) if [ "$cache_age" -lt "$CACHE_TTL" ]; then # Load cached configuration source "$CACHE_FILE" 2>/dev/null if [ "$auto_detected" == "1" ]; then echo -e "${BLUE}✅ 使用缓存的模型配置(剩余有效期:$((CACHE_TTL - cache_age)) 秒)${NC}" return 0 fi fi fi return 1 } ``` ### Technical Analysis The model cache is intended to contain data, but it is loaded with the Bash `source` command. `source` does not parse the file as inert configuration data; it executes every shell statement in the file in the current process. The cache path is partially controlled through `HIVE_CACHE_DIR`. The implementation does not verify that the directory and file: - Are owned by the current user. - Are not symbolic links. - Have restrictive permissions. - Contain only approved assignment keys. - Contain values matching an expected model-identifier format. Consequently, anyone able to control `HIVE_CACHE_DIR`, write to the selected cache file, replace it with a sy ...[truncated 1724 chars]- Remediation
View remediation
