Security Advisories (26)
CVE-2011-2728 (2012-12-21)

The bsd_glob function in the File::Glob module for Perl before 5.14.2 allows context-dependent attackers to cause a denial of service (crash) via a glob expression with the GLOB_ALTDIRFUNC flag, which triggers an uninitialized pointer dereference.

CVE-2020-12723 (2020-06-05)

regcomp.c in Perl before 5.30.3 allows a buffer overflow via a crafted regular expression because of recursive S_study_chunk calls.

CVE-2020-10878 (2020-06-05)

Perl before 5.30.3 has an integer overflow related to mishandling of a "PL_regkind[OP(n)] == NOTHING" situation. A crafted regular expression could lead to malformed bytecode with a possibility of instruction injection.

CVE-2020-10543 (2020-06-05)

Perl before 5.30.3 on 32-bit platforms allows a heap-based buffer overflow because nested regular expression quantifiers have an integer overflow.

CVE-2018-6913 (2018-04-17)

Heap-based buffer overflow in the pack function in Perl before 5.26.2 allows context-dependent attackers to execute arbitrary code via a large item count.

CVE-2018-18314 (2018-12-07)

Perl before 5.26.3 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2018-18313 (2018-12-07)

Perl before 5.26.3 has a buffer over-read via a crafted regular expression that triggers disclosure of sensitive information from process memory.

CVE-2018-18312 (2018-12-05)

Perl before 5.26.3 and 5.28.0 before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2018-18311 (2018-12-07)

Perl before 5.26.3 and 5.28.x before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2015-8853 (2016-05-25)

The (1) S_reghop3, (2) S_reghop4, and (3) S_reghopmaybe3 functions in regexec.c in Perl before 5.24.0 allow context-dependent attackers to cause a denial of service (infinite loop) via crafted utf-8 data, as demonstrated by "a\x80."

CVE-2013-1667 (2013-03-14)

The rehash mechanism in Perl 5.8.2 through 5.16.x allows context-dependent attackers to cause a denial of service (memory consumption and crash) via a crafted hash key.

CVE-2010-4777 (2014-02-10)

The Perl_reg_numbered_buff_fetch function in Perl 5.10.0, 5.12.0, 5.14.0, and other versions, when running with debugging enabled, allows context-dependent attackers to cause a denial of service (assertion failure and application exit) via crafted input that is not properly handled when using certain regular expressions, as demonstrated by causing SpamAssassin and OCSInventory to crash.

CVE-2010-1158 (2010-04-20)

Integer overflow in the regular expression engine in Perl 5.8.x allows context-dependent attackers to cause a denial of service (stack consumption and application crash) by matching a crafted regular expression against a long string.

CVE-2009-3626 (2009-10-29)

Perl 5.10.1 allows context-dependent attackers to cause a denial of service (application crash) via a UTF-8 character with a large, invalid codepoint, which is not properly handled during a regular-expression match.

CVE-2008-1927 (2008-04-24)

Double free vulnerability in Perl 5.8.8 allows context-dependent attackers to cause a denial of service (memory corruption and crash) via a crafted regular expression containing UTF8 characters. NOTE: this issue might only be present on certain operating systems.

CVE-2005-3962 (2005-12-01)

Integer overflow in the format string functionality (Perl_sv_vcatpvfn) in Perl 5.9.2 and 5.8.6 Perl allows attackers to overwrite arbitrary memory and possibly execute arbitrary code via format string specifiers with large values, which causes an integer wrap and leads to a buffer overflow, as demonstrated using format string vulnerabilities in Perl applications.

CVE-2007-5116 (2007-11-07)

Buffer overflow in the polymorphic opcode support in the Regular Expression Engine (regcomp.c) in Perl 5.8 allows context-dependent attackers to execute arbitrary code by switching from byte to Unicode (UTF) characters in a regular expression.

CVE-2012-5195 (2012-12-18)

Heap-based buffer overflow in the Perl_repeatcpy function in util.c in Perl 5.12.x before 5.12.5, 5.14.x before 5.14.3, and 5.15.x before 15.15.5 allows context-dependent attackers to cause a denial of service (memory consumption and crash) or possibly execute arbitrary code via the 'x' string repeat operator.

CVE-2016-2381 (2016-04-08)

Perl might allow context-dependent attackers to bypass the taint protection mechanism in a child process via duplicate environment variables in envp.

CVE-2013-7422 (2015-08-16)

Integer underflow in regcomp.c in Perl before 5.20, as used in Apple OS X before 10.10.5 and other products, allows context-dependent attackers to execute arbitrary code or cause a denial of service (application crash) via a long digit string associated with an invalid backreference within a regular expression.

CVE-2011-1487 (2011-04-11)

The (1) lc, (2) lcfirst, (3) uc, and (4) ucfirst functions in Perl 5.10.x, 5.11.x, and 5.12.x through 5.12.3, and 5.13.x through 5.13.11, do not apply the taint attribute to the return value upon processing tainted input, which might allow context-dependent attackers to bypass the taint protection mechanism via a crafted string.

CVE-2023-47100

In Perl before 5.38.2, S_parse_uniprop_string in regcomp.c can write to unallocated space because a property name associated with a \p{...} regular expression construct is mishandled. The earliest affected version is 5.30.0.

CVE-2024-56406 (2025-04-13)

A heap buffer overflow vulnerability was discovered in Perl. When there are non-ASCII bytes in the left-hand-side of the `tr` operator, `S_do_trans_invmap` can overflow the destination pointer `d`.    $ perl -e '$_ = "\x{FF}" x 1000000; tr/\xFF/\x{100}/;'    Segmentation fault (core dumped) It is believed that this vulnerability can enable Denial of Service and possibly Code Execution attacks on platforms that lack sufficient defenses.

CVE-2023-47039 (2023-10-30)

Perl for Windows relies on the system path environment variable to find the shell (cmd.exe). When running an executable which uses Windows Perl interpreter, Perl attempts to find and execute cmd.exe within the operating system. However, due to path search order issues, Perl initially looks for cmd.exe in the current working directory. An attacker with limited privileges can exploit this behavior by placing cmd.exe in locations with weak permissions, such as C:\ProgramData. By doing so, when an administrator attempts to use this executable from these compromised locations, arbitrary code can be executed.

CVE-2016-1238 (2016-08-02)

(1) cpan/Archive-Tar/bin/ptar, (2) cpan/Archive-Tar/bin/ptardiff, (3) cpan/Archive-Tar/bin/ptargrep, (4) cpan/CPAN/scripts/cpan, (5) cpan/Digest-SHA/shasum, (6) cpan/Encode/bin/enc2xs, (7) cpan/Encode/bin/encguess, (8) cpan/Encode/bin/piconv, (9) cpan/Encode/bin/ucmlint, (10) cpan/Encode/bin/unidump, (11) cpan/ExtUtils-MakeMaker/bin/instmodsh, (12) cpan/IO-Compress/bin/zipdetails, (13) cpan/JSON-PP/bin/json_pp, (14) cpan/Test-Harness/bin/prove, (15) dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp, (16) dist/Module-CoreList/corelist, (17) ext/Pod-Html/bin/pod2html, (18) utils/c2ph.PL, (19) utils/h2ph.PL, (20) utils/h2xs.PL, (21) utils/libnetcfg.PL, (22) utils/perlbug.PL, (23) utils/perldoc.PL, (24) utils/perlivp.PL, and (25) utils/splain.PL in Perl 5.x before 5.22.3-RC2 and 5.24 before 5.24.1-RC2 do not properly remove . (period) characters from the end of the includes directory array, which might allow local users to gain privileges via a Trojan horse module under the current working directory.

CVE-2015-8608 (2017-02-07)

The VDir::MapPathA and VDir::MapPathW functions in Perl 5.22 allow remote attackers to cause a denial of service (out-of-bounds read) and possibly execute arbitrary code via a crafted (1) drive letter or (2) pInName argument.

NAME

pl2bat - wrap perl code into a batch file

SYNOPSIS

pl2bat -h

pl2bat [-w] [-a argstring] [-s stripsuffix] [files]

pl2bat [-w] [-n ntargs] [-o otherargs] [-s stripsuffix] [files]

DESCRIPTION

This utility converts a perl script into a batch file that can be executed on DOS-like operating systems. This is intended to allow you to use a Perl script like regular programs and batch files where you just enter the name of the script [probably minus the extension] plus any command-line arguments and the script is found in your PATH and run.

ADVANTAGES

There are several alternatives to this method of running a Perl script. They each have disadvantages that help you understand the motivation for using pl2bat.

  1. C:> perl x:/path/to/script.pl [args]
  2. C:> perl -S script.pl [args]
  3. C:> perl -S script [args]
  4. C:> ftype Perl=perl.exe "%1" %*
    C:> assoc .pl=Perl
    then
    C:> script.pl [args]
  5. C:> ftype Perl=perl.exe "%1" %*
    C:> assoc .pl=Perl
    C:> set PathExt=%PathExt%;.PL
    then
    C:> script [args]

1 and 2 are the most basic invocation methods that should work on any system [DOS-like or not]. They require extra typing and require that the script user know that the script is written in Perl. This is a pain when you have lots of scripts, some written in Perl and some not. It can be quite difficult to keep track of which scripts need to be run through Perl and which do not. Even worse, scripts often get rewritten from simple batch files into more powerful Perl scripts in which case these methods would require all existing users of the scripts be updated.

3 works on modern Win32 versions of Perl. It allows the user to omit the ".pl" or ".bat" file extension, which is a minor improvement.

4 and 5 work on some Win32 operating systems with some command shells. One major disadvantage with both is that you can't use them in pipelines nor with file redirection. For example, none of the following will work properly if you used method 4 or 5:

C:> script.pl <infile
C:> script.pl >outfile
C:> echo y | script.pl
C:> script.pl | more

This is due to a Win32 bug which Perl has no control over. This bug is the major motivation for pl2bat [which was originally written for DOS] being used on Win32 systems.

Note also that 5 works on a smaller range of combinations of Win32 systems and command shells while 4 requires that the user know that the script is a Perl script [because the ".pl" extension must be entered]. This makes it hard to standardize on either of these methods.

DISADVANTAGES

There are several potential traps you should be aware of when you use pl2bat.

The generated batch file is initially processed as a batch file each time it is run. This means that, to use it from within another batch file you should preceed it with call or else the calling batch file will not run any commands after the script:

call script [args]

Except under Windows NT, if you specify more than 9 arguments to the generated batch file then the 10th and subsequent arguments are silently ignored.

Except when using CMD.EXE under Windows NT, if perl.exe is not in your PATH, then trying to run the script will give you a generic "Command not found"-type of error message that will probably make you think that the script itself is not in your PATH. When using CMD.EXE under Windows NT, the generic error message is followed by "You do not have Perl in your PATH", to make this clearer.

On most DOS-like operating systems, the only way to exit a batch file is to "fall off the end" of the file. pl2bat implements this by doing goto :endofperl and adding __END__ and :endofperl as the last two lines of the generated batch file. This means:

No line of your script should start with a colon.

In particular, for this version of pl2bat, :endofperl, :WinNT, and :script_failed_so_exit_with_non_zero_val should not be used.

Care must be taken when using __END__ and the DATA file handle.

One approach is:

.  #!perl
.  while( <DATA> ) {
.	  last   if  /^__END__$/;
.	  [...]
.  }
.  __END__
.  lines of data
.  to be processed
.  __END__
.  :endofperl

The dots in the first column are only there to prevent cmd.exe to interpret the :endofperl line in this documentation. Otherwise pl2bat.bat itself wouldn't work. See the previous item. :-)

The batch file always "succeeds"

The following commands illustrate the problem:

C:> echo exit(99); >fail.pl
C:> pl2bat fail.pl
C:> perl -e "print system('perl fail.pl')"
99
C:> perl -e "print system('fail.bat')"
0

So fail.bat always reports that it completed successfully. Actually, under Windows NT, we have:

C:> perl -e "print system('fail.bat')"
1

So, for Windows NT, fail.bat fails when the Perl script fails, but the return code is always 1, not the return code from the Perl script.

FUNCTION

By default, the ".pl" suffix will be stripped before adding a ".bat" suffix to the supplied file names. This can be controlled with the -s option.

The default behavior is to have the batch file compare the OS environment variable against "Windows_NT". If they match, it uses the %* construct to refer to all the command line arguments that were given to it, so you'll need to make sure that works on your variant of the command shell. It is known to work in the CMD.EXE shell under Windows NT. 4DOS/NT users will want to put a ParameterChar = * line in their initialization file, or execute setdos /p* in the shell startup file.

On Windows95 and other platforms a nine-argument limit is imposed on command-line arguments given to the generated batch file, since they may not support %* in batch files.

These can be overridden using the -n and -o options or the deprecated -a option.

OPTIONS

-n ntargs

Arguments to invoke perl with in generated batch file when run from Windows NT (or Windows 98, probably). Defaults to '-x -S "%0" %*'.

-o otherargs

Arguments to invoke perl with in generated batch file except when run from Windows NT (ie. when run from DOS, Windows 3.1, or Windows 95). Defaults to '-x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9'.

-a argstring

Arguments to invoke perl with in generated batch file. Specifying -a prevents the batch file from checking the OS environment variable to determine which operating system it is being run from.

-s stripsuffix

Strip a suffix string from file name before appending a ".bat" suffix. The suffix is not case-sensitive. It can be a regex if it begins with `/' (the trailing '/' is optional and a trailing $ is always assumed). Defaults to /.plx?/.

-w

If no line matching /^#!.*perl/ is found in the script, then such a line is inserted just after the new preamble. The exact line depends on $Config{startperl} [see Config]. With the -w option, " -w" is added after the value of $Config{startperl}. If a line matching /^#!.*perl/ already exists in the script, then it is not changed and the -w option is ignored.

-u

If the script appears to have already been processed by pl2bat, then the script is skipped and not processed unless -u was specified. If -u is specified, the existing preamble is replaced.

-h

Show command line usage.

EXAMPLES

C:\> pl2bat foo.pl bar.PM 
[..creates foo.bat, bar.PM.bat..]

C:\> pl2bat -s "/\.pl|\.pm/" foo.pl bar.PM
[..creates foo.bat, bar.bat..]

C:\> pl2bat < somefile > another.bat

C:\> pl2bat > another.bat
print scalar reverse "rekcah lrep rehtona tsuj\n";
^Z
[..another.bat is now a certified japh application..]

C:\> ren *.bat *.pl
C:\> pl2bat -u *.pl
[..updates the wrapping of some previously wrapped scripts..]

C:\> pl2bat -u -s .bat *.bat
[..same as previous example except more dangerous..]

BUGS

$0 will contain the full name, including the ".bat" suffix when the generated batch file runs. If you don't like this, see runperl.bat for an alternative way to invoke perl scripts.

Default behavior is to invoke Perl with the -S flag, so Perl will search the PATH to find the script. This may have undesirable effects.

On really old versions of Win32 Perl, you can't run the script via

C:> script.bat [args]

and must use

C:> script [args]

A loop should be used to build up the argument list when not on Windows NT so more than 9 arguments can be processed.

See also "Disadvantages".

SEE ALSO

perl, perlwin32, runperl.bat