I am embedding a third-party logging JAR (logagent.jar) into OpenSearch 3.2.0 by placing it in lib/. The JAR needs SocketPermission to connect to an external HTTPS endpoint.
I found that OpenSearch’s agent-based security (ByteBuddy instrumentation via opensearch-agent.jar) reads org/opensearch/bootstrap/security.policy embedded inside opensearch-3.2.0.jar. Since logagent.jar has no entry in that file, its ProtectionDomain is empty and all socket connections are denied with "Denied access to: <host>:443".
Standard -Djava.security.policy JVM flag is ignored. Plugin plugin-security.policy doesn’t apply to lib/ JARs. Disabling the Security Manager via JVM flags crashes OpenSearch startup.
My current fix: Extract org/opensearch/bootstrap/security.policy from opensearch-3.2.0.jar, append:
```
grant codeBase “${codebase.logagent.jar}” {
permission java.net.SocketPermission “*”, “connect,resolve”;
…
};
```
then repack the JAR. Automated in our build pipeline.
We also tried placing logagent.jar in plugins/logagent/ with a plugin-security.policy. This failed for two reasons:
(1) JarHell — if logagent.jar exists in both lib/ and plugins/, OpenSearch refuses to start due to duplicate classes.
(2) If removed from lib/ entirely, Log4j2 initializes at bootstrap (LogConfigurator.configure() in Bootstrap.init()) before plugins are loaded, so it cannot find the custom appender type and all appenders fail with Unable to locate plugin type. The JAR must be in lib/ for Log4j2, but lib/ JARs get no permissions from the plugin policy mechanism.
Question: Is there any supported/official way to extend OpenSearch’s security policy for third-party JARs in lib/ without patching the main JAR? Or is the JAR patch the only path?