security: switch_bizdate.dspy 校验补全 IPv6 + 拒绝时不回显 client_ip

原实现只认 127.0.0.1(漏 ::1),且校验失败时 return ip 把探测结果回显给调用方,
便于攻击者试探代理头处理方式。改为中性拒绝信息。
This commit is contained in:
yumoqing 2026-08-25 15:01:22 +08:00
parent 94c262ec73
commit 21b4f0c3d8

View File

@ -1,6 +1,9 @@
ip = request['client_ip'] # 安全:定时任务入口(改全平台业务日期 business_date),只允许本机调用。
if ip not in ['127.0.0.1']: # 校验失败不回显 client_ip(原实现 `return ip` 把探测结果反馈给调用方,
return ip # 便于攻击者试探代理头处理方式),统一返回中性拒绝信息。
ip = request.get('client_ip') or ''
if ip not in ('127.0.0.1', '::1', 'localhost'):
return 'Forbidden: 仅允许本机调用'
async with get_sor_context(request._run_ns, 'appbase') as sor: async with get_sor_context(request._run_ns, 'appbase') as sor:
try: try: