Skip to content

ZipFile.ExtractToDirectory causes faulty permissions with pinned files #94465

Description

@BaerMitUmlaut

Description

When unpacking certain ZIP files on Linux that were packed on Windows and had the "pinned" attribute set (example file), ZipFile.ExtractToDirectory will cause the file to only have execute permissions (------x---).

Reproduction Steps

  • Pick any file
  • Set the "pinned" attribute through cmd: attrib +p filename
  • Pack as a ZIP file using 7zip (packing through Windows does not preserve the "pinned" attribute)
  • Unpack the file on Linux (or in a WSL owned folder like /tmp) using the following code:
    public class Program
    {
        private static void Main(string[] args)
        {
            ZipFile.ExtractToDirectory(args[0], args[0].Replace(".zip", ""), Encoding.UTF8);
        }
    }
  • Verify the files permissions using ls -l:
    $ ls -l /tmp/dotnet
    total 28
    ------x--- 1 foobar foobar 24783 Nov  7 13:41 dotnet.jpg
    

Expected behavior

The permissions should be -rw-r--r--, like any file that did not have the "pinned" attribute set when it was packed.

Actual behavior

Read and write permissions are missing and an excutable permission is set (------x---).

Regression?

No response

Known Workarounds

Repacking the ZIP through the Windows packing tools or unsetting the "pinned" flag fixes the problem but cannot be done through code.

Configuration

  • .NET 6.0
  • Windows 10 / Ubuntu 20.04 in WSL

Activity

  1. ghost added
    untriaged
    on Nov 7, 2023
  2. gwell commented on Nov 9, 2023

    @gwell

    Also seeing this problem on Android when using ZipFileExtensions.ExtractToFile(ZipArchiveEntry, String).

  3. BaerMitUmlaut commented on Nov 14, 2023

    @BaerMitUmlaut
    Author

    The fix looks fairly easy:

    I tried making a fix but was so far unable to get the tools completely running including a new test file, might try again later.

  4. carlossanlop commented on Dec 6, 2023

    @carlossanlop
    Contributor

    @BaerMitUmlaut thanks for trying to get a fix.

    I tried making a fix but was so far unable to get the tools completely running including a new test file, might try again later.

    Where were you blocked? Can we help unblock you?

    I wonder if this issue is related to reparse points not being fully supported: https://learn.microsoft.com/en-us/windows/win32/fileio/reparse-points

    At least one of the reparse points indicates that a file is from OneDrive.

    @dotnet/area-system-io have you folks worked with these files lately?

  5. added this to the 9.0.0 milestone on Dec 6, 2023
  6. ghost removed
    untriaged
    on Dec 6, 2023
  7. added
    untriaged
    and removed
    untriaged
    on Dec 6, 2023
  8. jozkee commented on Dec 16, 2023

    @jozkee
    Member

    @dotnet/area-system-io have you folks worked with these files lately?

    No, not really. But seems like P also means Sparse in older Windows versions https://superuser.com/questions/44812/windows-explorers-file-attribute-column-values/982721#982721.

    The permissions should be -rw-r--r--, like any file that did not have the "pinned"

    Are all other Windows attributes ignored when unzipping in Linux?

  9. BaerMitUmlaut commented on Dec 16, 2023

    @BaerMitUmlaut
    Author

    Are all other Windows attributes ignored when unzipping in Linux?

    I don't know, but there might be more that influence it. This one was just the one I found in the wild on a production system.

  10. modified the milestones: 9.0.0, 10.0.0 on Aug 19, 2024
  11. modified the milestones: 10.0.0, Future on Jul 26, 2025
  12. added
    api-suggestion
    on Oct 7, 2025
  13. added
    in-pr
    on Oct 9, 2025
  14. added
    api-suggestion
    and removed
    api-suggestion
    on Oct 9, 2025
  15. modified the milestones: Future, 11.0.0 on Oct 16, 2025
  16. alinpahontu2912 commented on Oct 21, 2025

    @alinpahontu2912
    Member

    Hey @BaerMitUmlaut, do you have any thoughts about the proposed api?

  17. BaerMitUmlaut commented on Oct 21, 2025

    @BaerMitUmlaut
    Author

    Looks good to me! I also checked your PR and I think that should fix the problem.

  18. added theissue type on Jun 9, 2026
  19. added a commit that references this issue on Jul 15, 2026
    a238e23
  20. locked and limited conversation to collaborators on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api-suggestionarea-System.IO.Compressionin-pr

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions