Neo_78 wrote: ↑Sun Jan 28, 2024 1:19 pm
I am als not sure why many Chrome-based browser cannot be executed with the sandbox feature. Is the sandbox disabled automatically for Chrome when you execute it in FatDog?
Here's the magic stuff that everybody whispers about not never dares to ask.
Let's start with a plain fact: everytime you launched chrome, it will run as root.
ALWAYS
Even when you're logged in as a regular user, chrome is always run as root, when you first launches it.
NO EXCEPTION.
Why? Because chrome is a suid (set-suid) application. It is always launched with the privilege as root. Check the file permission of chrome-sandbox in your chrome installation directory and you'll see what I mean.
So, what gives? After it is run as root, chrome will make certain Linux syscalls to limit itself (=put itself in a sandbox). Having put itself in a sandbox, chrome then relinquishes the root privilege and changes its identify back into the original logged-in user, with all the sandbox restrictions already in place.
But why does it need to run as root first? Simple. Because the syscalls to "limit itself" can only be called as root. These syscalls don't work as a regular user.
It's just like somebody who impersonates as a prison guard. As a prison guard, he gets the key to a jailroom. Once he gets the key, he goes inside the jail, and lock himself in. The he takes off his prison guard clothing, and then throw both the clothing and the keys out of the jail. Now, you can only do that if you're impersonating as a prison guard in the first place. You can't just go to a prison and ask for key.
Hence, chrome needs to (ironically) launch as root in order to provide you with more security.
Okay, so far so good. But why can't chrome run with sandbox while running as root? Because chrome developers think that as root, you can always get out of the jail, because, well, you're root and you're capable of everything. Hence, the sandbox is useless when being used for root.
So, in their wisdom to prevent you from having a false sense of security, they disable the sandbox feature if you're root; but they want you to be aware that fact, hence they force you to use the --no-sandbox flag, or chrome will refuse to run at all.
But is it really true that no sandboxing can be done if one is running as root? Of course not. You can do sandboxing even when running as root, as @fatdoguser has shown again and again in his numerous posts about dropping the capability and running as "restricted root".
But perception matters. It's the same thing like forcing everybody to use HTTPS, because it makes things "oh more secure" (hint: it doesn't). Rather than giving (perhaps slightly limited) sandbox protection when running as root, they disable the feature all together and claim that running as root is unsafe.