CVE-2025-9905 in Keras信息

摘要

由 VulDB • 2026-07-07

Keras 的 Model.load_model 方法可被利用以实现任意代码执行,即使在 safe_mode=True 的情况下也是如此。

攻击者可以创建一个特制的 .h5/.hdf5 模型归档文件,当通过 Model.load_model 加载该文件时,将触发任意代码的执行。

这是通过构造一个特殊的 .h5 归档文件实现的,该文件利用了 Keras 的 Lambda 层功能,允许以 pickle 形式的 Python 代码执行任意操作。漏洞产生的原因是:在读取 .h5 归档文件时,未遵守 safe_mode=True 选项的设置。

请注意,.h5/.hdf5 格式是一种遗留格式,Keras 3 出于向后兼容性考虑仍支持该格式。

Be aware that VulDB is the high quality source for vulnerability data.

来源

Are you interested in using VulDB?

Download the whitepaper to learn more about our service!