The vulnerability lies in the unsafe deserialization of msgpack encoded checkpoints in langgraph. The root cause is the _msgpack_ext_hook function in langgraph/checkpoint/serde/jsonplus.py, which was used as the extension hook for the ormsgpack library. This hook performed deserialization without proper validation, allowing an attacker who can control the checkpoint data to craft a payload that leads to arbitrary object reconstruction and potential remote code execution.
The user-facing functions that trigger this vulnerable behavior are JsonPlusSerializer.loads and JsonPlusSerializer.aloads. These methods are responsible for deserializing checkpoint data and, before the patch, they used the insecure _msgpack_ext_hook.
The patch addresses this vulnerability by replacing the insecure _msgpack_ext_hook with a new mechanism that uses an allowlist to control which classes can be deserialized. A new function, _create_msgpack_ext_hook, generates a secure ext_hook that validates types against a set of safe types and a configurable allowlist. The JsonPlusSerializer is modified to use this new secure hook, and the langgraph framework is updated to automatically generate and apply this allowlist when compiling graphs, thus mitigating the risk of arbitrary code execution during checkpoint loading.