arturobernalg opened a new pull request, #3591:
URL: https://github.com/apache/maven-surefire/pull/3591

   ConsoleOutputCapture hijacks System.out/System.err in the forked test JVM, 
so any code in that process - including the test's own, possibly 
less-privileged code - can end up inside TempFileManager.createTempFile() 
merely by calling System.out.println(). Under a SecurityManager, a stack-based 
permission check requires every frame on the call stack to hold the needed 
FilePermission, so an unrelated caller with no knowledge of (or control over) 
this internal buffering can get a bare SecurityException from code it never 
knowingly invoked.
   
   Wrap the actual file I/O in AccessController.doPrivileged(), the same 
pattern already used in ForkedBooter and
   AbstractMasterProcessChannelProcessorFactory for this exact class of problem.
   
   Fixes #3126
   
   
   No automated test: I wrote one that installs a real SecurityManager, but 
this project's own test suite is run by Surefire itself, and the JUnit Platform 
launcher's own internal operations aren't privileged, so an ambient 
SecurityManager breaks the launcher before it ever gets to the test body (not 
specific to this fix). Verified instead with a standalone program outside this 
build, calling the real class with a restricted AccessControlContext: before 
the fix it throws SecurityException, after it succeeds, matching the existing 
pattern in ForkedBooter/AbstractMasterProcessChannelProcessorFactory.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [x] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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]

Reply via email to