MacOS – Why does unzipping via Finder set execute bit on text files

findermacos

When unzipping a .zip file by double-clicking on the .zip file via the Finder, I notice that plaintext files have their execute bit on. Unzipping an equivalent .tar.gz file does not exhibit this behavior. Why?

For example, unzipping this zip file will result in the LICENSE, README.md and CONTRIBUTING.md (plaintext files) to be marked as executable. But unzipping this .tar.gz file does not exhibit this behavior.

When unzipping each using the command line unzip utility, OSX does not mark the files as executable. So why is the Finder doing this? It seems strange, and insecure, for it to be marking plaintext files as executable.

Best Answer

The ZIP format does not contain information about Unix permissions (see ZIP, file headers). By default all files are then marked as executable.

Tar can store this information and by untarring it is possible to restore them (see tar, file format).