<div dir="auto">The reality is that privsep was always going to be a process. It's taken more than 80 patches to get close to removing rootwrap.<div dir="auto"><br></div><div dir="auto">There are other advantages to removing rootwrap, mainly around performance, the integration of library code, and general non-bonkersness (cat to tee to write to a file as root), etc.</div><div dir="auto"><br></div><div dir="auto">There is president in the code to mark calls as undesirable, and others could be marked like that as well, but ultimately someone needs to do an audit and fix things... That's more than one person can reasonably do.</div><div dir="auto"><br></div><div dir="auto">So, who wants to help try and improve this? Patches welcome.</div><div dir="auto"><br></div><div dir="auto">Michael</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri., 29 Mar. 2019, 10:26 pm Matthew Booth, <<a href="mailto:mbooth@redhat.com">mbooth@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Privsep is intended to provide some security in depth. The idea is<br>
based on the principal of least privilege. We assume that an attacker<br>
has exploited some bug in Nova and is able to execute arbitrary code.<br>
If privsep is doing its job, the attacker should at least not be able<br>
to perform any privileged operations which Nova does not normally<br>
perform.<br>
<br>
For developers, from the spec[1]:<br>
<br>
"The intention is to allow slightly more code into the privileged<br>
portion - enough that we now have sufficient “context” to make better<br>
security decisions. For example move from “run chown” to “take<br>
ownership of VM output file”."<br>
<br>
Unfortunately, I suspect out of expediency in the initial forklift<br>
from rootwrap, we've lost this critical principal of moving<br>
security-critical logic into privsep itself. Consequently, a brief and<br>
non-exhaustive audit reveals we have privsep functions to do the<br>
following:<br>
<br>
fs.py:<br>
<br>
* mount anything of any type, including remote storage, anywhere.<br>
* unmount anything<br>
* shred any file or block device, without restriction<br>
<br>
path.py:<br>
<br>
* read any file or block device, without restriction<br>
* overwrite any existing file or block device<br>
<br>
utils.py:<br>
<br>
* send any signal to any process<br>
<br>
Just the existence of these methods in nova's privsep module<br>
essentially gives the unprivileged nova process unfettered root<br>
access, which entirely defeats the purpose of privsep. As it stands<br>
today, privsep gives us literally nothing. I suspect that it's worse<br>
than rootwrap, in fact. If privsep protection is something we want, we<br>
need to do 2 things:<br>
<br>
1. Immediately stop adding or using generic privsep functions.<br>
2. Audit privsep properly for problematic methods, and remove them.<br>
<br>
For example, in libvirt.driver.get_console_output() we do<br>
nova.privsep.path.writefile(console_log, 'a+', data). Instead, we<br>
should have, eg,<br>
nova.privsep.libvirt.ensure_console_log_for_instance(instance). This<br>
would determine the instance path from its own secure config (see [1]<br>
again), and touch that file.<br>
<br>
We should probably also compile a list of privsep anti-patterns if<br>
there isn't one already to make life simpler for reviewers. For<br>
example, I suggest that no privsep function should take as an argument<br>
a path, or any other reference to a system resource; it should<br>
determine these itself.<br>
<br>
I view this as essentially a continuation of the privsep forklift. As<br>
with all such large mechanical changes I expect this to be disruptive<br>
and unloved by reviewers. Is it something we'd be prepared to<br>
prioritise?<br>
<br>
Matt<br>
<br>
[1] <a href="https://specs.openstack.org/openstack/oslo-specs/specs/liberty/privsep.html" rel="noreferrer noreferrer" target="_blank">https://specs.openstack.org/openstack/oslo-specs/specs/liberty/privsep.html</a><br>
--<br>
Matthew Booth<br>
Red Hat OpenStack Engineer, Compute DFG<br>
<br>
Phone: +442070094448 (UK)<br>
<br>
</blockquote></div>