From SQLi to RCE – Exploiting LangGraph’s Checkpointer
LangGraph's SQLite checkpointer built SQL from user-controlled filter keys without parameterisation, allowing SQL injection; the query results were then deserialised with an unsafe msgpack extension handler that could import and call arbitrary Python functions. Chained together, an attacker who controls the filter passed to get_state_history() could run shell commands on the server.
Published on research.checkpoint.com
AI agents need memory. Frameworks like LangGraph provide it through checkpointers – persistence layers that store execution state.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the filter dictionary keys were interpolated into a JSON path inside the SQL WHERE clause instead of being bound as parameters, and the msgpack extension hook used getattr/importlib to call arbitrary functions on attacker-controlled data.
Impact
An attacker could achieve remote code execution on self-hosted LangGraph deployments that expose get_state_history() with a user-controlled filter; LangSmith Deployment on PostgreSQL is not affected.
What the attacker needed
Self-hosted LangGraph; SQLite or Redis checkpointer; get_state_history() exposed; user-controlled filter
The fix
The SQL injection was fixed by parameterising queries in langgraph-checkpoint-sqlite 3.0.1 and langgraph-checkpoint-redis 1.0.2, and the msgpack deserialisation issue was fixed in langgraph-checkpoint 4.0.1.
How it was found
- Prepare a msgpack payload that uses the constructor extension to call a shell command.
- Send a filter whose key breaks out of the JSON path and adds a UNION SELECT row containing that payload.
- The application runs the query and receives the fake checkpoint row.
- The checkpointer deserialises the injected msgpack, which imports a module and calls a function, executing the command.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A database query is built by gluing text together, so a user-supplied key can break out of the intended string and add extra SQL. Separately, the stored checkpoint data is unpacked with a format that can name a Python module and function to call, so crafted data runs code. Together, a malicious filter makes the app fetch and unpack attacker data, giving command execution.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.