T09 · Insecure Skill Coding Practices
- Location
handler.py:230- Finding
Unsanitized User Input Enables Markdown Output Injection
- Content
View full analysis
Vulnerability Details
File Location:
handler.py, lines 230-236
Vulnerability Type: Markdown output injection through unsanitized user-controlled fields
Risk Level: MediumVulnerable Code
python lines.append(f'- Platform read: {platform}') if minutes: lines.append(f'- Available time: about {minutes} minutes') else: lines.append('- Available time: not fully specified, so the guide defaults to lower-friction choices first.') lines.append(f'- Budget pressure: {budget}') lines.append(f'- Recent pattern: {recent}')Technical Analysis
The
platform,budget, andrecentvariables originate from the caller-controlledargs["input"]value. They are interpolated directly into a Markdown response without escaping Markdown metacharacters, removing line breaks, restricting their length, or otherwise validating their structure.An attacker can supply embedded newlines and Markdown syntax to terminate the intended list item and create arbitrary headings, links, or misleading instructions. For example, a platform value such as:
text Switch ## Required Action [Sign in to continue](https://attacker.example)would cause the generated response to contain a forged section that may appear to be trusted skill output. The vulnerability affects presentation integrity rather than granting direct code execution.
Attack Path
- An attacker supplies a crafted dictionary or JSON object through
args["input"]. _coerce_input()accepts and normalizes the object without constraining field content._pick()and_score_profiles()propagate the craftedplatform,budget, or recent-game value._build_result()directly interpolates the value into Markdown.- A client renders the response as trusted Markdown.
- The injected headings, links, or instructions appear as part of the legitimate recommendation and may mislead the user into following attacker-control ...[truncated 711 chars]
- An attacker supplies a crafted dictionary or JSON object through
- Remediation
View remediation
Remediation Suggestions
- Treat all values derived from
args["input"]as untrusted presentation data. - Replace carriage returns, line feeds, and other control characters with spaces before inserting values into inline Markdown fields.
- Escape Markdown-significant characters such as backslashes, backticks, brackets, parentheses, asterisks, underscores, hash characters, angle brackets, and pipe characters.
- Enforce explicit type and maximum-length constraints for fields such as platform, budget, and recent games.
- Prefer structured output fields over concatenated Markdown when the caller can render the response itself.
- If Markdown output is required, place untrusted values in safely escaped code spans or quoted blocks and use a renderer configured to disable raw HTML and unsafe URL schemes.
- Add regression tests using multiline values, headings, links, raw HTML, control characters, and oversized input to confirm that user data cannot alter the response structure.
- Treat all values derived from
