fix: judge a save-script destination another local user can steer
Closes #4565.
open --save-script=<path> resolved the destination by name. A second local user who could write any directory on the way to it could replace that component, or leave a symbolic link there before the entry was created, and move the recording wherever they chose. Both the local writer and the remote staging path had it.
Node exposes no openat or renameat, so a publisher cannot resolve a destination relative to a verified directory handle, and no re-check closes a race with a local attacker. The window is closed by permissions: a destination is accepted only when no other non-root local user can modify any directory the publish traverses. Every directory the kernel steps into is judged, not only the final real path, since a plain directory under a shared one can hold a link into a private destination. .. is applied to the directory the walk reached, not to the text.
A destination is refused under script_ancestor_untrusted when a traversed directory is owned by neither you nor root, is writable by other or by its group, is where the entry would be created while others may add entries, or holds a link another user could have planted. Missing levels are created one at a time at 0700, and a refused destination creates nothing.
A group-writable directory is refused whoever owns it, with a chmod g-w hint. An earlier shape accepted one whose group looked private to this user; that is dropped. Membership cannot be proven — systemd-userdbd answers memberships /etc/passwd and /etc/group never show, so an unseen user can hold the gid. Under umask 002 a directory you create is group-writable and is refused until you chmod g-w it.
ACLs, network mounts and mounts over a checked directory sit outside the rule: it says no other local user can steer where the recording is written, not that nobody can read it.
Scope. The rule judges a destination a caller names. Destinations the daemon picks for itself keep main's behavior byte for byte; #4649 decides that chain separately.
Size. Production source is +687/−62 over 6 files (+625 net), most of it the host-kit walk. No new flag, command, state name or wire field.
🤖 Generated with Claude Code