create temporary file in directory with secure permissions
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
#### Motivation
`File.createTempFile(String, String)` will create a temporary file in the system temporary directory if the `'java.io.tmpdir'`. The permissions on that file utilize the umask. In a majority of cases, this means that the file that java creates has the permissions: `-rw-r--r--`, thus, any other local user on that system can read the contents of that file.
This can be a security concern if any sensitive data is stored in this file.
#### Proposed changes
Create a secure temp file using `PlatformDependent.createTempFile` instead of `File.createTempFile`. The change is released in [netty-4.1.63.Final](https://github.com/netty/netty/commit/c735357bf29d07856ad171c6611a2e1a0e0000ec) and Druid is upgraded to `netty-4.1.63.Final` in [this commit](https://github.com/apache/druid/pull/11117).
#### Rationale
Create temporary files with sane permissions by default.
Contributor guide
Research direction
Start by locating Druid call sites of File.createTempFile(String, String) and compare their usage with Netty's PlatformDependent.createTempFile. Verify that the affected temporary files are created with restrictive permissions and add or update coverage for the changed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100