I am writing a server that will accept untrusted Dynamic Library Modules (DLL,SO/DSO) loaded at runtime using Boost.DLL.
I would like to run the untrusted module in a separate process that only has access to the relevant shared memory (sometimes read only) and interprocess queues.
Boost does allow for a permissions object to be associated with the shared memory.
It seems like there might be a way to create a process on windows and Linux and then adjust the permissions.
How can a process be created that
- has no permissions to start with (e.g. using AdjustTokenPrivileges on windows perhaps?), but
- is then granted read access to shared memory mapped file (e.g. by setting permissions when constructing the shared memory segment?)
Or perhaps this is inherently too risky?
First, from the docs:
Beware, if you do so, then you immediately have to know about platform specific required permissiong:
¹ when not passing the permissions object
Your other question:
AdjustTokenPrivileges
on windows perhaps?), butNo. The
permissions
object does not give permissions to the invoking process. Thepermissions
object restricts access for other processes. I wager that as such, it only makes sense to specifypermissions
oncreate_only
oropen_or_create
.What I imagine is the usual route on Windows/Linux:
I wager that Windows will allow more fine-grained control due to its Access Control Lists (not tested this): they should allow you to specify additional/different accounts that have access.
On linux, it is highly likely that to achieve such control, additional system calls are necessary (e.g. to change the owner/group of the shared object and/or add such a group the client user account as primary/secondary group).
Summarizing: _I would focus on granting access to a specific recipient, instead of "starting a recipient without any permissions". The latter is impractical (processes might not even function "without any permissions") and elevating privileges during runtime is a lot more difficult than using statically assigned/administered permissions. Not to mention it's inherently less secure to add permissions on the fly.