From 25c9e7cdb30c67b915548ff1583d0bbe5a536f8c Mon Sep 17 00:00:00 2001 From: ymq Date: Mon, 7 Sep 2026 18:04:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(gateway):=20run=5Fmessage=E7=A9=BA=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E5=AE=88=E5=8D=AB=E2=80=94=E2=80=94=E7=A9=BA/?= =?UTF-8?q?=E7=BA=AF=E7=A9=BA=E7=99=BD=E6=B6=88=E6=81=AF=E7=BB=9D=E4=B8=8D?= =?UTF-8?q?=E8=BF=9BLLM(2026-09-07=E5=AE=9E=E6=B5=8B:=E7=A9=BAprompt?= =?UTF-8?q?=E8=87=B4LLM=E5=B9=BB=E8=A7=89delete=5Fproject=E8=A6=81?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4/=E7=9B=B4=E6=8E=A5run=5Fcommand=E6=89=A7?= =?UTF-8?q?=E8=A1=8Cpython3=20heredoc=E9=9D=9E=E5=8D=B1=E9=99=A9=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E7=BB=95=E8=BF=87=E7=A1=AE=E8=AE=A4=E9=97=A8);?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E6=8B=A6=E6=88=AA=E8=A6=86=E7=9B=96generic+?= =?UTF-8?q?=E5=85=A8=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_service/gateway.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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": ""}