That won’t work. We’d need to use ix rules for those in the base abstraction which would break for anyone not having apparmor-profile-everything installed as there’s no other profile it can use.
Is it possible for an attacker to install a root SSL certificate to decrypt TLS traffic, mitm apt and inject a malicious kernel during upgrades?
GPG verification should prevent this but this has been bypassed before so I don’t want to rely on it completely.
Another way to prevent this would be to use onion mirrors unless Tor traffic can be mitmed if the user’s system is compromised (I don’t know if it can or not).
I guess so. You could test this by moving the folder that contains SSL certificates. /etc/something, part of packages ca-certificates or so. So that folder needs to be protected from root too.
That was the default in past but undone due to unreliability.
Also, an attacker can just install a local .deb file containing a malicious kernel with sudo apt-get install /path/to/malicious-kernel.deb which allows them to do whatever they want with the kernel images.
Is it possible to prevent this and only allow installing from repositories?
So apt won’t be able to access any .deb files on the system except ones in /var/cache/apt/. Unless the filename doesn’t have to end in .deb (dunno what apt would do then).
This might also be able to be prevented with a wrapper.
Both apt and dpkg support a TON of command line options. Proably one to change the path to the SSL CA certificates. For example I am not certain that path to sources.list or sources.list.d can be changed. (Whonix build script uses that.) Also some environment variables.
For the purpose of apparmor-profile-everything it is probably best to prohibit direct access by root to apt / dpkg. All access should be through (a) wrapper(s). (Probably an apt wrapper that is allowed to call dpkg.)
The wrapper would have a (configurable) whitelisted amount of allowed command line options (and perhaps environment variables if there is an important/sane use case.) A blacklist approach is probably not possible since these command line parameters are too complex.
The wrapper could be created any time. Integration (with uwt) we can worry about once the wrapper exists.
Configurable by who? The user? If so, nothing stops an attacker from abusing it.
Very little options would be needed for ordinary usage so a configurable whitelist probably isn’t necessary.
It would be very important and sane. Otherwise an attacker could use some LD_PRELOAD tricks.
We can unset all environment variables with
for env_var in $(env | sed -e 's/=.*//g'); do unset "${env_var}"; done
Important ones like $PATH can be excluded.
We could alternatively use apparmor’s environment scrubbing which unsets dangerous environment variables but I think the method above is far more effective.
I’m not sure if this should be opt-in anymore. Breakages will be easy to fix for the most part and issues shouldn’t really occur unless doing some crazy stuff. The security advantages of this are great and it plugs many holes already.
By those booting in a different boot mode. Or temporarily disabling apparmor-profile-everything. Or when booting from a (offline) live iso rather than hdd.
Too complicated. Easier options. Environment variable sanitization is a common thing.
Can be considered after testing (call for testers blog post) when ready. Let me know when time comes / draft.
Also needs to not restrict user freedoms. Grub boot menu entries to boot into “full access admin mode”?
I don’t think we should use a grub boot menu for that. Users might see “admin mode”, think it would fix their problem, boots with it, it doesn’t fix their problem and now everything runs unconfined.