T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/scan_skill.py:171
- Finding
- Scan failures and missing targets are treated as safe<![CDATA[ ## Vulnerability Details **File Location**: `scripts/scan_skill.py:171-180, 186-209, 232-239`; `scripts/firewall_check.py:153-161, 214-219` **Vulnerability Type**: Fail-open security decision **Risk Level**: High ### Vulnerable Code ```python # scripts/scan_skill.py:171-180 if not skill_path.exists(): return ScanResult( skill_name=skill_name, skill_path=str(skill_path), threat_level=ThreatLevel.SAFE.value, threats_found=[], warnings=[f"Skill path does not exist: {skill_path}"], recommendations=[], is_safe=True ) ``` ```python # scripts/scan_skill.py:186-209 for root, dirs, files in os.walk(skill_path): for file in files: if file.endswith(('.py', '.sh', '.js', '.ts', '.ps1', '.bat', '.md')): file_path = os.path.join(root, file) threats = scan_file(file_path, MALICIOUS_PATTERNS) all_threats.extend(threats) critical_count = sum(1 for t in all_threats if t["level"] == "critical") high_count = sum(1 for t in all_threats if t["level"] == "high") medium_count = sum(1 for t in all_threats if t["level"] == "medium") if critical_count > 0: threat_level = ThreatLevel.CRITICAL is_safe = False recommendations.append("CRITICAL: Immediate review required. Critical security threats detected.") elif high_count > 0: threat_level = ThreatLevel.HIGH is_safe = False recommendations.append("HIGH: Review recommended. High-risk patterns detected.") elif medium_count > 0: threat_level = ThreatLevel.MEDIUM is_safe = True recommendations.append("MEDIUM: Consider reviewing medium-risk patterns.") elif all_threats: threat_level = ThreatLevel.LOW is_safe = True recommendations.append("LOW: Minor concerns detected. Review optional.") else: threat_level = ThreatLevel.SAFE is_safe = True recommendations.append("No security concerns detected.") ``` ```python # scripts/scan_skill.py:232-239 try: with open(fi ...[truncated 3005 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Return an explicit error or `UNKNOWN`/`SCAN_ERROR` state for nonexistent paths, unreadable files, malformed input, and interrupted scans. 2. Never set `is_safe=True` unless every in-scope file was inspected successfully. 3. Make firewall decisions fail closed: incomplete scans should result in `BLOCK` or `QUARANTINE`, not `ALLOW`. 4. Record every skipped file and the reason it was skipped in the scan result. 5. Expand file detection beyond a fixed extension list. Consider file signatures, shebangs, executable permission bits, and relevant configuration formats. 6. Reject unsupported executable content or require manual review. 7. Replace broad exception suppression with narrow exception handling and actionable diagnostics. 8. Add tests covering nonexistent paths, permission errors, malformed files, unsupported executable extensions, and partial scans. ]]>
