Repository navigation
Do not create world readable temp files for response content - #1205
Merged
Merged
Conversation
Member
|
@Vidya-m78 what do you think about moving the createReportFolder() functionality to FileUtils - having a helper here that createsUser only folders? |
rbri
force-pushed
the
master
branch
4 times, most recently
from
November 22, 2026 10:29
93e8d89 to
893439d
Compare
Contributor
Author
|
Makes sense, that's the better home for it. Moved it to org.htmlunit.util.FileUtils as createUserOnlyDirectories(Path), so DebuggingWebConnection just calls the helper now (fully qualified there because the class already imports the commons-io FileUtils). Also covered it in FileUtilsTest, including the parent directories. The temp file side stays as is, Files.createTempFile() already restricts the file to the owner, so there is nothing to wrap there. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



HttpWebConnection.downloadContent() stores a response that exceeds WebClientOptions.getMaxInMemory() (500 KiB by default) in the temp directory, and File.createTempFile() creates that file with the permissions of the umask, rw-r--r-- on Posix systems, so every other user of the machine can read the cached page, download or API response for as long as the WebResponse is alive. DebuggingWebConnection has the same exposure for its report folder in the temp directory, which also holds the POST parameters of the recorded requests. Files.createTempFile() restricts a new file to the owner; without the change the two new tests fail with 'expected: but was: ' and 'expected: but was: '.