CVE-2026-120361 in FindBin::Bin
Summary
by MITRE • 11/30/2026
FindBin::Bin versions from 4.0.1 before 5.4.0 for Perl execute code from the script's directory name via a string eval.
The module defines Bin by interpolating the script's directory, or the current directory for perl -e, into a single-quoted literal inside a string eval, without escaping. A single quote in any directory name ends the literal and the rest of the name is compiled as Perl code. FindBin::Bin is installed only on Perl 5.40 and later, and FindBin::libs loads it.
An attacker who can name a directory can run code as any user who runs a script inside it.
Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
Analysis
by VulDB Data Team • 11/30/2026
The vulnerability identified in the FindBin module for Perl versions prior to 5.4.0 represents a critical server-side request forgery and arbitrary code execution flaw rooted in improper input validation during path interpolation. The core technical defect lies within how the Bin variable is constructed, which involves interpolating the script's directory or the current working directory into a single-quoted literal string that is subsequently passed to an eval function without any sanitization of special characters. This architectural decision assumes that file system paths are safe containers for code literals, ignoring the fact that Unix and Windows operating systems allow users to create directories with arbitrary names containing shell metacharacters or Perl syntax elements such as single quotes.
When a directory name contains a single quote character, it prematurely terminates the intended string literal within the eval statement. The remainder of the path is then interpreted by the Perl interpreter not as data but as executable code. This mechanism allows an attacker who has the ability to create directories in locations accessible to the target application to inject arbitrary Perl commands. For instance, if a script resides in or accesses a directory named test' . system('id') . 'test', the eval will execute the injected command sequence rather than simply returning the path string. This flaw is particularly dangerous because it bypasses standard input validation checks that might look for SQL injection patterns or XSS payloads but fail to account for code injection via file system naming conventions.
The operational impact of this vulnerability is severe, enabling remote attackers with directory creation privileges to achieve arbitrary code execution under the context of any user running a script within the compromised directory structure. This effectively grants the attacker full control over the application's runtime environment, potentially leading to complete server compromise, data exfiltration, or lateral movement within the network infrastructure. The risk is exacerbated by the fact that FindBin::libs loads this module automatically in many Perl environments, increasing the attack surface for applications relying on standard library components without explicit awareness of their internal implementation details regarding path handling and code evaluation.
From a classification perspective, this vulnerability aligns with CWE-94 Improper Control of Generation of Code (Code Injection) as it involves the injection of executable code through untrusted input that is directly evaluated by an interpreter. It also maps to MITRE ATT&CK technique T1059 Command and Scripting Interpreter, specifically sub-techniques related to Perl scripting, where attackers leverage built-in system utilities or interpreters to execute malicious commands on a compromised host. The vulnerability highlights the dangers of using eval with unsanitized dynamic content, a pattern that remains prevalent in legacy codebases despite known best practices against its use for untrusted data processing.
Mitigation strategies must prioritize immediate patching by upgrading FindBin::Bin to version 5.4.0 or later where this interpolation flaw has been addressed through proper escaping mechanisms. In environments where upgrading is not immediately feasible, administrators should enforce strict directory naming policies that prohibit the creation of directories containing single quotes or other code-injection characters in paths accessible to web servers and application processes. Additionally, developers should refactor any usage of eval with dynamic strings to use safer alternatives such as require for module loading or explicit path resolution functions that do not involve string interpolation into executable contexts. Regular security audits focusing on file system interactions and dynamic code evaluation patterns are essential to prevent similar vulnerabilities in other components of the Perl ecosystem.