From a402b6e3503715ae1fc2766b2f3d1ad0e424d5c4 Mon Sep 17 00:00:00 2001 From: hotyue Date: Mon, 10 Aug 2026 06:32:20 +0000 Subject: [PATCH] =?UTF-8?q?fix(agent):=20=E5=8D=87=E7=BA=A7=20Webhook=20?= =?UTF-8?q?=E7=AD=BE=E5=90=8D=E5=BC=95=E6=93=8E=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8F=82=E6=95=B0=E5=85=A8=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=98=B2=E7=AF=A1=E6=94=B9=20(fixes=20#108)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/agent_daemon.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/agent_daemon.sh b/core/agent_daemon.sh index 9945bf8a..194302e5 100755 --- a/core/agent_daemon.sh +++ b/core/agent_daemon.sh @@ -162,8 +162,18 @@ class AgentHandler(http.server.BaseHTTPRequestHandler): self.wfile.write(b"401 Unauthorized: Replay Attack Detected\n") return - # [身份核验] 数据完整性校验,使用 compare_digest 免疫时序探测攻击 - msg = f"{req_path}:{req_t}".encode('utf-8') + # ========================================================== + # [安全升级] 漏洞 #108 修复:HMAC 覆盖完整查询参数防篡改 + # ========================================================== + extra_payload = req_path + + # 精确还原 Master 下发时的 Query 参数拼接序列 + if 'mod' in query and 'state' in query: + extra_payload += f"?mod={query['mod'][0]}&state={query['state'][0]}" + elif 'b64' in query: + extra_payload += f"?b64={query['b64'][0]}" + + msg = f"{extra_payload}:{req_t}".encode('utf-8') expected_sign = hmac.new(AUTH_TOKEN.encode('utf-8'), msg, hashlib.sha256).hexdigest() if not hmac.compare_digest(expected_sign, req_sign):