CVE-2024-45858: Guardrails has an arbitrary code execution vulnerability
Guardrails AI passes validator arguments from a RAIL XML file to Python's eval(). If a user loads a crafted RAIL file, the Python inside it runs on their machine. Versions from 0.2.9 before 0.5.10 are affected. Upgrade guardrails-ai to 0.5.10.
Published Sep 18, 2024 · Analysis Nov 10, 2026
What an attacker can do
HiddenLayer found the bug in the parse_token method of the ValidatorsAttr class (guardrails/validatorsattr.py). The validators attribute of a RAIL file's output tag is split on a colon into a validator name and its arguments. Arguments wrapped in curly braces go to eval(), so any Python expression inside them executes (CWE-95). The trigger is a single call, gd.Guard.from_rail('malicious.xml').
The attacker needs the victim to load a hostile file. RAIL files get shared on forums, in GitHub repositories and in example projects, so that is a realistic route. Code runs with the privileges of the Python process: a developer laptop, notebook or an application server that loads RAIL specs from outside. It can read files, steal tokens and run commands. The advisory rated it 7.8 with a local attack vector.
Who is affected
guardrails-ai from 0.2.9 up to but not including 0.5.10, per the advisory data. HiddenLayer's text names v0.2.9 to v0.5.0 as the affected span, so treat anything below 0.5.10 as affected. Check:
pip show guardrails-aiOnly code that loads RAIL files with Guard.from_rail, especially from outside sources, is exposed.
guardrails-ai
- Ecosystem
- PyPI
- Affected
- >= 0.2.9, < 0.5.10
- Fixed in
- 0.5.10
- Check
pip show guardrails-ai
How to fix it
Upgrade to guardrails-ai 0.5.10:
pip install --upgrade "guardrails-ai>=0.5.10"The vendor deployed the fix on September 17, 2024. The sources give no workaround besides not loading RAIL files from untrusted places. Review RAIL files you already use for validators attributes that contain braces with Python code.
How to tell if you were hit
Search RAIL and XML spec files in your repositories and shared folders for validators attributes with curly-brace arguments that hold function calls, imports or os and subprocess references. Check shell history and process logs on machines that loaded third-party RAIL files for unexpected commands or outbound connections.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
An arbitrary code execution vulnerability exists in versions 0.2.9 up to 0.5.10 of the Guardrails AI Guardrails framework because of the way it validates XML files. If a victim user loads a maliciously crafted XML file containing Python code, the code will be passed to an eval function, causing it to execute on the user's machine.
Questions
- How does an attacker trigger CVE-2024-45858?
By getting a user to load a malicious RAIL XML file, for example with gd.Guard.from_rail. Python in the validators arguments then runs through eval().
- Which version fixes it?
guardrails-ai 0.5.10 is the patched version. The vendor deployed the fix on September 17, 2024.
- Is my own RAIL file safe?
Files you wrote and control are not the risk. The danger is files from untrusted sources.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Guardrails AI vulnerabilities
All Guardrails AI entriesCVE-2026-45758
Malicious code in guardrails-ai 0.10.1 (supply chain compromise)
critical9.6No fixMay 19, 2026CVE-2026-31233
Guardrails AI contains a code injection vulnerability in its Hub package installation mechanism
critical9.8No fixMay 12, 2026CVE-2024-6961
Guardrails AI vulnerable to Improper Restriction of XML External Entity Reference
high5.9Jul 21, 2024
