From 3d7c68bac6ee74fad63f43cf99e45c62e202ed55 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Fri, 5 Jun 2026 15:14:28 +0800 Subject: [PATCH] fix(wechatmp): reject webhook requests when wechatmp_token is empty --- channel/wechatmp/common.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/channel/wechatmp/common.py b/channel/wechatmp/common.py index e1cbe7b6..a994c01d 100644 --- a/channel/wechatmp/common.py +++ b/channel/wechatmp/common.py @@ -19,9 +19,15 @@ def verify_server(data): nonce = data.nonce echostr = data.get("echostr", None) token = conf().get("wechatmp_token") # 请按照公众平台官网\基本配置中信息填写 + # Reject when token is empty: an empty token reduces signature verification + # to a predictable hash over attacker-controlled values. + if not token: + raise web.Forbidden("wechatmp_token is not configured") check_signature(token, signature, timestamp, nonce) return echostr except InvalidSignatureException: raise web.Forbidden("Invalid signature") + except web.Forbidden: + raise except Exception as e: raise web.Forbidden(str(e))