slachiewicz opened a new issue, #3626: URL: https://github.com/apache/maven-surefire/issues/3626
Affected version: master at d7c7e359e. Two related temp-file observations, reproduced with the project's own classes in a scratch directory: - `SureFireFileManager.create` (surefire-api/src/main/java/org/apache/maven/surefire/api/util/SureFireFileManager.java:35-54) uses a fixed `surefire-<user>` directory under `java.io.tmpdir`, and `TempFileManager.createTempFile` (surefire-api/src/main/java/org/apache/maven/surefire/api/util/TempFileManager.java:140-172) builds names from a timestamp plus a monotonic counter. A bounded run created `probe-20261120220602296_1.tmp` with mode `[OWNER_READ, OWNER_WRITE, GROUP_READ, OTHERS_READ]` — no owner-only permissions are set in source. - In `createTempFile`, the `exists()` check at line 151 does not detect a dangling symlink, and `createNewFile()` at line 164 is called without using its boolean result. A bounded run with a preplanted dangling symlink at the predicted name returned that symlink path as if it were a new file (IS_SYMLINK=true); writing through the returned path created and filled the symlink target (TARGET_CONTENT=WRITTEN_BY_BUILD). Later consumers such as `Utf8RecodingDeferredFileOutputStream.java:139` reopen the returned path by name. Expected behavior: create the directory with `Files.createTempDirectory` (0700), reject a pre-existing/foreign-owned directory, use `Files.createFile` with `CREATE_NEW|NOFOLLOW_LINKS`, fail when creation fails, and reuse the opened descriptor or re-verify inode/owner before writing. Regression tests can assert the POSIX mode and that a preplanted symlink causes an error rather than a usable path. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
