OpenSearch/plugins
Jason Tedor 0a1b566c65
Fix security manager bug writing large blobs to GCS (#55421)
* Fix security manager bug writing large blobs to GCS

This commit addresses a security manager permissions issue writing large
blobs (on the resumable upload path) to GCS. The underlying issue here
is that we need to wrap the close and write calls on the channel. It is
not enough to do this:

SocketAccess.doPrivilegedVoidIOException(
  () -> Streams.copy(
    inputStream,
    Channels.newOutputStream(client().writer(blobInfo, writeOptions))));

This reason that this is not enough is because Streams#copy will be in
the stacktrace and it is not granted the security manager permissions
needed to close or write this channel. We only grant those permissions
to classes loaded in the plugin classloader, and Streams#copy is from
the parent classloader. This is why we must wrap the close and write
calls as privileged, to truncate the Streams#copy call out of the
stacktrace.

The reason that this issue is not caught in testing is because the size
of data that we use in testing is too small to trigger the large blob
resumable upload path. Therefore, we address this by adding a system
property to control the threshold, which we can then set in tests to
exercise this code path. Prior to rewriting the writeBlobResumable
method to wrap the close and write calls as privileged, with this
additional test, we are able to reproduce the security manager
permissions issue. After adding the wrapping, this test now passes.

* Fix forbidden APIs issue

* Remove leftover debugging
2020-04-17 18:49:10 -04:00
..
analysis-icu Use task avoidance with forbidden apis (#55034) 2020-04-15 13:27:53 -07:00
analysis-kuromoji Upgrade to lucene 8.5.1 release (#55229) (#55235) 2020-04-15 17:35:42 +02:00
analysis-nori Upgrade to lucene 8.5.1 release (#55229) (#55235) 2020-04-15 17:35:42 +02:00
analysis-phonetic Upgrade to lucene 8.5.1 release (#55229) (#55235) 2020-04-15 17:35:42 +02:00
analysis-smartcn Upgrade to lucene 8.5.1 release (#55229) (#55235) 2020-04-15 17:35:42 +02:00
analysis-stempel Upgrade to lucene 8.5.1 release (#55229) (#55235) 2020-04-15 17:35:42 +02:00
analysis-ukrainian Upgrade to lucene 8.5.1 release (#55229) (#55235) 2020-04-15 17:35:42 +02:00
discovery-azure-classic Refactor global build info plugin to leverage JavaInstallationRegistry (#54026) 2020-03-23 15:30:10 -07:00
discovery-ec2 [7.x] Lazy test cluster module and plugins (#54852) (#55087) 2020-04-13 10:53:35 -05:00
discovery-gce [7.x] Lazy test cluster module and plugins (#54852) (#55087) 2020-04-13 10:53:35 -05:00
examples Deprecate disabling basic-license features (#54816) (#55405) 2020-04-17 15:04:17 -04:00
ingest-attachment Remove deprecated third-party methods from tests (#55255) (#55269) 2020-04-15 17:54:47 -04:00
mapper-annotated-text [7.x] Optimize which Rest resources are used by the Rest tests… (#53766) 2020-03-19 12:28:59 -05:00
mapper-murmur3 [7.x] Comprehensively test supported/unsupported field type:agg combinations (#54451) 2020-03-31 14:35:03 -04:00
mapper-size [7.x] Optimize which Rest resources are used by the Rest tests… (#53766) 2020-03-19 12:28:59 -05:00
repository-azure Remove deprecated third-party methods from tests (#55255) (#55269) 2020-04-15 17:54:47 -04:00
repository-gcs Fix security manager bug writing large blobs to GCS (#55421) 2020-04-17 18:49:10 -04:00
repository-hdfs [7.x] Lazy test cluster module and plugins (#54852) (#55087) 2020-04-13 10:53:35 -05:00
repository-s3 Remove deprecated third-party methods from tests (#55255) (#55269) 2020-04-15 17:54:47 -04:00
store-smb [7.x] Optimize which Rest resources are used by the Rest tests… (#53766) 2020-03-19 12:28:59 -05:00
transport-nio [7.x] Re-add origin url information to publish POM files (#55173) 2020-04-14 13:24:15 -07:00
build.gradle Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00