Restrict current-user files cross-platform - #65
Conversation
Callers that inherit or reopen sensitive runtime files need to repair access on the verified handle, not assume Unix mode bits or a private parent are sufficient. This gives them one fail-closed primitive that preserves the current-user ownership check and installs native owner-only permissions, including a protected Windows DACL. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
An ordinary data handle does not imply authority to replace a Windows DACL, so permission repair could fail before securing the file. Reopening from the already-validated handle requests the exact ACL rights without reintroducing a path substitution race, and the Windows regression now uses the same capability boundary. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
Mode bits alone do not revoke extended ACL grants, so a successful restriction could leave another principal with access. The safe-file contract now removes ACL policy through the verified handle on macOS and Linux, while unsupported Unix platforms fail instead of claiming privacy they cannot establish. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
The macOS ACL setter returns a C int, so a failure may appear in the uintptr syscall result as a zero-extended 32-bit minus one rather than an all-bits-set machine word. Treating zero as the only success value keeps file restriction fail-closed across ABI return representations. Validation: reproduced the old false-success result by invoking ACL removal on a closed descriptor. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
Removing a deny ACL while group or other mode bits remain open creates a brief access window even if the final state is private. Supported Unix implementations now share a fail-closed sequence that narrows mode bits before ACL work and reapplies them afterward.\n\nPlatform-specific tests also distinguish Darwin/Linux enforcement from the intentional unsupported-Unix result instead of imposing one contract across incompatible implementations. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
A successful local chmod is not sufficient evidence that a filesystem enforced private access, and SMB-family mounts retain a server-side DACL that these helpers cannot safely rewrite. Fail before mutation on those Linux filesystems and require an exact mode readback around ACL removal so callers never receive a success-shaped result for ambiguous permissions. Validation: executed the complete safefileio test binary inside a Linux container in addition to the repository and cross-build suites. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
Permission repair cannot revoke a descriptor another process already obtained while a file was broad. Replace the unreleased mutation API with handle-bound validation so broad mode bits, access ACLs, Windows DACLs, and SMB-family filesystems fail without changing the object; callers must create a private replacement instead.\n\nNormalizing Linux filesystem magic through uint32 also keeps CIFS and SMB2 rejection effective when 32-bit statfs values are sign-extended. Validation: reproduced the sign-extension bypass in a Linux test binary and executed the complete updated safefileio suite inside Linux. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
The ACL probe and libc errno pointer must refer to the same OS thread; otherwise goroutine migration can turn an inspection failure into a false no-ACL result. Pinning the short native-call sequence preserves the validation-only contract while retaining typed PureGo function signatures. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
A DACL limited to trusted principals is still mutable through inheritance while it remains unprotected. Treat inheritable files as unsafe so validation cannot be invalidated by later ACE propagation from an attacker-controlled parent; recovery continues to require a separately created protected replacement. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
AFS and similar network or user-space filesystems can grant access outside local file modes and access ACLs, so treating them as supported can falsely validate secret-bearing files as private. Classify these filesystems through statfs and fail closed while retaining uint32 normalization for 32-bit Linux. Validated with the safefileio suite in a Linux container, native vet and tests, Linux 386/arm cross-builds, and Windows/Darwin cross-builds. Generated with OpenAI Codex Co-authored-by: OpenAI Codex <noreply@openai.com>
roborev: Combined Review (
|
Sensitive runtime files can predate a hardened caller or carry explicit permissions that a private parent does not override. Unix
chmodsemantics are not portable to Windows, where a current-user-owned file may still expose broad ACL entries.This adds one fail-closed safe-file operation on an already-open, ownership-verified regular file: owner-only mode on Unix and a protected current-user/System/Administrators DACL on Windows. Callers retain path and format policy while sharing the security-sensitive platform logic. Platform-specific coverage pins both permission repairs.