PraisonAI Arbitrary File Write Vulnerability
PraisonAI versions 4.6.37 and earlier are vulnerable to arbitrary file write due to missing path validation in the `write_file` function when `workspace=None`, allowing an attacker to write attacker-controlled content to arbitrary file paths on the victim's system via a malicious webpage.
PraisonAI versions up to 4.6.37 are susceptible to an arbitrary file write vulnerability (CVE-2026-47397) within its Python API. This flaw stems from the write_file function’s lack of path validation when the workspace parameter is set to None, a default configuration in production environments. An attacker can exploit this by hosting a webpage containing hidden metadata that specifies an arbitrary file path and content. When a victim’s PraisonAI agent crawls and analyzes this webpage, it autonomously calls the write_file function, writing the attacker-controlled content to the specified path on the victim’s system. This vulnerability allows attackers to bypass injection defenses and LLM safety measures, as the agent performs normal operations triggered by the malicious metadata.
Attack Chain
- The attacker crafts a malicious webpage containing hidden metadata within a
<span>element, defining theoutput_fileandoutput_contentparameters. - A victim uses the PraisonAI Python API to initiate a web crawling task, targeting the attacker’s malicious webpage using the
web_crawltool. - The PraisonAI agent crawls the attacker-controlled webpage using the
web_crawltool, extracting the hidden metadata. - The agent parses the extracted metadata and identifies the
output_fileparameter, which specifies the arbitrary file path. - The agent, as part of its normal operation, autonomously calls the
write_filefunction to write the extracted content to a file. - Because
workspaceisNone, path validation is skipped incode/tools/write_file.py:77-83. - The
write_filefunction writes the content defined by theoutput_contentparameter to the file path specified byoutput_fileon the victim’s system. - The attacker achieves arbitrary file write on the victim’s system, potentially leading to code execution or data exfiltration.
Impact
Successful exploitation allows an attacker to write arbitrary files to the victim’s system. This can lead to various malicious outcomes, including overwriting critical system files, injecting malicious code, or exfiltrating sensitive information. The vulnerability affects any user of PraisonAI who processes attacker-controlled webpages using the web_crawl tool, potentially impacting a wide range of users and applications that rely on PraisonAI for automated web analysis.
Recommendation
- Upgrade PraisonAI to a version later than 4.6.37 to incorporate the fix for CVE-2026-47397.
- Deploy the Sigma rule “Detect PraisonAI Arbitrary File Write via Web Crawl” to detect exploitation attempts by monitoring for calls to the
write_filefunction with attacker-controlled paths. - Implement robust input validation and sanitization measures to prevent malicious metadata injection into web pages processed by PraisonAI agents.
Detection coverage 2
Detect PraisonAI Arbitrary File Write via Web Crawl
highDetects CVE-2026-47397 exploitation — PraisonAI agents calling write_file with attacker-controlled file paths from web crawling tasks.
Detect Suspicious File Writes Outside Workspace
mediumDetects attempts to write files outside a predefined workspace directory.
Detection queries are available on the platform. Get full rules →