Skip to content

Make FileBackedOutputStream even more resilient to broken temp-directory permissions than java.nio.file.Files.createTempFile is. - #8748

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_993772458
Open

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_993772458

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Make FileBackedOutputStream even more resilient to broken temp-directory permissions than java.nio.file.Files.createTempFile is.

If java.io.tmpdir is world-writable and does not set the very important sticky bit, then an attacker has a chance to unlink the temp file and replace it with a symlink between when it is created and when it is opened. This could cause the user of the stream to write/read data to/from an unintended location.

It's not clear that it's worth defending against this, given that the problem arises only with broken temp-directory permissions, which are much more likely to open holes elsewhere than here. But given the rise of security scanning over time, I'm figuring that it's worth addressing even some borderline reports (like this one from our internal scans) when it appears straightfoward and safe enough to do so.

RELNOTES=n/a

…ctory permissions than `java.nio.file.Files.createTempFile` is.

_If_ `java.io.tmpdir` is world-writable and does not set the very important sticky bit, then an attacker has a chance to unlink the temp file and replace it with a symlink between when it is created and when it is opened. This could cause the user of the stream to write/read data to/from an unintended location.

It's not clear that it's worth defending against this, given that the problem arises only with broken temp-directory permissions, which are much more likely to open holes elsewhere than here. But given the rise of security scanning over time, I'm figuring that it's worth addressing even _some_ borderline reports (like this one from our internal scans) when it appears straightfoward and safe enough to do so.

RELNOTES=n/a
PiperOrigin-RevId: 993772458

This branch has not been deployed

No deployments
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.

1 participant