[[!tag debian]]
Random crazy Debian idea of today: add support to dpkg so that it uses containers (or namespaces, or whatever works for this) for running package maintainer scripts (pre- and postinst, pre- and postrm), to prevent them from accidentally or maliciously writing to unwanted parts of the filesystem, or from doing unwanted network I/O.
I think this would be useful for third-party packages, but also for packages from Debian itself. You heard it here first! Debian package maintainers have been known to make mistakes.
Obviously there needs to be ways in which these restrictions can be overridden, but that override should be clear and obvious to the user (sysadmin), not something they notice because they happen to be running strace or tcpdump during the install.
Corollary: dpkg could restrict where a .deb can place files based on the origin of the package.
Example: Installing chrome.deb from Google installs a file in
/etc/apt/sources.list.d
, which is a surprise to some. If dpkg were
to not allow that (as a file in the .deb, or a file created in
postinst), unless the user was told and explicitly agreed to it, it
would be less of a nasty surprise.
Example: Some stupid Debian package maintainer is very busy at work and does Debian hacking when they should really be sleeping, and types the following into their postrm script, while being asleep:
#!/bin/sh
PKG=perfectbackup
LIB="/var/lib/ $PKG"
rm -rf "$LIB"
See the mistake? Ideally, this would be found during automated testing before the package gets uploaded, but that assumes said package maintainer uses tools like piuparts.
I think it'd be better if we didn't rely only infallible, indefatigable people with perfect workflows and processes for safety.
Having dpkg make the whole filesystem read-only, except for the parts that clearly belong to the package, based on some sensible set of rules, or based a suitable override, would protect against mistakes like this.