I'd like to know the security implications of changing the ownership of files, and starting process by, a UID that has no mapping to a current user on the system.
Let's say there's a file /foobar, and we've changed it's UID:GID to 1010:1010 — where those IDs are not currently mapped to any existing user — and set it's permissions to 0600. Other users will not be able to perform read or write operations on the file. If the file were instead in a directory owned by an existing user, that user could write to the file. And obvioulsy if a user were created that received the UID 1010, they could also write to the file. If we say that no such user will be created, though, is this a good way to keep that file secure from other users?
The reason I'm asking is that I don't want to run my Docker containers as root, but also don't want to get into the mess of managing user remapping with subuids. I thought the answer could be to run and own things in the container as the UID of the user who owns the files on the host. This seems to work just fine, and the non-existant container user (with the UID of the existing host user) is able to write to those files.
Though I feel there's some important security aspect I'm missing.