From 8ae3a445a7cd7d657739e17127fcc8e2911ffcf8 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 2 Oct 2026 22:45:07 +1000 Subject: [PATCH] fix(storepkg): mask the tar mode to the permission bits before narrowing The conversion is now exact rather than a truncation: the low nine bits are the permission bits whatever the tar header's width. --- internal/infrastructure/storepkg/registry.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/infrastructure/storepkg/registry.go b/internal/infrastructure/storepkg/registry.go index c0ac93523..a44cd4c59 100644 --- a/internal/infrastructure/storepkg/registry.go +++ b/internal/infrastructure/storepkg/registry.go @@ -174,7 +174,9 @@ func validateLayerEntry(header *tar.Header, declared map[string]uint32, found ma if !ok || found[header.Name] { return fmt.Errorf("package layer contains undeclared or duplicate file %q", header.Name) } - if uint32(header.Mode)&0o777 != mode&0o777 { + // The mask makes the conversion exact: the low nine bits are the + // permission bits whatever the tar header's width. + if uint32(header.Mode&0o777) != mode&0o777 { return fmt.Errorf("package file %q mode differs from descriptor", header.Name) } return nil