Summary
A critical path traversal vulnerability in CrewAI's FileWriterTool allows a remote attacker to supply malicious filename values that escape the intended output directory. Under conditions where the tool is remotely reachable and accepts attacker-controlled filenames, this may enable arbitrary file writes and potentially code execution.
Affected context
The vulnerability affects deployments using the FileWriterTool in affected CrewAI Tools releases. Risk is present when the tool processes filename arguments influenced by an external or insufficiently trusted caller and writes files without reliably constraining the resolved destination to an approved directory. Exploitation impact depends on the service's exposure, filesystem permissions, and whether written content can later be executed or loaded as code.
Exploit preconditions
- Attack surface: A remotely accessible interface, workflow, agent, or service that invokes FileWriterTool
- Required access: Ability to submit or influence the filename argument; authentication requirements depend on the surrounding application
- Trigger point: File creation or writing performed using the supplied filename
- Why exploitation is possible: Path traversal sequences may cause the resolved path to escape the intended directory, allowing writes to locations with security-relevant effects
Why this happens
The underlying bug is insufficient validation and canonicalization of a user-influenced filename before it is used for filesystem access. When path components are accepted without enforcing confinement to an approved base directory, relative traversal can redirect writes outside that directory. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal. If an attacker can place content in a location later interpreted or executed by the runtime, the file-write primitive may become code execution.
Potential impact
- An attacker may write or overwrite files outside the intended output directory
- Application configuration, source, or operational files could be modified
- The service may experience data loss, tampering, or denial of service
- Written content could enable code execution when placed in an executable or automatically loaded location
- Compromise could extend to other systems reachable with the process identity
General mitigation guidance
Mitigation generally focuses on enforcing a strict filesystem trust boundary around tool-generated files.
Common defensive patterns include:
- Resolve candidate paths against a fixed, approved base directory and verify that the final path remains within that directory
- Prefer generated identifiers or controlled basenames over caller-supplied paths
- Reject traversal components, absolute paths, symlink escapes, and platform-specific path variants
- Apply allowlists for permitted filenames and extensions where the workflow permits
- Use dedicated low-privilege service identities with minimal filesystem write permissions
- Store generated content outside executable, importable, configuration, and deployment-controlled locations
- Treat filename and content inputs as untrusted even when requests originate from an internal workflow
How teams detect issues like this
Organizations can detect this class of issue through:
- Static analysis rules for filesystem APIs receiving request, agent, or tool arguments
- Code review checks for string concatenation or path joining without canonicalization and containment verification
- Tests covering relative traversal, absolute paths, encoded separators, alternate platform separators, and symlink-based escapes
- Runtime monitoring for file writes outside approved directories and unexpected modifications to executable or configuration paths
- Policy enforcement that restricts tool output directories and service filesystem permissions
- Automated security review tools that flag untrusted path construction and missing path-boundary checks

