/

CVE-2026-14380

Severity:

HIGH RISK

(8.8)

Code Injection via DBI Profile (CWE-95) in Perl DBI

CVE-2026-14380

Modified

Vulnerability type

Category:

Code Injection

CWE:

CWE-95, CWE-470

Impact:

Arbitrary Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Perl DBI versions before 1.650 contain a code injection flaw in the handling of the Profile attribute, where user-influenced strings are interpolated into a string eval without validation.

If an attacker can influence DBI_PROFILE, DSN driver attributes, or direct Profile assignments, they can execute arbitrary Perl code and potentially run system commands in the host process.

Affected context

This vulnerability affects applications using Perl DBI versions before 1.650 that:

  • Enable or set the Profile attribute on DBI handles, directly or indirectly
  • Accept untrusted or semi-trusted input that can reach:
  • The DBI_PROFILE environment variable
  • DSN driver-attribute clauses, e.g. dbi:Driver(Profile=>SPEC):db
  • Application code paths that assign to $dbh->{Profile}
  • Run in environments where DBI connections are created dynamically per request, such as DBI::Gofer or DBI::ProxyServer, potentially exposing the Profile string to remote clients

In these contexts, a caller-controlled Profile specification can be interpreted as executable Perl code inside the host process.

Exploit preconditions

  • Attack surface:
  • Environment configuration (DBI_PROFILE variable)
  • Connection strings / DSNs containing Profile driver attributes
  • Application APIs or configuration layers that let users influence DBI handle attributes
  • Network-exposed DBI::Gofer / DBI::ProxyServer instances that accept per-request DSNs
  • Required access:
  • Ability to set or influence DBI_PROFILE, or
  • Ability to submit DSNs or configuration data that is passed to DBI unchanged or insufficiently validated, or
  • Ability to drive application inputs that propagate into $dbh->{Profile}
  • Trigger point:
  • Creation of a DBI handle when the Profile attribute is parsed and processed
  • Any point where DBI evaluates the Profile string, splitting it into path, package, and arguments
  • Why exploitation is possible:
  • DBI splits the Profile string and interpolates the "package" portion directly into a string eval without validating or constraining the package name
  • Because the value can be influenced by external input, an attacker can craft a Profile spec that injects arbitrary Perl code, including calls to run system commands, which DBI then executes in the host process context

Why this happens

The underlying bug is a classic code injection pattern stemming from unsafe use of eval on untrusted data, aligning with CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection').

DBI's Profile feature accepts a string specification, splits it into path, package, and arguments, and then constructs a Perl expression that is evaluated via a string eval. The package component is interpolated into that expression with no validation, escaping, or restriction to a safe subset. As a result, any caller-controlled Profile string effectively becomes part of executable Perl code within the DBI library.

This breaks the isolation between configuration and code: configuration-like data (the Profile spec) is treated as code, enabling arbitrary command execution whenever an attacker can influence that attribute.

Potential impact

  • Execution of arbitrary Perl code in the database client process
  • Execution of system commands under the privileges of the DBI-using application
  • Full compromise of application runtime and access to in-process secrets (API keys, DB credentials, tokens)
  • Reading, modifying, or exfiltrating sensitive data handled by the affected application
  • Lateral movement from a DBI::Gofer / DBI::ProxyServer broker host into other internal systems
  • Denial of service by crashing the Perl process or exhausting system resources

General mitigation guidance

Effective mitigation focuses on avoiding dynamic evaluation of untrusted configuration and tightening the trust boundary around DBI profiling features.

Common defensive patterns include:

  • Eliminate string-based eval for configuration: Prefer APIs that configure profiling through code-level constants, enums, or structured data rather than strings that are later interpolated.
  • Constrain Profile values to a safe set: Treat the Profile attribute as an internal control; if it must be configurable, restrict it to a small, predefined list of modes or modules, enforced via explicit whitelisting instead of dynamic construction of package names.
  • Separate configuration from code: Design configuration so it cannot carry arbitrary code; never treat user-facing configuration fields as Perl expressions.
  • Harden input paths that affect DBI: Reject or sanitize DSNs and environment variables that include Profile settings from untrusted sources, and avoid passing user-controlled fragments into DBI attributes without validation.
  • Apply least privilege for DBI processes: Run DBI-using applications and proxy servers with minimal OS permissions, constrained filesystem access, and limited ability to invoke external commands, reducing impact if code execution occurs.
  • Avoid exposing profiling controls to external callers: Keep profiling toggles and specifications in deployment-time configuration or code, not as request-level parameters.

How teams detect issues like this

Detection typically involves reviewing both DBI usage patterns and configuration handling for unsafe eval-like behavior.

High-level strategies include:

  • Static analysis for dynamic eval: Search for eval calls that build code strings using variables derived from configuration, environment variables, or DSNs, particularly around DBI Profile handling.
  • Configuration flow review: Trace how DBI_PROFILE, DSN strings, and other configuration inputs flow into DBI initialization. Flag any path where user input can directly influence $dbh->{Profile} or other attributes resolved via eval.
  • Policy-based code review checks: Enforce guidelines that prohibit using string-based eval for configuration interpretation, and require that any profiling or debugging controls use enumerated options instead of free-form strings.
  • Runtime monitoring and logging: Log Profile specifications and DSNs used by DBI::Gofer / DBI::ProxyServer in non-production environments, and alert on unexpected or suspicious values such as those containing Perl code fragments or shell command patterns.
  • Automated tooling: Use generic SAST tools configured to flag eval on non-constant strings, and complement them with custom rules that recognize DBI-specific patterns and attribute handling.

Sources

SourceLink
github.comgithub.com/perl5-dbi/dbi/commit/b73d5d9901767fc1d16b6661ef08fbed4532e259.patch
github.comgithub.com/perl5-dbi/dbi/security/advisories/GHSA-ch8w-hxc2-v557
metacpan.orgmetacpan.org/release/HMBRAND/DBI-1.650/changes
openwall.comopenwall.com/lists/oss-security/2026/07/07/16

Frequently asked

questions

It can be, depending on how DBI is exposed. For example, a network-facing DBI::Gofer or DBI::ProxyServer that accepts DSNs from clients and forwards them to DBI can allow a remote attacker to supply a malicious Profile specification and execute code on the broker host.

An attacker needs the ability to influence the value of the DBI Profile attribute, either through environment variables like DBI_PROFILE, configuration or DSNs that include Profile=>..., or application inputs that are passed directly into $dbh->{Profile}. If those paths are reachable from untrusted users, remote code execution becomes possible.

The most robust fix is to eliminate any use of string-based eval for interpreting configuration like Profile specifications and instead use a safe, structured representation with explicit validation. Profile behavior should be limited to a whitelist of known-safe options or modules, and user input should never be interpolated into package names or code snippets.

Avoid treating configuration as code: never use eval on values that can be influenced by users, environment variables, or network inputs. Establish coding standards that ban or tightly restrict string eval, require validation and whitelisting for dynamic module or package selection, and incorporate static analysis and code review practices focused on spotting eval and injection-prone patterns.

Find out what's already
exploitable in your codebase.