Perl FindBin modules before 5.4.0 have two local code flaws
FindBin::libs can add the current directory to LD_LIBRARY_PATH; FindBin::Bin can eval the script directory name.
Code injection in Perl FindBin::Bin via directory names
FindBin::Bin 4.0.1 before 5.4.0 builds Bin with a string eval that embeds the script directory, or the current directory for perl -e, in a single-quoted literal without escaping. A single quote in a directory name ends that literal so the rest is compiled as Perl. Anyone who can name a directory can run code as a user who runs a script there, including through FindBin::libs, but only on Perl 5.40 and later.
What to do: Upgrade FindBin::Bin to 5.4.0. It is installed only on Perl 5.40 and later.
| Product | Affected | Fixed in |
|---|---|---|
| FindBin::Bin | 4.0.1 before 5.4.0 | 5.4.0 |
Order-of-magnitude estimate by the model from install counts, market share and public scan data it knows; verify before quoting.
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::libs can add the current directory to LD_LIBRARY_PATH; FindBin::Bin can eval the script directory name.
Today 2.5K readers · 5K views · 287 reads · all time 290K views