Summary
Langflow's Knowledge Bases deletion endpoint previously concatenated user-supplied names directly into filesystem paths, enabling a path traversal condition.
An authenticated attacker could craft specially formatted knowledge base names to delete arbitrary directories on the server, causing data loss and service disruption.
Affected context
This vulnerability affects Langflow deployments exposing the Knowledge Bases API (DELETE /api/v1/knowledge_bases) where:
- Knowledge base identifiers are accepted from authenticated users and mapped to directories on disk.
- The server process has permission to delete those directories.
- Path handling logic constructs filesystem paths by directly appending user input to a base directory without enforcing strict directory boundaries.
It is most relevant in environments where application data, configuration, or other sensitive directories reside on the same filesystem accessible to the Langflow process.
Exploit preconditions
- Attack surface: HTTP API endpoint
DELETE /api/v1/knowledge_bases. - Required access: Valid authenticated access with permission to invoke knowledge base deletion.
- Trigger point: Sending a deletion request where the
nameor identifier parameter contains path traversal sequences (for example, segments that resolve outside the intended knowledge base directory). - Why exploitation is possible: The server concatenates user-supplied values into filesystem paths without normalizing and validating them against an allowed base directory, allowing the resolved path to escape its intended scope.
Why this happens
The underlying bug is a classic path traversal issue, mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
The application treats a user-controlled knowledge base name as a trustworthy path segment and appends it directly to a base directory when constructing deletion targets.
Without canonicalization, normalization, or strict checks that the final path remains within an approved root, specially crafted values can cause the filesystem operation to target directories outside the intended knowledge base storage area.
In abstract terms, this reflects a design pattern where file operations depend on untrusted input for path resolution, instead of using validated identifiers mapped to server-controlled paths.
Potential impact
- Deletion of arbitrary directories accessible to the Langflow process on the server.
- Loss of application data, including knowledge bases and other stored artifacts.
- Removal of configuration or runtime directories, leading to partial or complete service outage.
- Potential corruption of other applications or services sharing the same filesystem.
- Increased operational overhead due to restoration from backups and incident response efforts.
General mitigation guidance
Effective mitigation focuses on confining filesystem access and eliminating direct path construction from user input:
- Use opaque, server-generated identifiers for knowledge bases and maintain a mapping from IDs to absolute paths stored in a trusted datastore.
- Normalize and canonicalize any path derived from user input, then enforce that it resides within a predefined base directory before performing filesystem operations.
- Avoid accepting raw path fragments or directory names from clients; treat user input as data keys, not filesystem paths.
- Apply strict allowlists for valid identifier formats (e.g., UUIDs or constrained slugs) to reduce the chance of path traversal sequences.
- Run the Langflow service under a minimally privileged account, with filesystem permissions restricted to only the directories needed for operation.
- Consider isolating application data on dedicated directories or volumes to limit blast radius if a path-based flaw occurs.
How teams detect issues like this
Organizations can detect and monitor for similar vulnerabilities through:
- Static analysis rules that flag direct concatenation of user input into file paths or use of path-unsafe APIs in request handlers.
- Code reviews that require explicit checks showing:
- Canonicalization of paths before use.
- Enforcement that resolved paths remain under known base directories.
- Separation between user-facing identifiers and internal filesystem paths.
- Security testing and fuzzing of file-related endpoints with path traversal patterns to validate defensive checks.
- Runtime monitoring for suspicious deletion patterns, such as removal of directories outside expected data roots or repeated delete operations from a single account.
- Incorporating automated secure coding checks into CI pipelines to prevent reintroducing path traversal patterns.

