T09 · Insecure Skill Coding Practices
- Location
scripts/emr_qc_impl.py:112- Finding
Prompt Injection Through Untrusted Medical Record Content
- Content
View full analysis
str: """体格检查结果与现病史不符""" pe = fields["pe"] hpi = fields["hpi"] if not pe or not hpi: return "无缺陷" return llm([user_msg( f"""你是一位病历质控专家,请对门诊病历进行质控,如果没有缺陷请直接回答"无缺陷",不要进行任何分析;如果有缺陷请先回答"有缺陷"再另起一行分析原因 缺陷描述: 1.现病史提及"昏迷,意识不清,意识障碍,意识模糊",体格检查中出现"神志清楚,精神可,查体合作,自主体位,步态正常,步入病房",有缺陷 2.现病史提及"瘫痪",体格检查中出现"查体合作,自主体位,步态正常,步入病房",有缺陷 3.现病史提及"口角歪斜",体格检查中出现"面容正常,面容及表情正常",有缺陷 4.现病史提及"淤斑淤点",体格检查中"无淤斑淤点,无皮下出血",有缺陷 5.现病史提及血红蛋白低于60g/L,体格检查中"无贫血貌",有缺陷 6.现病史提及触及淋巴结肿大,体格检查中"全身未触及淋巴结肿大",有缺陷 7.如果体格检查未记录实质性内容,则不存在不符的情况,判定为"无缺陷" 以下是一些示例,用标记,请参考 【病历】 现病史:患者9小时前无明显诱因下出现晕厥,被家属发现后送至急诊。患者呈浅昏迷状态,双侧瞳孔等大等圆,光反迟钝。 体格检查:体温36.0℃ 脉搏112次/分 呼吸22次/分 血压95/54mmHg,发育正常,营养良好,自主体位 【质控结果】 有缺陷 体格检查结果(自主体位)与现病史(浅昏迷)不符 【病历】 现病史:患者家属发现患者中昏迷状态,GSC评分E1V1M3。 体格检查:体温37.4℃ 脉搏88次/分 呼吸17次/分 血压143/83mmHg,被动体位 【质控结果】 无缺陷 【病历】 现病史:背痛就诊否认高血压 体格检查:血压146/92mmHg,神清状可,双肺(-),HR64次/分,律齐,未及杂音。 【质控结果】 无缺陷 现在请对下面的门诊病历进行质控,请注意,如果体格检查中提及某种情况而现病史中没有提及,或者现病史提及某种情况而体格检查中没有提及,不触发本条质控规则,直接回答"无缺陷" 【病历】 现病史:{hpi} 体格检查:{pe} 【质控结果】""" )]) ``` ### Technical Analysis The history and physical-examination fields are untrusted input, but they are interpolated directly into the same user-role message that contains the model's operational instructions. No structural separation, escaping, injection detection, or authoritative system-role instruction protects the intended task. An attacker who can influence an imported medical record can insert model directives into either field. For example, the record could instruct the model to ignore all preceding criteria and return the no-defect response. Because the model receives both application rules and ...[truncated 1310 chars]- Remediation
View remediation
