T09 · Insecure Skill Coding Practices
Error
- Location
- index.js:27
- Finding
- Negative telemetry values allow risk-score manipulation and detection bypass<![CDATA[ ## Vulnerability Details **File Location**: `index.js`, lines 27-29 and 51-58 **Vulnerability Type**: Improper input validation and risk-score manipulation **Risk Level**: High ### Complete Code Snippet ```js const trustScore = Number.isFinite(bot.trustScore) ? bot.trustScore : 50; const incidents = Number.isFinite(bot.incidents) ? bot.incidents : 0; const anomalyCount = Number.isFinite(bot.anomalyCount) ? bot.anomalyCount : 0; // ... score += incidents * 8; score += anomalyCount * 5; if (trustScore < 50) score += Math.min(25, 50 - trustScore); let action = 'allow'; if (score >= 80) action = 'quarantine'; else if (score >= 50) action = 'block'; else if (score >= 25) action = 'watch'; ``` ### Technical Analysis The implementation checks whether `incidents` and `anomalyCount` are finite numbers but does not enforce non-negative values or reasonable upper bounds. Both fields are added directly to the risk score. Consequently, negative values subtract points from the score. A sufficiently negative value can offset any combination of hostile indicators, including data-exfiltration signals, privilege escalation, identity spoofing, and quarantine-bypass attempts. For example, a record with `quarantineBypass: true` receives 40 risk points, but setting `incidents: -100` subtracts 800 points. The resulting score remains below the `watch` threshold, causing the skill to return `allow`. The weak top-level validator at `index.js:72-73` does not prevent this condition because it validates only that the input is an object: ```js async validate(input) { return !input || typeof input === 'object'; } ``` ### Attack Path 1. An attacker gains control over, or can influence, a bot telemetry record submitted to the skill. 2. The attacker includes one or more genuine hostile indicators, such as `quarantineBypass: true` or `exfiltrationSignals: 1`. 3. The attacker supplies a large negative finite value for `incidents` or `anomalyCount`. 4. `evaluateBot()` mult ...[truncated 1092 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Require `incidents` and `anomalyCount` to be non-negative integers. - Apply documented upper bounds to prevent unrealistic values and numeric abuse. - Constrain `trustScore` to its intended range, such as 0 through 100. - Reject malformed telemetry instead of silently substituting defaults for security-sensitive fields. - Add schema validation before evaluating any bot record. - Consider clamping the final risk score to a documented range. - Add tests proving that negative, fractional, excessively large, and incorrectly typed values are rejected. Example hardening: ```js const isBoundedInteger = (value, min, max) => Number.isInteger(value) && value >= min && value <= max; if (!isBoundedInteger(bot.incidents, 0, 10000)) { throw new TypeError('incidents must be an integer between 0 and 10000'); } if (!isBoundedInteger(bot.anomalyCount, 0, 10000)) { throw new TypeError('anomalyCount must be an integer between 0 and 10000'); } if (!Number.isFinite(bot.trustScore) || bot.trustScore < 0 || bot.trustScore > 100) { throw new TypeError('trustScore must be a finite number between 0 and 100'); } ``` ]]>
