# Customize Java security manager settings?

**URL:** <https://discuss.elastic.co/t/customize-java-security-manager-settings/72255>\
**Category:** Elasticsearch\
**Created:** [January 20, 2017, 3:52am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255 "2017-01-20T03:52:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Li\_Xu](https://avatars.discourse-cdn.com/v4/letter/l/c0e974/32.png) [@Li\_Xu](https://discuss.elastic.co/u/Li_Xu)\
**Post date:** [January 20, 2017, 3:52am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255/1 "2017-01-20T03:52:15Z")

</div>

I'l writing a plugin that calls Jackson to deserialize a json string into a Java object. I understand that in ES 5+ access is pretty much locked down. So is there a way to enable Jackson to do its thing? I'm getting this when submitting a doc:

```
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse [content.iso639]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse [content.iso639]",
    "caused_by" : {
      "type" : "access_control_exception",
      "reason" : "access denied (\"java.lang.RuntimePermission\" \"accessDeclaredMembers\")"
    }
  },
  "status" : 400
}
```

---

<div class="post-metadata">

**Author:** ![Li\_Xu](https://avatars.discourse-cdn.com/v4/letter/l/c0e974/32.png) [@Li\_Xu](https://discuss.elastic.co/u/Li_Xu)\
**Post date:** [January 20, 2017, 4:48am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255/2 "2017-01-20T04:48:28Z")

</div>

Just to clarify that I have tried to grant that in plugin's plugin-security.policy file and when installing the plugin I did see the warning, but still it doesn't seem to work ...

from bin/elasticsearch-plugin install:  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
@ WARNING: plugin requires additional permissions @  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
\* java.lang.RuntimePermission accessDeclaredMembers  
See [http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html](http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html)  
for descriptions of what these permissions allow and the associated risks.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 20, 2017, 7:10am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255/3 "2017-01-20T07:10:23Z")

</div>

In case it helps:

[https://www.elastic.co/guide/en/elasticsearch/plugins/current/plugin-authors.html#\_java\_security\_permissions](https://www.elastic.co/guide/en/elasticsearch/plugins/current/plugin-authors.html#_java_security_permissions)

---

<div class="post-metadata">

**Author:** ![Li\_Xu](https://avatars.discourse-cdn.com/v4/letter/l/c0e974/32.png) [@Li\_Xu](https://discuss.elastic.co/u/Li_Xu)\
**Post date:** [January 20, 2017, 7:22am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255/4 "2017-01-20T07:22:29Z")

</div>

I did look at that page and here's my simple policy file:

```
grant {
    permission java.lang.RuntimePermission "accessDeclaredMembers";
};

```

I used --batch argument in installing the plugin which supposedly accepts the security warning.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 20, 2017, 7:34am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255/5 "2017-01-20T07:34:18Z")

</div>

Is this file available in your final ZIP file?

Did you also then add:

```auto
// ES permission you should check before doPrivileged() blocks
import org.elasticsearch.SpecialPermission;

SecurityManager sm = System.getSecurityManager();
if (sm != null) {
  // unprivileged code such as scripts do not have SpecialPermission
  sm.checkPermission(new SpecialPermission());
}
AccessController.doPrivileged(
  // sensitive operation
);

```

In you code?

---

<div class="post-metadata">

**Author:** ![Li\_Xu](https://avatars.discourse-cdn.com/v4/letter/l/c0e974/32.png) [@Li\_Xu](https://discuss.elastic.co/u/Li_Xu)\
**Post date:** [January 20, 2017, 8:13am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255/6 "2017-01-20T08:13:03Z")

</div>

Yeah I did.

I just found my problem where I missed ReflectPermission and didn't paid close attention to the error message.

Btw, do you know how to deal with conflicting versions of jackson-core (mine is from a dependency jar which is older than ES's)? Is shading mine the only answer?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 20, 2017, 8:24am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255/7 "2017-01-20T08:24:59Z")

</div>

If you can't use the one provided by elasticsearch core as yours is really really old, then yeah, shading is the only option I can see.

My 2 cents

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 17, 2017, 8:25am UTC](https://discuss.elastic.co/t/customize-java-security-manager-settings/72255/8 "2017-02-17T08:25:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
