T09 · Insecure Skill Coding Practices
- Location
- scripts/scan.py:765
- Finding
- Attacker-Controlled Markdown Headings Can Suppress Critical Findings<![CDATA[ ## Vulnerability Details **File Location**: `scripts/scan.py:765-777, 831-848, 876-888` **Vulnerability Type**: Untrusted-content-driven severity suppression **Risk Level**: High ### Vulnerable Code ```python _DOCUMENTATION_HEADINGS = re.compile( r'(?:red\s*flag|check\s*(?:for|list)|reject|warning|danger|' r'do\s*not|never|avoid|suspicious|malicious|vetting|review|' r'safe\s*pattern|what\s*(?:it|to)\s*(?:detect|scan|check|look)|' r'detect(?:ion|s|ed)|limitation|example\s*(?:of|:)|' r'owasp|vulnerabilit|common\s*(?:attack|threat|issue)|' r'security\s*(?:guide|best|tip|practice|overview))', re.IGNORECASE ) ``` ```python # Headings — check if the heading suggests documentation of dangers heading_match = re.match(r'^(#{1,6})\s+(.*)', line) if heading_match: depth = len(heading_match.group(1)) heading_text = heading_match.group(2) if _DOCUMENTATION_HEADINGS.search(heading_text): doc_section_active = True doc_section_depth = depth elif depth <= doc_section_depth: # A same-or-higher-level heading ends the doc section doc_section_active = False doc_section_depth = 99 ctx.line_contexts[line_num] = "heading" continue # Content under documentation headings if doc_section_active: ctx.checklist_lines.add(line_num) ctx.line_contexts[line_num] = "documentation_list" continue ``` ```python def adjust_finding_for_context(finding: dict, md_ctx: MarkdownContext) -> dict: """Adjust a finding's severity if it's in a documentation context.""" line = finding.get("line", 0) if is_documentation_context(md_ctx, line): finding = dict(finding) # copy original_severity = finding["severity"] finding["severity"] = "info" finding["context"] = ( f"[DOCUMENTATION CONTEXT — downgraded from {original_severity}] " + finding.get("context", "") ) finding["in_documentation"] = True else: ...[truncated 2262 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not downgrade executable code blocks, shell commands, installation instructions, or imperative steps solely because of their enclosing heading. 2. Preserve `critical` severity for inherently dangerous patterns such as remote-content shell pipelines, private-key access, credential exfiltration, and persistence installation. 3. Limit contextual adjustment to at most one severity level rather than changing every finding to `info`. 4. Require an explicit, narrowly defined safe-example marker for documentation-only snippets, and visibly report that such a marker was supplied by untrusted content. 5. Analyze linguistic intent and Markdown structure together. Commands under headings such as “installation,” “setup,” “run,” or numbered operational steps should remain actionable findings. 6. Add adversarial tests in which malicious commands appear below every recognized documentation-heading keyword. 7. Ensure that no attacker-controlled contextual metadata can produce a nominally safe verdict when critical execution patterns are present. ]]>
