halostatue / minitar

Minimal pure-ruby support for POSIX tar(1) archives.
Other
38 stars 27 forks source link

`Archive::Tar::Minitar::PosixHeader.from_data` is vulnerable to DoS by negative size fields #31

Closed refashioned closed 5 years ago

refashioned commented 6 years ago

minitar is vulnerable to the same infinite loop that RubyGems was vulnerable to before version 2.7.6. See:

Download loop.gem from the first link; then minitar list loop.gem will give an endless stream of

loop
loop
loop
loop
loop
loop

The problem is that Archive::Tar::Minitar::PosixHeader.from_data parses fields using oct, and oct allows lots of syntax including negative numbers.

Be aware that RubyGems' strict_oct fix made their code incompatible with some kinds of tar headers, so minitar may have to do something more careful. https://github.com/rubygems/rubygems/issues/2213