Summary
DBD::File for Perl fails to prevent table files from being symbolic links pointing outside the configured data directories, enabling path traversal via symlink abuse.
Under deployments where attackers can create or influence table files, this can allow reading from or writing to arbitrary files on the filesystem outside the intended data directory.
Affected context
The vulnerability affects applications using Perl's DBD::File and related file-based DBI drivers that rely on a designated data directory for table storage.
It is relevant when table files within this directory may be created, modified, or influenced by less-trusted users or processes, such as multi-tenant file stores, shared hosting, or applications exposing table creation through user-controlled parameters.
In such cases, a symlink placed within the data directory can silently redirect database operations to files anywhere on the filesystem, bypassing the logical confinement intended by f_dir and f_dir_search.
Exploit preconditions
- Attack surface: File-based database backends using DBD::File as the storage layer.
- Required access: Ability to create or manipulate table files or entries within the configured data directory (e.g., creating symlinks, influencing table names, or interacting with a feature that writes table files from user input).
- Trigger point: Any operation that resolves a table name to a file path using
complete_table_nameand then performs read or write operations on that file. - Why exploitation is possible: The driver constructs absolute paths for table files but does not verify whether the resulting path is a symbolic link targeting locations outside the configured data directories, allowing attacker-controlled symlinks to redirect database I/O.
Why this happens
The core issue is a lack of path canonicalization and validation when resolving table names to filesystem paths.
complete_table_name assumes that any file within the data directory is safe without checking for symbolic links or verifying that the final resolved path remains under f_dir or f_dir_search.
This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory and CWE-59: Improper Link Resolution Before File Access, where the code trusts filesystem links and relative paths without enforcing directory boundaries.
Conceptually, the component treats file-based tables as implicitly trusted just because they originate from the data directory, but it does not confirm that the underlying filesystem object matches that assumption.
Potential impact
- Reading arbitrary files on the host system that are accessible to the DBD::File process.
- Overwriting or corrupting files outside the intended data directory, potentially impacting application or system behavior.
- Exfiltration of sensitive configuration files, credentials, or application data stored elsewhere on the filesystem.
- Escalation of impact when combined with other weaknesses, such as using writable configuration files or scripts that are later executed.
- Bypassing logical tenant or application isolation that relies on directory boundaries for separation.
General mitigation guidance
Effective mitigation focuses on enforcing strict filesystem boundaries and treating table paths as untrusted until proven otherwise:
- Resolve and canonicalize table file paths (e.g., using realpath-like functions) and ensure the final resolved path remains within the configured f_dir or f_dir_search directories before any file I/O.
- Explicitly reject table paths that are symlinks, or restrict them to symlinks targeting whitelisted locations, depending on deployment requirements.
- Apply least-privilege principles to the process using DBD::File, limiting its filesystem permissions so even if redirection occurs, accessible files are minimally sensitive.
- Avoid exposing raw file- or table-name controls directly to end users; introduce validation layers that enforce naming policies and deny potentially malicious patterns.
- Where feasible, separate data directories per tenant or trust level, and ensure the directories have controlled ownership and permissions that prevent low-privileged users from inserting symlinks.
How teams detect issues like this
Organizations can look for this class of issue using a combination of code, configuration, and runtime checks:
- Code review: Identify code paths where DBD::File or similar file-based DBI drivers are used; verify that after
complete_table_nameor equivalent resolution, symlink checks and directory boundary validations are consistently enforced. - Static analysis: Implement custom rules or patterns that flag filesystem accesses in database driver code which lack canonicalization, symlink checks, or directory traversal safeguards.
- Runtime monitoring: Inspect data directories for unexpected symlinks pointing outside the tree; periodically audit directory contents and permissions for anomalies or unowned entries.
- Policy enforcement: Define internal guidelines for use of file-based database drivers, including mandatory path validation helpers and wrappers, and enforce them via automated checks in CI/CD where possible.

