Skip to content
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

BanJNDI errorprone error in JndiResourceResolverFactory with rules_java v5.4.1 #9916

Closed
satreix opened this issue Feb 25, 2023 · 1 comment · Fixed by #9886
Closed

BanJNDI errorprone error in JndiResourceResolverFactory with rules_java v5.4.1 #9916

satreix opened this issue Feb 25, 2023 · 1 comment · Fixed by #9886
Milestone

Comments

@satreix
Copy link

satreix commented Feb 25, 2023

What version of gRPC-Java are you using?

1.53.0

What is your environment?

macOS 13.0.1, openjdk 17, bazel 6.0.0, rules_java v5.4.1

What did you expect to see?

No errors.

What did you see instead?

ERROR: external/io_grpc_grpc_java/core/BUILD.bazel:24:13: Building external/io_grpc_grpc_java/core/libinternal-class.jar (117 source files) failed: (Exit 1): java failed: error executing command (from target @io_grpc_grpc_java//core:internal) external/remotejdk17_macos/bin/java '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 17 arguments skipped)
external/io_grpc_grpc_java/core/src/main/java/io/grpc/internal/JndiResourceResolverFactory.java:216: error: [BanJNDI] Using JNDI may deserialize user input via the `Serializable` API which is extremely dangerous
        javax.naming.directory.Attributes attrs = dirContext.getAttributes(name, rrType);
                                                                          ^
    (see https://errorprone.info/bugpattern/BanJNDI)

Steps to reproduce the bug

Setup bazel to use grpc-java 1.53.0 with openjdk 17, bazel 6.0.0, rules_java v5.4.1. You will get the error. A repro exist in satreix/everest#406

This error does not appear with rules_java 5.4.0.

@ejona86
Copy link
Member

ejona86 commented Feb 28, 2023

We need to suppress warnings there. The specific usage is safe because we construct the value to lookup, and restrict it to DNS. #9886 would address this.

Your easiest option for short-term is probably use the patches attribute available on http_archive and git_repository to apply a patch like:

diff --git a/core/src/main/java/io/grpc/internal/JndiResourceResolverFactory.java b/core/src/main/java/io/grpc/internal/JndiResourceResolverFactory.java
index 22e08de9c..0710bd8f9 100644
--- a/core/src/main/java/io/grpc/internal/JndiResourceResolverFactory.java
+++ b/core/src/main/java/io/grpc/internal/JndiResourceResolverFactory.java
@@ -195,7 +195,7 @@ final class JndiResourceResolverFactory implements DnsNameResolver.ResourceResol
   @VisibleForTesting
   @IgnoreJRERequirement
   // Hashtable is required. https://github.com/google/error-prone/issues/1766
-  @SuppressWarnings("JdkObsolete")
+  @SuppressWarnings({"JdkObsolete", "BanJNDI"})
   // javax.naming.* is only loaded reflectively and is never loaded for Android
   // The lint issue id is supposed to be "InvalidPackage" but it doesn't work, don't know why.
   // Use "all" as the lint issue id to suppress all types of lint error.

benjaminp added a commit to benjaminp/grpc-java that referenced this issue Feb 28, 2023
errorprone cannot be updated past 2.10 because later versions do not support Java 8.

Fixes grpc#9916.
benjaminp added a commit to benjaminp/grpc-java that referenced this issue Feb 28, 2023
errorprone cannot be updated past 2.10 because later versions do not support Java 8.

Fixes grpc#9916.
benjaminp added a commit to benjaminp/grpc-java that referenced this issue Mar 1, 2023
errorprone cannot be updated past 2.10 because later versions do not support Java 8.

Fixes grpc#9916.
temawi pushed a commit that referenced this issue Mar 1, 2023
errorprone cannot be updated past 2.10 because later versions do not support Java 8.

Fixes #9916.
@ejona86 ejona86 added this to the 1.54 milestone Mar 2, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants