Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set stricter directory permissions #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vu3rdd
Copy link
Contributor

@vu3rdd vu3rdd commented Aug 22, 2022

Directory transfer of the transit protocol use the zip format internally to transfer a bunch of files/directories from the sender to the recipient. The recipient, creates the destination directory and unzips the zip file to recreate the directory that was sent by the sender. This process is transparent to the user.

This PR address two issues:

  1. wormhole-william is using 0777 for directory permissions at the creation time. This seems excessive. I believe, this was discussed in the past, but I can't find the right issue at the moment. We set it to a stricter 0700.
  2. For a wormhole-william to wormhole-william transfer on Un*x based systems (macOS, GNU/Linux), the file permissions on the sender side are restored at the recipient side as well. Sender is already sending the permission bits in the attributes field of the zip file entry. These bits are restored upon receive.

@psanford
Copy link
Owner

We've had some discussion about file permission bits in the past here: #33 (comment).

The current code sets the permission to 0777 so that we respect the user's umask. This allows users to set their permissions to be as restrictive or permissive as they are comfortable with. We likewise do the same thing implicitly with the creation of files in those directories.

I believe this matches the behavior of the python magic-wormhole implementation.

Copy link
Contributor

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

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

I think this is a good idea, albeit with slightly higher permission bits set. Even if umask decreases the permissions, we would still be (at least from the example in the other PR mentioned) getting higher permissions than what probably is necessary.

@@ -215,7 +215,7 @@ func recvAction(cmd *cobra.Command, args []string) {
}

dir := filepath.Dir(p)
err = os.MkdirAll(dir, 0777)
err = os.MkdirAll(dir, 0700)
Copy link
Contributor

Choose a reason for hiding this comment

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

Gosec suggests 0750 as that means read/write/execute for user and read/execute for group and no permissions for other. I think that might make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for choosing 0700 was that since this is a program that is a very privacy oriented file transfer program, it would be prudent choose a more "paranoid" default. For instance, if a recipient got very sensitive files and didn't want another user to access it. As a program, we guarantee such a behaviour instead of relying on the operating system.

Copy link
Contributor

@Jacalz Jacalz Aug 26, 2022

Choose a reason for hiding this comment

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

I know but I think 0700 is too strict given that it doesn't include group permissions. Using 0750 will be almost just as good but without potential permission issues.

@vu3rdd
Copy link
Contributor Author

vu3rdd commented Aug 26, 2022

The current code sets the permission to 0777 so that we respect the user's umask. This allows users to set their permissions to be as restrictive or permissive as they are comfortable with. We likewise do the same thing implicitly with the creation of files in those directories.

The reason for choosing 0700 is to have a more paranoid approach to privacy. I understand the idea of respecting user's umask. Since umask only makes the given permissions stricter, in my humble opinion, choosing a more secure default would not do any harm.

@Jacalz
Copy link
Contributor

Jacalz commented Dec 28, 2022

The current code sets the permission to 0777 so that we respect the user's umask. This allows users to set their permissions to be as restrictive or permissive as they are comfortable with. We likewise do the same thing implicitly with the creation of files in those directories.

The reason for choosing 0700 is to have a more paranoid approach to privacy. I understand the idea of respecting user's umask. Since umask only makes the given permissions stricter, in my humble opinion, choosing a more secure default would not do any harm.

It is better to have a sane default than an overly paranoid setting that might cause issues for users. I still think it would be a good middle ground to select 0750 and let umask handle stricter permissions for those that want stricter permissions. This should avoid causing issues for users while still improving the permission security.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants