Messages in this thread | | | Date | Mon, 23 Jan 2023 18:14:03 -0500 | From | "Colin Walters" <> | Subject | Re: [PATCH v3 1/2] exec: add PR_HIDE_SELF_EXE prctl |
| |
On Mon, Jan 23, 2023, at 5:54 PM, Giuseppe Scrivano wrote: > > I realize it seems like a one-off fix, but it is done only for backward > compatibility. > > Other paths under /proc/self/map_files require CAP_SYS_ADMIN in the > initial user namespace, or have CAP_CHECKPOINT_RESTORE in the user > namespace. Sure, it is not future-proof, but it would look weird if > after CVE-2019-19814 there will be more ways to access files from the > host without requiring some capabilities.
I think a way to rephrase what I'm saying is that it feels like this should be about making /proc/self/exe and /proc/self/map_files consistent.
> With the prctl a runtime would just need to do the following and live > happily ever after: > > __attribute__ ((constructor)) static void hide_self_exe (void) > { > if (prctl(PR_SET_HIDE_SELF_EXE, 1, 0, 0, 0) == 0) > return; > > /* ...reexec as we do today... */ > } > > and we won't have to worry about what mount options are supported or > used by proc.
Yeah, OK - having the logical operation be on the process and not the view into it (procfs) definitely is more robust.
But how about calling this PR_SET_PROCFS_RESTRICTED or so, and then *also* changing the /proc/self/map_files lookup to deny if this is set? Yes, it'd be mostly redundant, but it'd help clarify things for any future changes since it'd be clear that the logic *should* be consistent for /proc/self/exe and /proc/self/map_files. And actually as a bonus, it would make the case of e.g. `podman run --cap-add=checkpoint_restore` secure right? (Though honestly I don't know how common that is or whether one can practically use checkpoint_restore without other caps)
| |