Compartir a través de


Why do .zip files from Mac OS show up as green/encrypted?

It’s kind of funny really. The ZIP specification mandates that a program/OS creating a zip archive include a tag informing about itself to the program trying to decompress the archive. This information is called “version made by”, and looks like this:

           0 - MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)
          1 - Amiga                     2 - OpenVMS
          3 - UNIX                      4 - VM/CMS
          5 - Atari ST                  6 - OS/2 H.P.F.S.
          7 - Macintosh                 8 - Z-System
          9 - CP/M                     10 - Windows NTFS
         11 - MVS (OS/390 - Z/OS)      12 - VSE
         13 - Acorn Risc               14 - VFAT
         15 - alternate MVS            16 - BeOS
         17 - Tandem                   18 - OS/400
         19 - OS/X (Darwin)            20 thru 255 - unused

Now, interestingly, it seems that Mac OS is tagging the zip archives it creates with the value 3 (UNIX). Ok, so far no problem, I guess.

The problem happens when Windows gets confused about how to interpret file/folder attributes. In FAT/NTFS, these values are stored according to this definition of File Attribute Constants. You’ll see that FILE_ATTRIBUTE_ENCRYPTED has a value of 0x4000.

The interesting part is how Mac OS is storing its file attributes in the zip archive. Mac OS, being a UNIX based OS, uses the UNIX file/folder attributes system (and permissions, but that’s a topic for another time…).. Well, it just so happens that in POSIX, the flag to describe a directory/folder (S_IFDIR) coincidentally also has the value 0x4000. So it turns out the zip decompression code wasn’t aware that there might be other operating systems out there that might create zip archives…

Bonus question: can you change this behavior. Answer: No; but you can clear the encryption flag from the extracted files/folders easily.

Comments

  • Anonymous
    May 27, 2012
    interesting thing is when using 7-zip, it not only extracts un-encrypted but also removes the extra macosx folder. So part of this is a mac bug too in my opinion
  • Anonymous
    May 30, 2012
    Ian: yes, Mac OS adds that "extra" folder which apparently contains thumbnails of the items being zipped as well as some additional metadata. Most/all of this information should be recoverable from the items themselves so I'm guessing this is done for performance, so it's probably safe to ignore/remove/not extract.
  • Anonymous
    October 29, 2012
    Very helpful. I noticed that the green files were always from Macs, but didn't know why. FYI after clean installing on Windows 8, it lost the encryption certificate and couldn't open the Mac-zipped content anymore. Fortunately I had the original email with the ZIP and just re-extracted successfully. Lost a few files though since I had added some files in the "encrypted" directory.
  • Anonymous
    November 09, 2012
    Hi Jeff, thanks for reading! I haven't seen the problem you describe, I'll see if I can reproduce it.
  • Anonymous
    February 10, 2013
    I cannot believe this still happening. I sell digital products, zipped on a mac. But I now take the extra step of deleting the extra mac folder in the new zip. Any idea if that is enough to stop this problem from happening to windows users???Ryan
  • Anonymous
    February 19, 2013
    @Ryan Nagy: unfortunately, that won't be enough to prevent this from happening
  • Anonymous
    June 12, 2013
    Same issue here.I wonder why folders still get extracted correctly while the flag gets misinterpreted.... not worth a bug fix from MS?
  • Anonymous
    September 23, 2013
    AxelD: If I remember correctly, this is fixed in Windows 8 so users running that release or higher should not see this problem anymore.
  • Anonymous
    April 25, 2014
    The comment has been removed
  • Anonymous
    May 30, 2014
      I tried to reproduce this behavior on my Windows 7 system, butcouldn't.  (My Windows Explorer shows no unusual attributes for a folderin a .zip archive created on a Mac using the Finder Compress option.)  Info-ZIP UnZip (6.00, "-Zv" report) shows these attributes for thefolder: Unix file attributes (040755 octal):            drwxr-xr-x(040755 = 0x41ED, so the 0x4000 bit is set.)  If this problem still exists in Windows 7 (or XP), then I'd like toget a failing test case (because I haven't found a way to make one).  Also, for my curiosity, ... [...] the extra macosx folder. [...]  Which "the extra folder" is that, exactly?  The "__MACOSX" folder(which may or may not appear, depending on how the archive was created),or something else?
  • Anonymous
    October 15, 2014
    Not sure if this helps, but when I encounter this problem I've noticed that "opening" the zip file, by double-clicking, will open non-encrypted versions of the file(s). Right-clicking and selecting Extract All seems to always extract the files as encrypted.
  • Anonymous
    February 06, 2015
    The comment has been removed
  • Anonymous
    February 14, 2015
    The comment has been removed