T09 · Insecure Skill Coding Practices
Error
- Location
- src/sast-analyzer.js:318
- Finding
- Regex-Only Static Analysis Produces Security-Relevant False Negatives and False Positives<![CDATA[ ## Vulnerability Details **File Location**: `src/sast-analyzer.js:318-325, 365-380` **Vulnerability Type**: Inadequate static-analysis validation **Risk Level**: High ### Vulnerable Code ```javascript for (const file of files) { const content = fs.readFileSync(file, 'utf-8'); results.filesScanned++; results.linesScanned += content.split('\n').length; // Execute all rule checks const fileFindings = this.scanContent(content, file); results.findings.push(...fileFindings); } ``` ```javascript scanContent(content, filePath) { const findings = []; for (const [category, rules] of Object.entries(this.rules)) { for (const rule of rules) { if (rule.pattern.test(content)) { findings.push({ id: rule.id, category, severity: rule.severity, title: rule.title, description: rule.description, file: path.relative(process.cwd(), filePath), cwe: rule.cwe }); } } } return findings; } ``` ### Technical Analysis Every rule is applied as a regular expression against the complete textual contents of a file. The implementation does not parse language syntax, identify executable syntax nodes, distinguish comments and documentation from executable code, track values across variables, or perform control-flow and data-flow analysis. This causes false positives because examples in Markdown files and comments are treated as actual behavior. It also causes false negatives because dangerous operations can be hidden through aliases, computed property access, string concatenation, multiline expressions, wrappers, or indirect calls. Only one finding is generated per rule and file, even if the pattern occurs multiple times. Findings do not include the matched text or a source line, making independent verification difficult. ### Attack Path 1. An attacker creates a Skill containing a dangerous operation that the scanner is expected to detect. 2. The attack ...[truncated 941 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse supported languages into abstract syntax trees and inspect executable syntax nodes rather than raw text alone. 2. Add interprocedural taint and data-flow analysis for untrusted input reaching command, network, filesystem, and dynamic-code sinks. 3. Treat Markdown code blocks and comments as documentation findings rather than executable behavior unless the instructions direct the Agent to execute them. 4. Report every occurrence with the exact matched evidence, source line, column, and confidence. 5. Add normalization for aliases, computed properties, multiline expressions, and common wrappers. 6. Clearly mark regex-only checks as heuristic and prevent a clean heuristic scan from being represented as proof of safety. 7. Add regression tests covering both evasions and benign documentation examples. ]]>
