5 ms·
It's not an issue with sentinel values, but an issue with not escaping your inputs I don't believe tar "falls for" such a stupid trick. Confusing metadata wit
by raverbashing 6y ago
It's not an issue with sentinel values, but an issue with not escaping your inputs
I don't believe tar "falls for" such a stupid trick.
Confusing metadata with actual data is a classic security blunder
tl;dr: cpio has amateurish levels of input validation/handling
- masklinn 6y ago> tl;dr: cpio is an amateur project TBF cpio dates back to v7 unix, some time before considerations of security really became a thing.
- raverbashing 6y agoThe question is not so much why it was like that, the question is why nobody fixed this yet I like the Unix environment, but I can understand why stuff like systemd take hold, because the legacy is painful. And any Unix environment has this weird mix of tools where the most popular ones got better over time (tar, etc) then you have the weird ones that didn't evolve so much like cpio
- cyphar 6y agoA bit of shameless self-promotion, I wrote a blog post some time ago which goes through the history of tar[1]. Tar definitely has evolved through the Unix wars, but I wouldn't say the final result is really that great. While we do tend to reinvent tools for reinvention's sake, I do think tar really does deserve a redesign based on modern constraints (rather than the constraints of tape archives). Zip archives are markedly better designed. Also, cpio did evolve at least somewhat. In fact POSIX has a separate archive tool called "pax" (which supports both tar and cpio) which was meant to act as a truce between the tar and cpio factions of Unix vendors. Nobody uses it, as far as I know. [1]: https://www.cyphar.com/blog/post/20190121-ociv2-images-i-tar https://www.cyphar.com/blog/post/20190121-ociv2-images-i-tar
- lboc 6y agoIt sees some use in z/OS. For example, open source tarballs aren't generally EBCDIC, so: pax -rvf automake-1.16.tar -o from=ISO8859-1,to=IBM-1047
- masklinn 6y ago> Zip archives are markedly better designed. Yes and no. They have advantages and drawbacks: * zip archives don't require seeking through the entire thing to list archive contents * zip archives can random-access files cheaply * zip checksums the files themselves (AFAIK tar only checksums the header) * zip compresses files individually, meaning different files can use different configuration * the central directory (CD) means you can trade efficiency for very cheap updates: removing a file is just rewriting the CD without that file, likewise to replace a file just tack the new file at the end, then write a new CD with updated offsets However * "streaming" zips can lead to schizophrenia as the central directory record does not necessarily match the streamed contents or ordering * zip only compresses files individually meaning there's no cross-file efficiency to be had (some compression formats have a "solid" archive concept which compresses globally as an opt-in) so tar can compressed better depending on the mix and the compression algorithm (assuming both archives use the same method) > Also, cpio did evolve at least somewhat. In fact POSIX has a separate archive tool called "pax" (which supports both tar and cpio) which was meant to act as a truce between the tar and cpio factions of Unix vendors. Nobody uses it, as far as I know. GNU CPIO apparently straights support tar.
- cyphar 6y agoI would argue the upsides out-weigh the downsides. Out of two downsides you mention, one actually applies to tar archives as well (the ordering of files can be random) -- it's just that there's no index to compare against. If you added an index to a tar archive it would have the same issue. The compression point you make is fair, though there is a clear trade-off when it comes to random-access. Naive whole-archive compression makes efficient random-accesses impossible because you have to decompress everything before the data you're trying to access. A sufficiently-clever archive and compression format may be able to overcome that, but I'd argue that zip made a reasonable trade-off here. > AFAIK tar only checksums the header tar doesn't checksum anything, there isn't even a CRC.
- josephcsible 6y ago> the question is why nobody fixed this yet Because fixing it would be a breaking change to the archive format.
- raverbashing 6y agoYou don't have to change the archive format in a breaking way, you just need to extend it Backwards compatibility is more important with archives than with the util itself
- cyphar 6y agoSo does tar. In fact, tar's dash-less flag support ("tar xvfz") is probably an artefact of the fact that in Unix v1 they hadn't come up with dashed flags, and "tar" appears to have been a successor to (or modelled after) "tp" which was a successor to "tap" which was in Unix v1 and had roughly the same flag layout.