Summary
A path traversal vulnerability in PraisonAI's FileMemory component allows an attacker-controlled user ID to influence the location where memory JSON data is written. If the caller can supply crafted path components such as parent-directory references or separators, data may be written to arbitrary locations that the process can access.
Affected context
The issue occurs in deployments using the FileMemory constructor before the affected security fix. It becomes risky when user IDs originate from untrusted callers and are incorporated directly into memory paths without normalization or containment checks. The resulting path may escape the intended memory directory and target other process-writable locations.
Exploit preconditions
- Attack surface: The FileMemory API or another application path that accepts caller-controlled user IDs
- Required access: Ability to provide or influence the
user_idvalue - Trigger point: Construction of a FileMemory instance followed by JSON data persistence
- Why exploitation is possible: The user ID is joined into the storage path without sufficient sanitization or verification that the resolved path remains inside the intended directory
Why this happens
The underlying bug is path construction based on untrusted input. When a user-controlled identifier is concatenated with a trusted base directory, traversal sequences or path separators can alter the resolved destination.
This maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). The related CWE-73: External Control of File Name or Path also applies because an external value controls a filesystem path without adequate validation or confinement.
Potential impact
- An attacker may write or overwrite JSON data in process-writable locations
- Application state, configuration, or operational data could be modified
- The process may experience data corruption or denial of service
- Written content could be used to influence later application behavior
- In permissive environments, the issue could contribute to broader compromise
General mitigation guidance
Mitigation generally focuses on treating identifiers as data rather than filesystem syntax.
Common defensive patterns include:
- Sanitizing or canonicalizing user-controlled identifiers before path construction
- Allowing only a constrained identifier format when directory names are required
- Resolving the final path and verifying that it remains within the designated storage root
- Using secure-by-default storage abstractions that do not expose raw path composition
- Separating user data into controlled namespaces with least-privilege filesystem permissions
- Reducing process write access to sensitive directories and files
- Avoiding reliance on validation alone when the underlying filesystem operation can be constrained
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules that flag filesystem path APIs receiving external input
- Code review checks for direct joining or concatenation of user IDs with directory paths
- Tests using traversal markers, separators, absolute paths, and platform-specific path forms
- Runtime policies that restrict application write locations
- Monitoring for writes outside the expected memory directory
- Automated security review tools that identify CWE-22 and CWE-73 patterns

