axlsx icon indicating copy to clipboard operation
axlsx copied to clipboard

Upgrade Rubyzip 2

Open fabdbt opened this issue 6 years ago • 6 comments

Could you please unlock rubyzip version to use newest version 2 ? https://github.com/rubyzip/rubyzip/releases/tag/v2.0.0

fabdbt avatar Oct 01 '19 10:10 fabdbt

There is a vulnerability in rubyzip < 1.3: https://github.com/rubyzip/rubyzip/pull/403

toncid avatar Oct 01 '19 22:10 toncid

By unlock, I do not mean allowing rubyzip versions prior to 1.3. I mean allowing people to use axlsx gem with rubyzip >= 1.3 and so rubyzip >= 2.

fabdbt avatar Oct 02 '19 06:10 fabdbt

@Apokly I've had success with the following polyfill on rubyzip == 1.2.1. YMMV. edit: simplified it, but misread the question. regardless; useful nonetheless.

Place a file ``zip.rb'' as below

lib/
  zip/
    zip.rb

zip.rb

# Polyfill to make AXLSX package work with v1.2.x `zip` which no longer defines `Zip::Zip`
require 'zip'
require 'zip/output_stream'

module Zip
  class ZipOutputStream < OutputStream
    def initialize(filename, stream = false)
      if stream
        filename = StringIO.new
      end
      super(filename, stream)
    end
  end
end

chriscz avatar Oct 31 '19 18:10 chriscz

There’s now a community-supported fork of axlsx: https://github.com/caxlsx/caxlsx

Versions 2.0.2 and 3.0.x have been released, both supporting newer versions of Rubyzip. See https://rubygems.org/gems/caxlsx/versions/3.0.1

noniq avatar Oct 31 '19 20:10 noniq

Note: there have since been more critical vulnerabilities discovered in rubyzip v1.0.0:

  • https://github.com/rubyzip/rubyzip/issues/315
  • https://github.com/rubyzip/rubyzip/issues/369

Taking a serious look at https://github.com/caxlsx/caxlsx ...

baburdick avatar Nov 11 '21 01:11 baburdick

As far as I understand, both vulnerabilities are in the context of extracting archives. Axlsx only creates archives.

However, it’s a very bad idea to have a vulnerable version of Rubyzip in your project at all, so please upgrade to at least caxlsx 2.0.2 or 3.0.1.

In caxlsx it's also possible to use an external zip program instead of Rubyzip, see https://www.rubydoc.info/gems/caxlsx/Axlsx/Package#serialize-instance_method

noniq avatar Nov 11 '21 09:11 noniq