-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix SecurityException in repository-s3 plugin #25206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix SecurityException in repository-s3 plugin #25206
Conversation
…d SecurityException. A plugin is only allowed to use its own jars when performing privileged operations. The S3 client might open a new Socket on close(). elastic#25192
|
I haven't added NOTICE and LICENSE files for commons-io for now. I can do so, if we want to go ahead with this change. |
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
jasontedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment. Unless there's a good reason that I'm not seeing we should not add a new dependency here.
buildSrc/version.properties
Outdated
| httpasyncclient = 4.1.2 | ||
| commonslogging = 1.1.3 | ||
| commonscodec = 1.10 | ||
| commonsio = 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we need a whole new dependency for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can implement the stream copying, it's not too much code.
|
+1, we shouldn't introduce a dependency on Apache Commons IO here. I think as long as you wrap the whole try block in the Thank you @joachimdraeger |
|
@joachimdraeger Yes, that's right. Here I'm okay duplicating the code unless a broader need arises. |
|
I had a few thoughts while running tonight:
Between the two alternatives I present, I prefer option one, no need to muddy up core with a method that has one callee for one purpose. I think that a test is mandatory. Does this make sense? What do you think? |
… to avoid SecurityException. A plugin is only allowed to use its own jars when performing privileged operations. The S3 client might open a new Socket on close(). elastic#25192" This reverts commit 429f22f.
…o avoid SecurityException. A plugin is only allowed to use its own jars when performing privileged operations. The S3 client might open a new Socket on close(). elastic#25192
|
I implemented the stream copying. Great, that the try/resource construct takes care of reporting exceptions returned by close() correctly. I will have a look if it would make sense to move the doPrivileged into the DefaultS3OutputStream.flush() method. What specifically would you like to test and how @jasontedor ? |
|
@joachimdraeger This is off the cuff, I have not looked closely enough to see if I'm thinking here is feasible but maybe you can explore this? We know that |
|
Your idea with connecting to a local socket might be more feasible than I first though @jasontedor. Indeed, S3BlobStoreContainerTests exercises all the relevant code paths. Have a look at the experiment that I did and let me know what you think. |
|
@joachimdraeger I think that test is a good start, can you bring it to #25254 and we can assess it more carefully? |
|
I'm going to close this PR, I think we will favor the approach in #25254. Thanks for taking the lead on this @joachimdraeger. |
Use Apache commons IO to copy streams in repository S3 plugin to avoid SecurityException. A plugin is only allowed to use its own jars when performing privileged operations. The S3 client might open a new Socket on close(). #25192