Back to skill

Security audit

Referral Letter Generator

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real medical referral letter generator, but it has unsafe and under-disclosed dependency installation and file-handling behavior around sensitive patient data.

Install only in an isolated environment, do not use real patient data unless storage and transmission meet your healthcare privacy requirements, avoid HTML output for untrusted input, and preinstall pinned dependencies yourself instead of allowing runtime package installation. Treat output paths as sensitive and keep them inside an approved secure directory.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (4)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/main.py:294
Finding

Unescaped Medical Data Allows Active HTML Injection

Content
View full analysis
REASON FOR REFERRAL

{data.reason_for_referral.replace(chr(10), '
')}

``` The same unsafe interpolation pattern also affects patient and provider details, diagnoses, medical history, medications, allergies, vital signs, laboratory results, and additional notes in `scripts/main.py:244-331`. ### Technical Analysis Values loaded from the input JSON are interpolated directly into an HTML document. Replacing newline characters with `
` does not encode HTML metacharacters such as `<`, `>`, `"`, or `&`. An attacker who can influence referral data can therefore insert arbitrary HTML, including script elements, event handlers, external resources, misleading forms, or document-structure-breaking markup. For example, a referral reason containing an image with an `onerror` handler would be written as active markup rather than displayed as text. This issue is especially significant because generated referral documents contain protected health information. If the output is opened directly in a browser, hosted by an internal application, embedded into a web page, or passed into an email workflow, the injected markup may execute under the security context assigned to that document. ### Attack Path 1. An attacker supplies or modifies the input referral JSON. 2. The attacker places active HTML in `reason_for_referral` or another rendered field. 3. `load_from_json()` accepts the value without sanitization. 4. `generate_html()` interpolates the value directly into the document. 5. The generated HTML file is delivered to a healthcare worker or uploaded to another system. 6. When the file is rendered, the attacker-controlled markup executes or modifies the displayed referral. 7. Dependin ...[truncated 921 chars]
Remediation
View remediation
`, ``, malformed closing tags, and encoded HTML entities. ]]>

T08 · Insecure Dependencies

Warning
Location
requirements.txt:1
Finding

Unpinned and Incorrect Dependency Declarations Create Supply-Chain Risk

Content
View full analysis
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
scripts/main.py:352
Finding

Document Generation Automatically Installs Unpinned Packages at Runtime

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/main.py:554
Finding

Caller-Controlled Output Path Allows Overwriting Arbitrary Writable Files

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (20)

os.system() or os exec-family call

High
Category
Dangerous Code Execution
Confidence
96% confidence
Finding

The code executes a shell command at runtime to install a missing dependency using os.system(). Even though the package name is hardcoded, invoking a shell from an application that handles medical data expands the attack surface, permits unreviewed code installation from external sources, and can be abused if the execution environment or package supply chain is compromised.

Content

Scanner excerpt · scripts/main.py (reported line 355)May include surrounding context.

python
from reportlab.lib.units import inch
        except ImportError:
            print("Warning: reportlab not installed. Installing required package...")
            os.system(f"{sys.executable} -m pip install reportlab -q")
            from reportlab.lib import colors
            from reportlab.lib.pagesizes import letter
            from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill's stated purpose is generating referral letters, but it performs shell-based package installation unrelated to core document generation at runtime. This behavior is dangerous because it introduces network/supply-chain and command-execution risk into a workflow expected to only format and write clinical documents.

Content

No source excerpt is available for this finding.

os.system() or os exec-family call

High
Category
Dangerous Code Execution
Confidence
96% confidence
Finding

This branch also launches a shell command to install python-docx during document generation. In a healthcare context, runtime package installation is especially risky because it introduces remote code execution via package install paths and mixes privileged system changes with processing of sensitive patient information.

Content

Scanner excerpt · scripts/main.py (reported line 473)May include surrounding context.

python
from docx.enum.text import WD_ALIGN_PARAGRAPH
        except ImportError:
            print("Warning: python-docx not installed. Installing required package...")
            os.system(f"{sys.executable} -m pip install python-docx -q")
            from docx import Document
            from docx.shared import Inches, Pt
            from docx.enum.text import WD_ALIGN_PARAGRAPH

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The DOCX path likewise installs a package by executing a shell command, which exceeds the expected scope of a referral-letter generator. In medical workflows this is more dangerous because operators may trust the tool with PHI while it silently performs external code retrieval and installation.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The tool writes referral content containing PHI/PII directly to user-specified files, and in sample mode also writes a JSON file with medical details to disk. While persistence is part of the feature, the lack of safeguards, warnings, access controls, or secure-handling guidance can lead to unintended disclosure through insecure locations, shared systems, backups, or leftover files.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill advertises and operationalizes shell execution plus file read/write behavior, but it does not declare any explicit tool scope such as allowed-tools or permissions. In a healthcare context handling PHI, this increases the risk of over-broad execution, unintended file access, and unsafe invocation patterns because consumers cannot reliably constrain what the skill is permitted to do.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The 'when to use' section expands beyond medical referral-letter generation into broad academic-writing and generic workflow scenarios, which weakens scope boundaries and can cause the skill to be invoked for tasks it was not designed or reviewed to handle. Over-broad triggers are dangerous because they increase the chance of misuse, prompt confusion, and processing of inappropriate or sensitive data under an ill-fitting workflow.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The usage examples show writing referral letters to local files without prominent warnings that the outputs may contain highly sensitive PHI. In a medical context, insufficient warning and handling guidance can lead users to save patient data in insecure locations, commit it to repositories, or expose it through logs, backups, and shared workspaces.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The quick reference demonstrates generating referral letters with directly identifiable patient and provider information, but provides no warning about handling protected health information, secure storage, transmission, or environmental safeguards. In a medical context, this omission can lead users to process real patient data in insecure files, email attachments, shared directories, or logs, increasing the risk of privacy and compliance violations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file instructs users to include full legal name, date of birth, MRN, contact details, and insurance information in referral letters. Although HIPAA compliance is mentioned later, the document does not clearly warn users that the skill involves sensitive patient data handling and privacy-sensitive content generation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The template explicitly collects and renders multiple categories of sensitive health information and identifiers, including name, DOB, MRN, contact details, insurance, diagnoses, medications, labs, and imaging, but provides no privacy, minimum-necessary, or secure-handling guidance. In a medical referral context, this increases the risk of over-disclosure, unsafe transmission, and accidental inclusion of protected health information beyond what is necessary for the referral.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This template is designed to collect and reproduce highly sensitive health information, including direct identifiers, insurance data, MRN, clinical history, medications, labs, and imaging, but it provides no privacy, minimum-necessary, or secure-handling guidance. In a healthcare documentation skill, that omission increases the risk that users will paste, store, or transmit protected health information insecurely or more broadly than needed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The application automatically installs a package after only printing a warning, without requiring explicit approval. This is unsafe because users may not expect system modification or network activity from a document generator, and in regulated environments silent dependency installation can violate change-control and security expectations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The DOCX generation path repeats automatic package installation without prior confirmation. In the context of a medical letter generator, unexpected package installation is more concerning because it occurs alongside handling of sensitive patient data and may execute in trusted clinical environments.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

This JSON contains natural-language sample data anchored to a specific U.S. healthcare context, including address formatting and English-language clinical text, but provides no indication that the skill supports locale choice or that the constraint is intentional. For a reusable skill artifact, hard-coded locale assumptions can violate language/locale policy expectations when not documented or user-selectable.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency is unpinned, so builds may resolve to different versions over time and can unexpectedly introduce vulnerable or incompatible releases. In a medical letter generation skill, dependency drift can affect document generation reliability and increase supply-chain risk even if this line itself is not directly exploitable.

Content

Scanner excerpt · requirements.txt (reported line 1)May include surrounding context.

text
dataclasses
docx
enum
reportlab

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The docx package is unpinned, allowing installation of any future or currently available version that satisfies the name, which creates supply-chain and reproducibility risk. For a skill that generates referral letters, document-processing libraries handle untrusted content paths and file formats, so uncontrolled version changes are more concerning than in a trivial utility.

Content

Scanner excerpt · requirements.txt (reported line 2)May include surrounding context.

text
dataclasses
docx
enum
reportlab

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
92% confidence
Finding

The enum dependency is unpinned, which permits non-reproducible installs and potential exposure to malicious or vulnerable upstream releases. This is also suspicious from a hygiene perspective because enum is often unnecessary on modern Python versions, increasing the chance of accidental dependency confusion or redundant package usage.

Content

Scanner excerpt · requirements.txt (reported line 3)May include surrounding context.

text
dataclasses
docx
enum
reportlab

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
99% confidence
Finding

reportlab is unpinned, which means deployment may pull a version with known vulnerabilities or future insecure changes. Given this skill likely generates medical referral documents, a vulnerable PDF/document library is more dangerous because it may process attacker-controlled content and has a history of serious issues including RCE and SSRF.

Content

Scanner excerpt · requirements.txt (reported line 4)May include surrounding context.

text
dataclasses
docx
enum
reportlab

Unverifiable Dependency: reportlab has 8 known advisory(ies) (CVE-2023-33733 (Reportlab vulnerable to remote code execution); CVE-2020-28463 (Server-side Request Forgery (SSRF) via img tags in reportlab); CVE-2019-19450 (ReportLab vulnerable to remote code execution via paraparser) +5 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
98% confidence
Finding

The manifest includes reportlab without a version pin even though the package has multiple published advisories, including severe issues such as remote code execution and SSRF in some releases. Because the installed version cannot be verified, there is a real risk that deployments may resolve to an affected release, especially dangerous in a document-generation skill that may embed or parse user-influenced content.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.