已合并
【安全排查】【重明问题修复】收口配置驱动动态导入与表达式求值风险 #392
【安全排查】【重明问题修复】收口配置驱动动态导入与表达式求值风险 #392
已合并
ChaseChe77创建于 6月29日
ChaseChe77
ChaseChe77成员
6月29日

PR 合入模板

1. 修改描述

  • 修改原因:
    chongming 分支针对安全扫描问题收口,本 PR 保留确认需要修复的问题:023 / 015 / 014 / 011 / 010,主要涉及 YAML 配置驱动的动态导入风险,以及 profiler 属性表达式求值过宽带来的安全风险。

  • 修改内容:

    1. 对 profiler / metrics 的 handlersymbol 动态导入增加白名单限制,禁止非预期模块被配置导入。
    2. dynamic_hook 中属性表达式执行从原有 eval() 黑名单模式收口为受限 AST 安全求值。
    3. 收窄表达式执行上下文,仅保留 this/self/args/kwargs/return/ret 等必要变量,避免具名参数平铺暴露。
    4. 同步补充 / 更新对应 UT,覆盖恶意模块导入、危险表达式、上下文暴露收口等场景。
    5. 同步更新示例配置和中英文文档,保持行为说明与代码一致。

2. 功能验证

补充说明:

  • 已执行本次改动相关 UT。
  • 已按实际业务场景完成 profiler / metrics 手动验证,确认 hook 正常生效、非白名单导入受限、危险表达式场景被拦截。

3. 代码检视

  • 要求:
    • 合入代码大于 200 行,需三人以上会议检视。
    • 检视密度≥2个/100行。
    • 检视缺陷密度达不到要求的需给出说明。
    • 大于 1000 行代码原则上不允许合入,需进行备案。

补充说明:

  • 本 PR 相对 chongming-precommit-pr 增量为 17 files changed, 571 insertions(+), 147 deletions(-)
  • 其中新增 571 行中,业务代码 284 行,UT 262 行,文档/示例 25 行。

4. 安全自检

典型安全编码问题

补充说明:

  • 本次修改不新增对外接口,主要收口配置输入与表达式输入。
  • 对非法 handler/symbol 配置增加白名单校验、失败回退/报错及日志记录。
  • 对表达式执行仅允许受限 AST 节点和白名单函数,避免方法调用、危险属性访问和上下文过度暴露。
  • 未新增涉及 ReDos 的正则逻辑,未引入整数溢出/除零类运算风险。

5. 变更知会

  • 资料修改:
    已同步修改:

    • docs/zh/vLLM_service_oriented_performance_collection_tool.md
    • docs/en/vLLM_service_oriented_performance_collection_tool.md
    • ms_service_profiler/patcher/config/hooks_example.yaml
  • 变更通知(消息知会 + 邮件知会):
    请按团队实际流程补充


6. 冒烟修改

  • PR 来源:

补充说明:
建议后续补充针对以下场景的安全冒烟/回归:

  • 非白名单 handler/symbol 配置导入拦截
  • 危险表达式如 this.__class__len(this.shutdown()) 拦截
  • 合法简单表达式与正常 hook 场景保持兼容
likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 ChaseChe77 的贡献)
ChaseChe77ChaseChe77成员
6月29日 关联了issue:【开发自提】安全问题加固
ascend-robotascend-robot成员
6月29日 添加了label:stat/needs-squash
ascend-robotascend-robot成员
6月29日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
6月29日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-Ascend/msserviceprofiler 陈豪, minghang_c (2/2) 陈豪 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

Mad97_, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了70条消息 查看更多
ascend-robotascend-robot成员
6月30日 解决了最后一个问题
ascend-robotascend-robot成员
6月30日 合入了pull request
ascend-robot
ascend-robot成员
6月30日 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
ascend-robot
ascend-robot成员
6月30日 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
ascend-robot
ascend-robot成员
6月30日 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike