Back to skill

Security audit

unisound-surgery-review

Security checks for vulnerabilities and agentic risk

Overview

This medical-record review skill has a legitimate purpose, but it can send sensitive records and bearer keys to configurable network endpoints and can optionally write plaintext prepared records to disk.

Review before installing in any environment with real patient data. Use only approved HTTPS guideline and LLM endpoints, avoid caller-supplied --base values, use --no-llm when records cannot leave the host, redact identifiers before input, and do not enable --save-prepared unless plaintext local retention is explicitly approved and protected.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/surgery_review.py:255
Finding

Caller-Controlled LLM Endpoint Can Receive Medical Records and Bearer Credentials

Content
View full analysis
str: selected_model = model_name or self._settings.default_model model_config = self._settings.models.get(selected_model) if model_config is None: raise ValueError(f"未找到模型配置: {selected_model}") payload = { "model": model_config.model_id or selected_model, "messages": [{"role": "user", "content": prompt}], "temperature": model_config.temperature, } if model_config.type == "openai_compatible": return self._post_chat( url=f"{model_config.base_url.rstrip('/')}/chat/completions", payload=payload, headers={"Authorization": f"Bearer {model_config.api_key}"}, ) raise ValueError(f"不支持的模型类型: {model_config.type}") def _post_chat(self, url: str, payload: dict[str, Any], headers: dict[str, str]) -> str: body = json.dumps(payload, ensure_ascii=False).encode("utf-8") req = request.Request( url=url, data=body, headers={"Content-Type": "application/json", **{key: value for key, value in headers.items() if value}}, method="POST", ) opener = request.urlopen(req) if not self._settings.timeout else request.urlopen(req, timeout=self._settings.timeout) ``` Selected medical-document contents are embedded directly in that prompt: ```python evidence_text = "\n\n".join( ( f"【文书#{doc['doc_index']} / {doc['doc_type']} / {doc['file_name']}】\n" f"{doc['content']}" ) ...[truncated 3157 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run.py:90
Finding

Optional Debug Feature Persists Complete Medical Records as Plaintext

Content
View full analysis
None: save_dir = Path(output_json).parent if output_json else ICD_DRG_DIR / "runs" / "surgery-review" save_dir.mkdir(parents=True, exist_ok=True) prepared_path = save_dir / f"{input_path.stem}.prepared.txt" prepared_path.write_text(record_to_prepared_text(payload), encoding="utf-8") print(f"Prepared text saved to: {prepared_path}", file=sys.stderr) ``` It is invoked when the optional command-line flag is supplied: ```python payload = load_record_payload(input_path, args.input_type, args.encoding, args.sheet) if args.save_prepared: save_prepared(payload, args.output_json or args.output, input_path) surgeries = merge_candidate_args(args.surgeries_json, args.surgery, default_role="other") ``` ### Technical Analysis `record_to_prepared_text` concatenates the contents of the record's documents, and `save_prepared` writes that content unencrypted to a persistent `.prepared.txt` file. The code does not explicitly set restrictive file permissions, enforce a retention period, redact patient identifiers, or remove the file after processing. The feature is opt-in and documented as a debugging option, which reduces exploitability. Nevertheless, medical records are highly sensitive, and writing complete intermediate data to a normal file creates a confidentiality risk beyond the minimum processing necessary for the coding-review operation. The behavior also conflicts with the broad statement in `SKILL.md` that the Skill does not persist request bodies or intermediate results locally. Although the later CLI documentation mentions `- ...[truncated 1526 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (16)

Tainted flow: 'req' from os.getenv (line 270, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/surgery_review.py (reported line 178)May include surrounding context.

python
headers["Authorization"] = f"Bearer {self._settings.api_key}"
        req = request.Request(url=url, headers=headers, method="GET")
        try:
            with request.urlopen(req, timeout=self._settings.timeout) as response:
                return json.loads(response.read().decode("utf-8"))
        except error.HTTPError as exc:
            if exc.code == 404:

Tainted flow: 'req' from os.getenv (line 270, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/surgery_review.py (reported line 276)May include surrounding context.

python
headers={"Content-Type": "application/json", **{key: value for key, value in headers.items() if value}},
            method="POST",
        )
        opener = request.urlopen(req) if not self._settings.timeout else request.urlopen(req, timeout=self._settings.timeout)
        with opener as response:
            response_payload = json.loads(response.read().decode("utf-8"))
        choices = response_payload.get("choices") or []

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 163)May include surrounding context.

md
- `scripts/run.py` 是唯一对外入口,复用 `scripts/surgery_review.py` 的核心审核逻辑。

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 165)May include surrounding context.

md
- 发布目录只保留 `SKILL.md`、`_meta.json`、`scripts/`;示例输入、运行输出、自测脚本放在 skill 包外。

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/surgery_review.py (reported line 98)May include surrounding context.

python
def load_guideline_api_settings_from_env() -> GuidelineApiSettings:
    return GuidelineApiSettings(
        base_url=_required_env("GUIDELINE_API_BASE"),
        api_key=os.getenv("GUIDELINE_API_KEY", ""),
        timeout=_env_int("GUIDELINE_API_TIMEOUT", 30),

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The code sends selected medical-record document content and audit prompts to a configurable LLM endpoint, which is a material data exfiltration path not disclosed by the manifest. Because evidence docs can contain protected health information and narrative clinical details, transmitting them to external model providers creates significant confidentiality and compliance exposure.

Content

No source excerpt is available for this finding.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/surgery_review.py (reported line 323)May include surrounding context.

python
for candidate in surgery_code_lookup_candidates(surgery_code):
        guideline = guideline_repository.find_guideline_by_code(candidate)
        if guideline is not None:
            return guideline
    return None

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/surgery_review.py (reported line 476)May include surrounding context.

python
"source": "列出对应的原文摘录(含文书类型/页码/关键句)"
}}
    """
    return prompt


def _normalize_text(value: str) -> str:

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill transmits medical-record content to external services without any user-facing warning, consent mechanism, or disclosure at the point of use. For clinical documents, silent outbound transfer increases the risk of privacy violations, regulatory noncompliance, and misuse of sensitive patient data.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Caller-controlled base URL and app key allow the skill to send case data to arbitrary attacker-chosen endpoints under the guise of LLM review. In a medical-record auditing skill, this greatly amplifies exfiltration risk because untrusted callers can redirect sensitive case content outside approved infrastructure.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill documentation advertises capabilities that imply access to environment variables, local file read/write, and outbound network calls, but it does not declare any explicit tool scope such as permissions or allowed-tools. In a medical-record review skill, this is risky because sensitive patient data, API keys, and prepared record text could be accessed or exfiltrated through undeclared channels, and operators cannot enforce least-privilege from the manifest alone.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The code sends the full medical record payload and an authentication key to review_surgery_payload, together with configurable base and model parameters, implying transmission of PHI to an external or internal LLM endpoint. In a medical-coding review skill, this is especially sensitive because records may contain extensive patient data, and the endpoint is user-selectable via CLI, creating data disclosure and secret-handling risk if misconfigured or pointed to an untrusted service.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script can persist preprocessed medical-record text to disk via --save-prepared, and the generated content includes concatenated document contents from the patient record. Because this skill processes highly sensitive healthcare data, writing plaintext debug artifacts to local storage materially increases confidentiality risk through accidental retention, backup exposure, shared-host access, or later exfiltration.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill performs remote guideline retrieval over HTTP(S), which introduces undisclosed external data flows into a medical-coding review workflow that appears local from the manifest. In healthcare contexts, even metadata such as procedure codes and identifiers can be sensitive, and hidden network dependencies increase privacy and supply-chain risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

Authenticated remote guideline lookup occurs without user disclosure, creating a hidden external dependency and undisclosed data transfer channel. While less severe than full document transmission, sending procedure-related context to remote services can still expose sensitive operational or patient-linked information.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The prompt and expected response values force Chinese-language interaction and output, and multiple user-facing errors/help strings elsewhere in the file are also Chinese-only. The file does not offer user language selection or explain that the skill is intentionally limited to a Chinese-language regional workflow.

Content

No source excerpt is available for this finding.