【问题标题】:Extracting user uploaded archives without exposing to ZipBombs?在不暴露于 ZipBombs 的情况下提取用户上传的档案?
【发布时间】:2011-05-16 20:27:50
【问题描述】:

我的问题很简单:我如何确保(或阻止)用户上传提取后会填满整个磁盘空间的存档(所谓的 ZipBomb)?我正在使用 PHP。

【问题讨论】:

标签: php upload archive


【解决方案1】:

在提取您的档案之前,使用 PHP Zip 库函数确保在提取时内容在总大小限制内。

例如:

$zip = zip_open('uploaded.zip');
$file = zip_read($zip);
$totalsize = 0;

while ($file) {
    $totalsize += zip_entry_filesize($file);
    $file = zip_read($zip); // read next file
}

zip_close($zip);

if ($totalsize > SIZE_LIMIT) {
    // not allowed!
}
猜你喜欢
  • 2018-03-02
  • 2010-09-14
  • 2019-07-13
  • 2021-04-13
  • 2018-05-12
  • 2017-07-22
  • 1970-01-01
  • 1970-01-01
  • 2022-08-06
相关资源
最近更新 更多