T09 · Insecure Skill Coding Practices
- Location
scripts/run.py:82- Finding
Unsanitized Drug Name Permits Output Path Traversal
- Content
View full analysis
- Remediation
View remediation
str: value = re.sub(r"[^A-Za-z0-9_-]+", "_", str(value)).strip("_") return value[:100] or "unknown" output_root = Path(out_dir).resolve() safe_drug_name = safe_filename_component(drug_name) md_path = (output_root / f"bd_valuation_{safe_drug_name}_{ts}.md").resolve() if output_root not in md_path.parents: raise ValueError("Output path escapes the configured output directory") ``` 4. Apply the same validation to Markdown, HTML, and PPT output. 5. Add regression tests using traversal strings, absolute-path syntax, Windows separators, Unicode separators, and excessively long names. ]]>
