T09 · Insecure Skill Coding Practices
- Location
extract.py:90- Finding
Remote PDF Files Are Downloaded over Unencrypted HTTP
- Content
View full analysis
Vulnerability Details
File Location:
extract.py, line 90
Vulnerability Type: Unauthenticated remote content retrieval
Risk Level: MediumVulnerable Code
python report_id = row['报告ID'] date = row['公告日期'] pdf_url = f'http://pdf.dfcfw.com/pdf/H2_{report_id}_1.pdf' try: resp = requests.get(pdf_url, timeout=30) if len(resp.content) < 5000: continueThe same insecure URL scheme is documented in
SKILL.md, line 34:text http://pdf.dfcfw.com/pdf/H2_{报告ID}_1.pdfTechnical Analysis
The application retrieves untrusted PDF documents over plaintext HTTP and immediately processes the response with
pdfplumberor PyMuPDF. HTTP does not provide server authentication, integrity protection, or confidentiality. A network-positioned attacker can therefore replace or modify a downloaded report.The response is accepted based only on its size. The code does not call
raise_for_status(), validate the response content type, verify the PDF magic bytes, impose a maximum response size, or authenticate the document. PDF parsers process complex binary structures, so feeding attacker-controlled documents to them increases exposure to parser vulnerabilities and resource-exhaustion attacks.Attack Path
- A user runs the extractor on a network controlled or observable by an attacker.
- The script requests a report through
http://pdf.dfcfw.com/.... - The attacker intercepts or redirects the HTTP response.
- The attacker returns a crafted payload larger than 5,000 bytes.
- The script writes the payload to
temp.pdf. pdfplumberor PyMuPDF parses the attacker-controlled file.- The payload corrupts extracted results, consumes excessive resources, or attempts to exploit a vulnerability in the installed parser.
Impact Assessment
An attacker can alter the generated report content and potentially cause denial of service through oversized or computat ...[truncated 286 chars]
- Remediation
View remediation
Remediation Suggestions
- Require an HTTPS endpoint and reject redirects that downgrade to HTTP.
- Call
resp.raise_for_status()before consuming the response. - Stream downloads while enforcing a strict maximum file size.
- Validate the expected content type and require the file to begin with a valid PDF signature.
- Where supported, verify reports using a trusted digest or digital signature.
- Parse externally sourced PDFs in a sandbox with restricted filesystem access, network access, CPU time, and memory.
- Keep PyMuPDF, pdfplumber, and their transitive parsing components updated to reviewed versions.
