T09 · Insecure Skill Coding Practices
- Location
SKILL.md:84- Finding
Unsanitized Dynamic Values Used in Report Paths and Active HTML
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:84-92,references/report_template.md:72-87, andreferences/report_template.md:411-425
Vulnerability Type: Path traversal and stored HTML injection caused by missing input validation and contextual output encoding
Risk Level: MediumVulnerable Code
SKILL.md:84-92:markdown Output path: `~/Downloads/[brand_name]_restaurant_business_model_report_[YYYYMMDD].html` HTML specification: background `#faf8f5`, accent color `#c0392b`, PingFang SC font, centered with a maximum width of 900px, and card-based layout. Every core number must include a confidence rating (★★★ confirmed / ★★ inferred / ★ estimated), following Section 10 of `references/analytics_methodology.md`. Include `@media print` styles and a "📄 Export PDF" button. Disclaimer: This report is based on publicly available information, is provided for reference only, and does not constitute investment advice. --- ## Phase 5: Output and Display 1. Save and open the HTML using `open`The original file contains the equivalent instructions in Chinese. The security-relevant behavior is the direct interpolation of
[brand_name]into the output path followed by automatic opening of the generated file.references/report_template.md:72-87:html <div class="report-container"> <!-- Cover card: brand name, category, store scale, report date --> <div class="cover-card">...</div> <!-- Five main sections, each in an independent card --> <div class="section-card" id="part1">Strategy</div> <div class="section-card" id="part2">Tactics</div> <div class="section-card" id="part3">Metrics</div> <div class="section-card" id="part4">Restaurant Operations</div> <div class="section-card" id="part5">Extended Analysis</div> <!-- Overall assessment --> <div class="summa ...[truncated 4427 chars]- Remediation
View remediation
Remediation Suggestions
-
Normalize the filename
- Permit only a conservative allowlist such as letters, numbers, spaces, underscores, and hyphens.
- Replace all other characters with
_. - Remove
/,\,.., leading dots, control characters, shell metacharacters, and platform-specific reserved names. - Enforce a reasonable maximum filename length.
-
Verify path containment
- Resolve the Downloads directory and proposed output path to canonical absolute paths.
- Confirm that the final path is a child of the resolved Downloads directory.
- Reject generation if containment validation fails.
-
Use safe file creation
- Generate a unique filename rather than silently overwriting existing reports.
- Use exclusive or atomic file creation where supported.
- Avoid following symbolic links when creating the output file.
-
Encode every dynamic HTML value
- HTML-escape brand names, news titles, summaries, source names, metrics, and other retrieved text.
- Apply encoding appropriate to the destination context: text nodes, attributes, URLs, CSS, or JavaScript.
- Do not copy raw markup from search results into the report.
-
Validate links
- Permit only explicitly supported schemes, preferably
https:. - Reject
javascript:,data:,file:, and other unexpected schemes. - Add
rel="noopener noreferrer"to external links opened in a new browsing context.
- Permit only explicitly supported schemes, preferably
-
Reduce active-content exposure
- Replace the inline
onclickhandler with a static script loaded under a restrictive Content Security Policy, or omit scripting and instruct users to use the browser print command. - Add a Content Security Policy that blocks remote scripts, plugins, framing, and unexpected network destinations.
- Avoid automatically opening the report until validation and generation have completed successfully.
- Replace the inline
-
Treat web results as untrusted
- Ext ...[truncated 250 chars]
-
