已关闭
[Bug]: benchmarks/llm 样例默认启用远端代码执行 #5082
liuyutong创建于 9月24日关闭于 9月29日
9月24日 添加了label:bug
9月24日 添加了label:triage-reviewmodule: usability;删除了label:bug
TorchNPU-Bot
9月24日 评论:
9月24日 评论:
问题指向 benchmarks/llm 样例代码与文档的安全整改(trust_remote_code 默认值、路径默认值、README 说明),属样例易用性与文档类问题
添加分类标签:module: usability。
当前分类由社区bot提供,如分类有误请在评论中回复。


9月24日 添加了label:bug
9月24日 添加了label:bot-triaged;删除了label:triage-review
TorchNPU-Bot
9月24日 评论:
9月24日 评论:
检测到当前 issue 已关联 PR,自动添加标签:bot-triaged


9月24日 关联了pull request:fix(benchmark): restrict remote model code execution
9月24日 关联了pull request:fix(benchmark): restrict remote model code execution
9月24日 关联了pull request:fix(benchmark): restrict remote model code execution
9月24日 关联了pull request:fix(benchmark): restrict remote model code execution
9月24日 关联了pull request:fix(benchmark): restrict remote model code execution
9月24日 关联了pull request:fix(benchmark): restrict remote model code execution
9月24日 关联了pull request:fix(benchmark): restrict remote model code execution
9月24日 关联了里程碑:v26.2.0
chenrayray
9月29日 评论:
9月29日 评论:
因为本单相关实施 PR 已全部结束(13 个已合入、0 个已关闭),按照本轮 issue 整理规则,先关闭此单。
核对的 PR:
- pytorch !46978:已合入
- pytorch !46979:已合入
- pytorch !46980:已合入
- pytorch !46981:已合入
- pytorch !46982:已合入
- pytorch !46983:已合入
- pytorch !47028:已合入
- pytorch !47029:已合入
- pytorch !47030:已合入
- pytorch !47031:已合入
- pytorch !47032:已合入
- pytorch !47033:已合入
- pytorch !47034:已合入
如仍有问题或需要继续推进,请重新打开,并补充当前 PyTorch / TorchNPU / CANN 版本、硬件环境、复现步骤及相关日志;需求类请补充尚未完成的具体内容。


9月29日 关闭了 issue
9月29日 issue状态由 TODO 改变为 DONE
9月29日 添加了label:resolved
问题描述
部分
benchmarks/llm训练样例在加载模型、分词器或处理器时默认启用了trust_remote_code=True。当用户传入远程模型仓库时,Transformers 可能下载并执行仓库中的自定义 Python 代码,执行权限与当前用户一致,而样例未要求显式确认可信来源。此外,个别样例的模型路径默认值包含开发环境中的个人绝对路径,不适合作为开源样例默认配置。
风险影响
用户执行训练脚本并指定未经验证的远程模型仓库时,模型仓库中的自定义建模或分词代码可能被执行,存在任意代码执行风险。模型、Tokenizer 和 Processor 的远端代码加载均受影响。
整改方案
trust_remote_code=True。--trust-remote-code显式开关。--revision固定完整 commit hash;本地已校验模型目录不强制该参数。验收标准
trust_remote_code=True。