Skip to content

Make --bind-data files have permissions 0666 - #265

Closed
alexlarsson wants to merge 1 commit into
containers:masterfrom
alexlarsson:bind-permissions
Closed

alexlarsson wants to merge 1 commit into
containers:masterfrom
alexlarsson:bind-permissions

Conversation

@alexlarsson

Copy link
Copy Markdown
Collaborator

When you use --bind-data or --ro-bind-data the file currently ends up with
permission 0600, as this is the mkstemp() default. All other codepaths in
bubblewrap creates 0666 files so that other users can read the files,
which is more common than top-secret files only readable by the user.

We fix this by fchmod()ing to 0666

When you use --bind-data or --ro-bind-data the file currently ends up with
permission 0600, as this is the mkstemp() default. All other codepaths in
bubblewrap creates 0666 files so that other users can read the files,
which is more common than top-secret files only readable by the user.

We fix this by fchmod()ing to 0666
@cgwalters

Copy link
Copy Markdown
Collaborator

I've wanted the ability to make files executable with the --file command for e.g. injecting shell scripts.

And I have a concern that someone was relying on the permissions being tighter. It's probably unlikely because to have permissions matter you really need multiple uids, which we don't emphasize much with bwrap today.

How about something like:

--perms 0644 --bind-data ... and --perms 0755 --fd ... ? The --perms would apply to the next argument.

@alexlarsson

Copy link
Copy Markdown
Collaborator Author

I like the --perms approach. Would it apply to the next argument only though, or set some default?

@cgwalters

Copy link
Copy Markdown
Collaborator

I think next arg only.

@smcv

smcv commented May 16, 2018

Copy link
Copy Markdown
Collaborator

I'd prefer to have secure defaults, and make the caller open up "wider" permissions if that's what they want.

All other codepaths in bubblewrap creates 0666 files so that other users can read the files

Do we really want other users (on the host system) to be able to write files?! That seems like a trap: if other users can write a file, then we can't trust the integrity of its contents.

@smcv

smcv commented Jun 6, 2018

Copy link
Copy Markdown
Collaborator

All other codepaths in bubblewrap creates 0666 files so that other users can read the files

All of those code paths hopefully respect umask, resulting in permissions more like 06[64][40] depending on the system's security model; but fchmod doesn't apply the mask. I think it's important to distinguish between maximum permissions that will be masked according to the umask, and exact permissions that will be applied as-is.

Do we really want other users (on the host system) to be able to write files?!

I'm fairly sure the answer is: no, unless the umask says yes.

@smcv
smcv self-requested a review June 6, 2018 18:22

@smcv smcv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't safe unless it's either explicitly requested, or takes into account the umask with which bubblewrap was invoked.

It might also be a good idea to set the umask to 077 during startup, and set it back to its original value after we drop privileges - that would go well with the fact that we have to change the umask in order to read it.

@smcv

smcv commented Feb 16, 2021

Copy link
Copy Markdown
Collaborator

How about something like:

--perms 0644 --bind-data ... and --perms 0755 --fd ... ? The --perms would apply to the next argument.

Implemented in #406 with the syntax you suggest.

I also added --chmod, because I think it's least surprising if --perms doesn't affect --dir if the directory already existed.

I'd prefer to have secure defaults, and make the caller open up "wider" permissions if that's what they want.

I'd still prefer this, but it would be a behaviour change for --dir, --tmpfs and --file (--bind-data and --ro-bind-data are OK) so I've kept the current behaviour as defaults.

@smcv

smcv commented Jun 10, 2021

Copy link
Copy Markdown
Collaborator

I think #406 is going to be a better route to make this possible.

@smcv smcv closed this Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants