T09 · Insecure Skill Coding Practices
- Location
scripts/analyzer.py:265- Finding
Broken Score Normalization Produces Unreliable Risk Classifications
- Content
View full analysis
Dict[str, float]: """Calculate weighted scores.""" scores = {} for dimension, config in self.DIMENSIONS.items(): score = self.results.get(dimension, 0) scores[dimension] = score * config["weight"] * 10 return scores def _weighted_average(self, scores: Dict[str, float]) -> float: """Calculate weighted average.""" return sum(scores.values()) def _assess_risk(self, scores: Dict[str, float]) -> str: """Assess overall risk level.""" overall = sum(scores.values()) if overall >= 7.5: return "LOW" elif overall >= 5: return "MEDIUM" else: return "HIGH" ``` ### Technical Analysis Each raw dimension score is already expressed on a scale from 0 to 10. The calculation multiplies that score by its configured weight and then multiplies it by 10 again: ```python score * config["weight"] * 10 ``` Because the dimension weights sum to 1, this produces an aggregate range of 0 to 100. However, `_assess_risk()` applies thresholds designed for a range of 0 to 10. Consequently, an aggregate score only needs to reach 7.5 out of 100 to be classified as `LOW` risk. The same incorrectly scaled values are exposed as dimension scores and printed as though each were out of 10. For example, the functionality dimension has a weight of 0.25 and can produce a displayed value as high as 25. This is security-relevant because the tool is explicitly presented as a security review mechanism for third-party skills. A severely unsafe skill can receive an authoritative-looking `LOW` risk result when modest points from non-security dimensions overwhelm the incorrectly scaled threshold. ### Attack Path 1. An attacker prepares a malicious or unsafe ...[truncated 1249 chars]- Remediation
View remediation
