This is technically challenging. We would have to replace the
/usr/bin/sudo binary with the wrapper, as the PATH only contains
/usr/bin in some execution contexts. Moving setuid binaries around is a
risk at its own.
Further, we really want to enforce this hardening by making it
impossible to call sudo.
Felix
Actually I would prefer to not even have sudo installed, but as we use
the same container for privileged and non-privileged execution, this is
the workaround (and it also helps to issue a meaningful error message
on accidental sudo invocation).
AFAIK, there is no way to switch users, given that switching via su is
not possible as we don't set a password for root.
So yes, it's a security feature.
Felix
That depends on how the container is started. If it is a vanilla
docker, root inside the container is basically the same as root on the
host. On docker rootless or podman you're right, root in the container
cannot gain relevant extra privileges.
Felix
In this case it is a security boundary. In the other cases, it just
emits a better error message - and a way to find remaining sudo calls.
>
> Conceptually, it should affect yocto builds as well. We are installing
> sudo and granting password-less access already as base image level. Only
> blocking isar-unprivileged would be inconsistent.
I'm wondering if this is a legacy thing, as Yocto can be built for
quite some time fully rootless. It even prohibits sudo via it's task
executor by switching to a new user namespace (a side effect of that)
[1].
Probably it would be better to drop sudo in the yocto container as well
(as part of the ongoing host tooling cleanup).
Felix
How about just dropping this patch and applying the rest of the series
so that we can move forward on the isar side?
That gives us time to clarify how to warn / discourage the sudo usage.
PS: Unfortunately we can't use the bitbake blocking of sudo in
rootless, as [1] also blocks our further splitting of namespaces.
Felix