Skip to content

ThrowableUtil should work without needing reflection permissions #7614

@jaymode

Description

@jaymode

Expected behavior

Netty works with a security manager without needing "java.lang.RuntimePermission" "accessDeclaredMembers". The ThrowableUtil class should be able to function without the addSuppressed method being available.

Actual behavior

In a environment with a security manager, Netty initialization fails due to the use of getDeclaredMethod in ThrowableUtil.

Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
    at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
    at java.base/java.security.AccessController.checkPermission(AccessController.java:895)
    at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:558)
    at java.base/java.lang.Class.checkMemberAccess(Class.java:2804)
    at java.base/java.lang.Class.getDeclaredMethod(Class.java:2428)
    at io.netty.util.internal.ThrowableUtil.getAddSuppressed(ThrowableUtil.java:35)
    at io.netty.util.internal.ThrowableUtil.<clinit>(ThrowableUtil.java:27)

Steps to reproduce

Run Netty with a security manager that does not grant the "accessDeclaredMembers" permission.

Reproducer

This is not minimal but see the code elastic/elasticsearch#28345. Remove the accessDeclaredMembers permission and run ./gradlew :modules:transport-netty4:check.

Netty version

4.1.18.Final in the reproducer but confirmed with 4.1.20.Final as well.

JVM version (e.g. java -version)

$ java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

OS version (e.g. uname -a)

Linux build 4.13.0-25-generic #29-Ubuntu SMP Mon Jan 8 21:14:41 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions