T09 · Insecure Skill Coding Practices
- Location
scripts/md2pdf.py:263- Finding
Unrestricted External Resource Loading During Markdown-to-PDF Conversion
- Content
View full analysis
None: with open(md_path, "r", encoding="utf-8") as f: md_text = f.read() extensions = [ "extra", # tables, fenced_code, footnotes, etc. "codehilite", # syntax highlighting hints "toc", # table of contents "sane_lists", # better list handling "smarty", # smart quotes ] extension_configs = { "codehilite": { "css_class": "highlight", "guess_lang": False, }, } html_body = markdown.markdown( md_text, extensions=extensions, extension_configs=extension_configs, output_format="html5", ) full_html = f""" {CSS_STYLESHEET} {html_body} """ HTML(string=full_html).write_pdf(pdf_path) ``` ### Technical Analysis The converter reads the entire input Markdown file, converts it to HTML, and passes the generated document directly to WeasyPrint without sanitizing embedded HTML or restricting resource URLs. Python-Markdown permits raw HTML in Markdown by default. Consequently, attacker-controlled Markdown can contain resource-loading elements such as images or other HTML constructs referencing absolute URLs. WeasyPrint may resolve these resources while rendering the PDF. This creates a server-side request forgery and privacy-leak surface. Requests originate from the machine running the Skill rather than from the attacker, potentially giving them access to network locations not directly reachable from their own system. The code does not define a custom WeasyPrint `url_fetcher`, enforce an allowed protocol list, ...[truncated 1259 chars]- Remediation
View remediation
