T09 · Insecure Skill Coding Practices
- Location
scripts/doc_generator.py:675- Finding
Unsanitized Repository Content Is Embedded into Generated Markdown
- Content
View full analysis
Vulnerability Details
File Location:
scripts/api_scanner.py:71,scripts/database_scanner.py:109,scripts/doc_generator.py:675,717,745,scripts/main.py:104
Vulnerability Type: Stored Markdown and HTML content injection
Risk Level: MediumVulnerable Code
Source content is read from an analyzed repository:
python # scripts/api_scanner.py:71 content = controller_file.read_text(encoding='utf-8', errors='ignore')python # scripts/database_scanner.py:109 content = sql_file.read_text(encoding='utf-8', errors='ignore')Extracted comments and descriptions are interpolated directly into Markdown:
python # scripts/doc_generator.py:675 - **描述**: {ep.get('description', '无描述')}python # scripts/doc_generator.py:717 lines.append(f"| {col.get('name', '')} | {col.get('type', '')} | {col.get('comment', '')} |")python # scripts/doc_generator.py:745 - 描述: {ep.get('description', '无描述')}The resulting content is then written without sanitization:
python # scripts/main.py:104 output_file.write_text(final_content, encoding='utf-8')Technical Analysis
The analyzer treats source repositories as trusted input. Java documentation comments and SQL column comments can originate from an untrusted contributor or a malicious third-party repository. These values are inserted directly into generated Markdown without escaping:
- Raw HTML elements
- Markdown image and link syntax
- Table delimiters
- Backticks and code-fence delimiters
- Dangerous URL schemes
- Renderer-specific active content
ConstraintCheckeronly searches for a short list of placeholder strings and does not sanitize HTML or Markdown.EntropyManagerreformats content but does not apply a security policy.Consequently, malicious repository text can persist in generated APID, SDD, or DBD documents. When a user opens those files, the effect depends on the Markdo ...[truncated 1475 chars]
- Remediation
View remediation
Remediation Suggestions
- Treat every value extracted from a target repository as untrusted.
- Apply context-aware Markdown escaping before interpolation, including escaping pipes, backticks, brackets, parentheses, and heading markers.
- Strip or encode raw HTML tags unless HTML output is an explicitly required feature.
- Reject dangerous URL schemes such as
javascript:,data:, andfile:. - Consider blocking remote images and other automatically loaded resources.
- Use structured Markdown-generation helpers rather than direct string interpolation.
- Keep source-derived text inside clearly delimited, escaped code blocks where appropriate.
- Add tests containing malicious JavaDoc and SQL comments, including HTML tags, remote images, links, table delimiters, and code fences.
- Document that generated files should be opened with a renderer that disables raw HTML and active content.
