diff --git a/pipeline_service/gateway.py b/pipeline_service/gateway.py index 0c0fccd..510d27d 100644 --- a/pipeline_service/gateway.py +++ b/pipeline_service/gateway.py @@ -147,6 +147,18 @@ class Gateway: from pipeline_core.agent_config import load_agent_config from .agent_loop_v2 import AgentExecutor + # 0. 空输入守卫(2026-09-07 实测安全缺陷):空/纯空白消息绝不进 LLM。 + # 实测根因:curl --data-urlencode 'prompt@不存在的文件' 发出空 prompt, + # 空用户消息下 LLM 自由发挥——一次幻觉出 delete_project 要求确认, + # 一次直接调 run_command 执行 python3 heredoc(非危险清单命令, + # 不触发确认门即执行)。空输入没有任何合法意图,必须入口拦截。 + if not (content or "").strip(): + yield json.dumps({ + "type": "error", + "message": "收到空消息(可能前端输入丢失或调用方 prompt 为空),已拒绝处理。请输入内容后重试。", + }, ensure_ascii=False) + "\n" + return + # 1. 解析项目上下文(纯通用模式跳过,不挂任何产线插件) if generic: ctx = {"pid": "", "pipeline_id": "", "name": "", "project_model_name": ""}