{"record":{"id":"350b878bf6312cbc","repo":"larksuite/cli","slug":"s-cannot-retrieve-file-owner-for-q","errorCode":null,"errorMessage":"%s: cannot retrieve file owner for %q","messagePattern":"(.+?): cannot retrieve file owner for %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/binding/audit_unix.go","lineNumber":24,"sourceCode":"package binding\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"syscall\"\n\n\t\"github.com/larksuite/cli/internal/vfs\"\n)\n\n// checkOwnerUID verifies the file is owned by the current user.\nfunc checkOwnerUID(path, label string) error {\n\tstat, err := vfs.Stat(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: cannot stat %q: %w\", label, path, err)\n\t}\n\tsysStat, ok := stat.Sys().(*syscall.Stat_t)\n\tif !ok {\n\t\treturn fmt.Errorf(\"%s: cannot retrieve file owner for %q\", label, path)\n\t}\n\tif sysStat.Uid != uint32(os.Getuid()) {\n\t\treturn fmt.Errorf(\"%s: path %q is owned by uid %d, expected %d\",\n\t\t\tlabel, path, sysStat.Uid, os.Getuid())\n\t}\n\treturn nil\n}\n\n// auditFilePermissions rejects world/group-writable modes (always) and\n// world/group-readable modes (unless allowReadableByOthers is true, which\n// exec commands typically need for their usual 755 mode).\nfunc auditFilePermissions(effectivePath string, allowReadableByOthers bool, label string) error {\n\tinfo, err := vfs.Stat(effectivePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: cannot stat %q: %w\", label, effectivePath, err)\n\t}\n\tmode := info.Mode().Perm()\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/binding/audit_unix.go#L6-L42","documentation":"After stat succeeds, checkOwnerUID extracts the raw syscall.Stat_t via stat.Sys() to read the owner UID. On platforms or filesystems where the syscall-specific stat structure is unavailable, the type assertion fails and this error is thrown. It is a defensive guard: without owner information the security audit cannot proceed safely, so it fails closed.","triggerScenarios":"stat.Sys() does not return *syscall.Stat_t — practically only on non-Unix builds that still compile this file (it is guarded by !windows, so this indicates an exotic platform) or a vfs implementation returning a synthetic FileInfo without a real syscall backing.","commonSituations":"Running on an unusual/unsupported Unix-like platform; a vfs layer that fabricates FileInfo (e.g. tests, FUSE-like shims) without a real Stat_t; cross-compiled binary running under an emulation layer with incomplete stat support.","solutions":["Run the CLI on a supported Unix platform (Linux/macOS) with a standard filesystem","Ensure the file lives on a regular local filesystem, not a shim that hides syscall metadata","If you maintain a custom vfs backend, return the platform's real *syscall.Stat_t from Sys()","Report the platform combination to the maintainers if it should be supported"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if fi, err := os.Stat(path); err == nil {\n  if _, ok := fi.Sys().(*syscall.Stat_t); !ok {\n    return fmt.Errorf(\"platform cannot expose owner uid for %s\", path)\n  }\n}","typeGuard":"func hasSysStat(fi fs.FileInfo) (*syscall.Stat_t, bool) {\n  st, ok := fi.Sys().(*syscall.Stat_t)\n  return st, ok\n}","tryCatchPattern":null,"preventionTips":["Run the CLI on supported Unix platforms with standard filesystems","Avoid exotic FUSE/shim filesystems for audited files","Test on the target platform before deploying configs"],"tags":["platform","stat","security-audit"],"backgroundTag":"unsupported-platform-stat","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}