{"id":"CVE-2025-9906","published":"2025-09-19T08:15:04Z","modified":"2026-02-26T17:48:23Z","title":"Arbitrary Code execution in Keras Safe Mode","vendor":"Keras-team","product":"Keras","tier":"tail","description":{"text":"The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True.\n\nOne can create a specially crafted .keras model archive that, when loaded via Model.load_model, will trigger arbitrary code to be executed. This is achieved by crafting a special config.json (a file within the .keras archive) that will invoke keras.config.enable_unsafe_deserialization() to disable safe mode. Once safe mode is disable, one can use the Lambda layer feature of keras, which allows arbitrary Python code in the form of pickled code. Both can appear in the same archive. Simply the keras.config.enable_unsafe_deserialization() needs to appear first in the archive and the Lambda with arbitrary code needs to be second.","provenance":"source","from":"CVE.org"},"cvss":{"score":8.6,"severity":"HIGH","version":"4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/AU:Y/R:A","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00203,"percentile":0.10437,"provenance":"source"},"cwes":[{"id":"CWE-502","name":"Deserialization of Untrusted Data"}],"references":[{"url":"https://github.com/keras-team/keras/pull/21429","tags":["patch"]}],"priority":{"score":8.1,"factors":[{"name":"EPSS percentile","points":2.09},{"name":"CVSS severity","points":6.02}]},"vendorSlug":"keras-team","affectedVersions":[{"vendor":"Keras-team","product":"Keras","versions":[">= 3.0.0, < 3.11.0"]}],"capec":[{"id":"CAPEC-242","name":"Code Injection"}],"ssvc":{"exploitation":"none","automatable":"no","technicalImpact":"total","timestamp":"2025-09-20T03:55:42.287333Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"PyPI","package":"keras","vulnerableRanges":["<3.11.0"],"patched":["3.11.0"],"from":["GHSA-36fq-jgmw-4r9c","PYSEC-2025-76"],"provenance":"source"}],"summary":{"text":"The Keras library's Model.load_model method contains a deserialization flaw, classed as deserialization of untrusted data, that persists even when safe_mode=True is set. An attacker who can get a specially crafted .keras model archive loaded can use a config.json entry that calls keras.config.enable_unsafe_deserialization() to disable safe mode first, then a Lambda layer containing pickled Python code to execute arbitrary code, which requires a local attack vector, low privileges, and user interaction to load the malicious model.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T22:08:48Z"},"euvd":{"id":"EUVD-2025-30281","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-keras-team-keras-cve-2025-1550","parents":[{"from":"CVE-2025-1550","to":"CVE-2025-9906","relation":"successor","confidence":"high","kind":"lineage","evidence":[{"kind":"version-step","provenance":"source","package":"PyPI:keras","fromFixed":"3.9.0","toFixed":"3.11.0","daysApart":192},{"kind":"same-code","provenance":"machine","files":["keras/src/saving/serialization_lib.py"],"commits":["https://github.com/keras-team/keras/commit/e67ac8ffd0c883bec68eb65bb52340c7f9d3a903","https://github.com/keras-team/keras/commit/713172ab56b864e59e2aa79b1a51b0e728bba858"],"basis":"shared function","functions":["_retrieve_class_or_fn"]}]}],"children":[{"from":"CVE-2025-9906","to":"CVE-2026-12480","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["keras/src/legacy/saving/legacy_h5_format.py"],"commits":["https://github.com/keras-team/keras/commit/713172ab56b864e59e2aa79b1a51b0e728bba858","https://github.com/keras-team/keras/commit/d5a88bdb137c0d3039b8f4bbbe8c7099925cc10c","https://github.com/keras-team/keras/commit/8f987f11bf7512f0df4774a8f1557bba07dc2b49"],"basis":"shared function","functions":["load_model_from_hdf5","save_optimizer_weights_to_hdf5_group"]}]}],"packageHistory":[{"cve":"CVE-2024-3660","published":"2024-04-16","fixed":"2.13.1rc0","kev":false},{"cve":"CVE-2025-1550","published":"2025-03-11","fixed":"3.9.0","kev":false},{"cve":"CVE-2025-8747","published":"2025-08-11","fixed":"3.11.0","kev":false},{"cve":"CVE-2025-9906","published":"2025-09-19","fixed":"3.11.0","kev":false},{"cve":"CVE-2025-49655","published":"2025-10-17","fixed":"3.11.3","kev":false,"link":{"from":"CVE-2025-9906","to":"CVE-2025-49655","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"PyPI:keras","fromFixed":"3.11.0","toFixed":"3.11.3","daysApart":28}]}},{"cve":"CVE-2025-9905","published":"2025-09-19","fixed":"3.11.3","kev":false,"link":{"from":"CVE-2025-9906","to":"CVE-2025-9905","relation":"successor","confidence":"low","kind":"sequence","orderedBy":"description","evidence":[{"kind":"version-step","provenance":"source","package":"PyPI:keras","fromFixed":"3.11.0","toFixed":"3.11.3","daysApart":0}]}},{"cve":"CVE-2025-12058","published":"2025-10-29","fixed":"3.12.0","kev":false}],"package":"PyPI:keras"}}