mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-22 08:13:59 +00:00
weft-mount-helper is meant to be installed setuid root, but it trusted its caller entirely: it ran veritysetup, mount and umount from the caller's PATH, mounted a caller's image at any directory, such as over /etc, and unmounted any mountpoint. Any local user could have gained root through it. It now mounts only at an empty directory /run/user/<uid>/weft/mnt/<name> of the real user, where weft-appd puts its mountpoints, with every component from <uid> on owned by that user, not writable by others and opened without following symbolic links, and mounts through the opened directory, so the path cannot be swapped meanwhile. It opens the image and hash tree with the real user's permissions, checks the root hash is a hex digest, mounts read-only with nosuid, nodev and noexec through mount(2), and unmounts only an EROFS filesystem at such a directory. veritysetup runs from the absolute path fixed at build time (WEFT_VERITYSETUP, /usr/sbin/veritysetup by default), with an empty environment. Devices are named weft-<uid>-<name>, so a user reaches only their own; a device left by an interrupted mount is closed by the next mount or unmount at that directory, and a user may have at most 64 open, counted from the kernel's list of device-mapper devices under a root-owned lock. Closed standard streams are reopened on /dev/null before anything else is opened, and errors and panics are printed as one-line messages. Run setuid as nobody with a PATH holding a hostile veritysetup and mount, the helper refuses /etc and another user's directory as mountpoints, a symbolic link to /etc, a file nobody cannot read, a malformed root hash, and unmounting /etc or a directory with no image; a valid request reaches veritysetup at its fixed path, also with the standard streams closed, and the hostile programs never run. Unit tests cover the mountpoint rules. |
||
|---|---|---|
| .. | ||
| weft-app-shell | ||
| weft-appd | ||
| weft-build-meta | ||
| weft-compositor | ||
| weft-file-portal | ||
| weft-ipc-types | ||
| weft-mount-helper | ||
| weft-pack | ||
| weft-runtime | ||
| weft-servo-shell | ||