Skip to content

HADOOP-19864 Followup: rejection of unregistered protocols.#8470

Open
steveloughran wants to merge 1 commit intoapache:trunkfrom
steveloughran:pr/HADOOP-19864-RpcKind
Open

HADOOP-19864 Followup: rejection of unregistered protocols.#8470
steveloughran wants to merge 1 commit intoapache:trunkfrom
steveloughran:pr/HADOOP-19864-RpcKind

Conversation

@steveloughran
Copy link
Copy Markdown
Contributor

Followup to #8433.

Server will immediately reject any protocols for which no handler is registered.

How was this patch tested?

new test case

For code changes:

  • Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: have the integration tests been executed and the endpoint declared according to the connector-specific documentation?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files?

AI Tooling

If an AI tool was used:

Server will immediately reject any protocols for which no
handler is registered.

Contains content written by github copilot
@steveloughran steveloughran requested a review from Copilot May 5, 2026 19:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR hardens the IPC/RPC server by rejecting RPC kinds that do not have any protocols registered on the server, aiming to avoid deserializing untrusted request payloads for unsupported kinds.

Changes:

  • Add an early rejection path in Server.processRpcRequest() when a RPC.Server has no registered protocols for the request RpcKind.
  • Introduce RPC.Server#hasRegisteredProtocols(RpcKind) to detect whether a kind is supported on a given server instance.
  • Add a new unit test intended to validate the “unregistered kind” behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java Adds pre-deserialization rejection for RPC kinds without registered protocols; adjusts logging/error strings.
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java Adds hasRegisteredProtocols helper to support the early-rejection check.
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java Adds a test case intended to cover rejection of unregistered RPC kinds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2119 to +2142
/**
* Test that a Protobuf-only RPC server rejects requests for RpcKinds
* that have no registered protocols, without deserializing the payload.
*/
@Test
@Timeout(value = 30)
public void testUnregisteredRpcKindRejectedWithoutDeserialization()
throws Exception {
// Standard test server: only RPC_PROTOCOL_BUFFER protocols are registered.
RPC.Server server = setupTestServer(conf, 1);
try {
// RPC_PROTOCOL_BUFFER has registered protocols — must be accepted.
assertThat(server.hasRegisteredProtocols(RPC.RpcKind.RPC_PROTOCOL_BUFFER))
.as("RPC_PROTOCOL_BUFFER should have registered protocols")
.isTrue();

// RPC_BUILTIN has no protocols registered on this server — must be rejected.
assertThat(server.hasRegisteredProtocols(RPC.RpcKind.RPC_BUILTIN))
.as("RPC_BUILTIN should have no registered protocols on a Protobuf-only server")
.isFalse();
} finally {
server.stop();
}
}
final String err = "No protocols registered on this server for RpcKind "
+ header.getRpcKind()
+ ". Rejecting request without deserialization.";
LOG.info("{} Client: {}", err, getHostAddress());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rejected as upgrading to warn is even noisier. We could go to LogExactlyOnce

this.protocolName + " for rpcKind " + header.getRpcKind(), t);
String err = "IPC server unable to read call parameters: "+ t.getMessage();
LOG.warn(
"Unable to read call parameters for client {}on connection protocol {} for rpcKind {}",
throw new FatalRpcServerException(
RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER, err);
RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
"Unknown rpc kind in rpc header" + header.getRpcKind());
Copy link
Copy Markdown
Contributor

@cnauroth cnauroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, pending pre-commits

@hadoop-yetus
Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 25s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 26m 45s trunk passed
+1 💚 compile 8m 29s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 8m 48s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 0m 54s trunk passed
+1 💚 mvnsite 1m 13s trunk passed
+1 💚 javadoc 0m 52s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 53s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 1m 47s trunk passed
+1 💚 shadedclient 17m 5s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 41s the patch passed
+1 💚 compile 8m 1s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 8m 1s the patch passed
+1 💚 compile 8m 48s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 8m 48s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 0m 52s /results-checkstyle-hadoop-common-project_hadoop-common.txt hadoop-common-project/hadoop-common: The patch generated 1 new + 333 unchanged - 1 fixed = 334 total (was 334)
+1 💚 mvnsite 1m 6s the patch passed
+1 💚 javadoc 0m 53s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 55s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 1m 55s the patch passed
+1 💚 shadedclient 17m 9s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 18m 33s hadoop-common in the patch passed.
+1 💚 asflicense 0m 47s The patch does not generate ASF License warnings.
127m 55s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8470/1/artifact/out/Dockerfile
GITHUB PR #8470
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux b70b76f16e2d 5.15.0-171-generic #181-Ubuntu SMP Fri Feb 6 22:44:50 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 0da8844
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8470/1/testReport/
Max. process+thread count 3153 (vs. ulimit of 10000)
modules C: hadoop-common-project/hadoop-common U: hadoop-common-project/hadoop-common
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8470/1/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants