Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: refuse a group-writable non-sticky volume root for the XDG trash
[._.]/ Adam Eivy700840f97f48
diff --git a/server/lib/nativeTrashXdg.js b/server/lib/nativeTrashXdg.jsindex cd2a5b60ed..e9b74fb65c 100644--- a/server/lib/nativeTrashXdg.js+++ b/server/lib/nativeTrashXdg.js@@ -77,13 +77,15 @@ const trustedOwner = (info, uid) => info.uid === 0 || info.uid === uid;// Whether a user other than root and the caller could rename entries of this// directory: anyone with write access to a non-sticky directory can, and in a-// sticky one the directory owner still can. A directory that holds a per-user-// trash must refuse that, or its owner swaps the checked trash directory for a-// symlink between the check and the move. Group write stays allowed: Ubuntu's-// user-private-group default (umask 002) makes 0775 the common mode of-// user-owned directories.+// sticky one the directory owner still can. A volume root that holds a+// per-user trash must refuse that, or such a user swaps the checked trash+// directory for a symlink between the check and the move. Group write counts+// too: whether a group has other members is not knowable from the mode, and+// NSS makes /etc/group an incomplete answer. Mount points are rarely+// group-writable (udisks gives 0700, fstab mounts a root-owned 0755), unlike+// the home data directory, which this check never covers.const othersCanRenameEntries = (info, uid) =>- !trustedOwner(info, uid) || ((info.mode & 0o002) !== 0 && (info.mode & 0o1000) === 0);+ !trustedOwner(info, uid) || ((info.mode & 0o022) !== 0 && (info.mode & 0o1000) === 0);/*** Spec §"Trash directories": prefer `$topdir/.Trash/$uid` when `$topdir/.Trash`diff --git a/server/lib/nativeTrashXdg.test.js b/server/lib/nativeTrashXdg.test.jsindex 37889e8e0d..7f31eb0897 100644--- a/server/lib/nativeTrashXdg.test.js+++ b/server/lib/nativeTrashXdg.test.js@@ -205,7 +205,12 @@ describe.skipIf(process.platform === 'win32')('XDG trash adapter', () => {await expect(_topDirTrash(top, uid)).rejects.toMatchObject({ code: 'TRASH_DIR_UNSAFE' });await chmod(top, 0o1777);expect(await _topDirTrash(top, uid)).toBe(join(top, `.Trash-${uid}`));+ // A group may hold other users, which the mode cannot tell apart.await chmod(top, 0o775);+ await expect(_topDirTrash(top, uid)).rejects.toMatchObject({ code: 'TRASH_DIR_UNSAFE' });+ await chmod(top, 0o1775);+ expect(await _topDirTrash(top, uid)).toBe(join(top, `.Trash-${uid}`));+ await chmod(top, 0o755);expect(await _topDirTrash(top, uid)).toBe(join(top, `.Trash-${uid}`));state.owners = { [top]: uid + 1 };await expect(_topDirTrash(top, uid)).rejects.toMatchObject({ code: 'TRASH_DIR_UNSAFE' });