Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update unix-tmp.md
  • Loading branch information
agocke authored Jun 10, 2022
commit d8555f266ecc1a178ccd5932d4d58d3a1b380ada
8 changes: 4 additions & 4 deletions docs/design/security/unix-tmp.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

# Unix temporary files
Copy link
Member

Choose a reason for hiding this comment

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

Would it be reasonable to expand the scope a little to cover "Unix file and directory permissions" in general? Whereever we write a file, we should set minimum permissions on it. And we would have the same guidance that there should be no perms for group and world unless they are required.

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a Mac to experiment with. Does anything in here differ for Mac? It seems that Macs support ACLs as well, and in some circumstances they are used in Linux as well. Should we include guidance for those? (@tmds)

Copy link
Member

Choose a reason for hiding this comment

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

My expectation is that mac will be similar to Linux: /tmp has the sticky bit, and a umask of at least 002.
I'm not a mac user either. Someone should verify this.

Copy link
Member

Choose a reason for hiding this comment

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

Are ACL's relevant to many Linux users, enough that (in theory) we should set them if available? Or are they mainly for special purposes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mac has its own restrictions, and doesn't necessarily have a shared temp directory. Just in case, the above should probably be followed, but it may not be necessary, depending on the configuration.


The Unix support for temporary files is different from the Windows model and developers who
are used to Windows may inadvertantly create security risk if they use the same practices on Unix.
The Unix support for temporary files is different from the Windows model and developers who
Copy link
Member

Choose a reason for hiding this comment

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

This should explicitly state that the guidance applies to not just files but anything file-like. The .NET diagnostics tools use FIFO/sockets in temp IIRC.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unix domain sockets have different restrictions, and don't necessarily follow this guidance.

are used to Windows may inadvertantly create security risk if they use the same practices on Unix.

Most notably, the Windows model for temporary files is that the operating system provides each user with a *unique*, *user-owned* temporary directory.
Most notably, the Windows model for temporary files is that the operating system provides each user with a *unique*, *user-owned* temporary directory.
Moreover, all Windows users, including the service and system users, have designated user folders, including temporary folders.

The Unix model is very different. The temp directory, assuming there is one, is often a global folder (except on MacOS).
Expand Down Expand Up @@ -42,4 +42,4 @@ multiple processes. Some considerations:

- There is no automatic cleanup in user folders. Files will remain permanently or require cleanup by the app
- Some environments do not have user home folders (e.g., systemd). Consider providing an environment variable
Copy link
Member

Choose a reason for hiding this comment

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

systemd has a PrivateTmp feature.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe also worth mentioning:
XDG defines XDG_RUNTIME_DIR which is a user-private tmpfs to store runtime files. See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html.

Copy link
Member

Choose a reason for hiding this comment

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

Some interesting requirements there, including that files not survive reboot. It might be worth specifying here that we should not expect our temp files to survive reboot, but we should not expect them to be cleaned up by reboot either.

to override the location of the temporary folder, and provide user documentation for this variable.
to override the location of the temporary folder, and provide user documentation for this variable.