-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Unix: Don't create world-writable files when safe save is enabled #96399
Conversation
Makes sense to me. I also see another Error FileAccessUnixPipe::open_internal(const String &p_path, int p_mode_flags) {
...
if (mkfifo(path.utf8().get_data(), 0666) != 0) { |
I think this should be 0600 to make sure only the current user can read from or write to the pipe. I'm not too familiar with how pipes are used in Godot but I suspect there wouldn't be (shouldn't be) multiple users involved in communication over them. |
When the "filesystem/on_save/safe_save_on_backup_then_rename" option is enabled files are created with 0666 permissions (-rw-rw-rw-) which is too loose. Use 0644 (-rw-r--r--) instead which is how the files would normally be created with the setting disabled and the system umask taken into account.
Named pipes created using the "pipe://" file access scheme should not be world-writable or readable. Limit their access to the current user by creating them with 0600 permissions instead of 0666.
I've added a commit to limit the pipe permissions too. |
(Polite nudge for reviews or merge.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change to fchmod
seems correct to me.
I'm not familiar enough with Unix pipes to assess the mkfifo
one, would be great if @bruvzg could have a look.
Are there any outstanding concerns with this PR? @bruvzg? |
Thanks! Congratulations on your first contribution! 🎉 |
When the "filesystem/on_save/safe_save_on_backup_then_rename" option is enabled, files are created with 0666 permissions (-rw-rw-rw-) which is too loose. Use 0644 (-rw-r--r--) instead which is how the files would normally be created with the setting disabled and the system umask taken into account.
Note: Originally I was going to remove the fchmod() entirely and allow mkstemp() to set the permissions based on the umask but #79866 (comment) suggests that would break web builds. However, there should be no reason for files created by godot to ever be world-writable.