From 9673efeafcb0db1b01903189cfb844ee9f6a5c8e Mon Sep 17 00:00:00 2001 From: "Charles S. Givre" Date: Fri, 2 Oct 2026 14:31:45 -0400 Subject: [PATCH] Potential fix for code scanning alert no. 43: Server-side request forgery Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .../java/org/apache/drill/exec/server/rest/DrillRoot.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java index ae99fa4687d..8c15283235c 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java @@ -154,6 +154,11 @@ public Response shutdownDrillbit() throws Exception { @Operation(externalDocs = @ExternalDocumentation(description = "Apache Drill REST API documentation:", url = "https://drill.apache.org/docs/stopping-drill/")) public String shutdownDrillbitByName(@PathParam("hostname") String hostname) throws Exception { + if (Strings.isNullOrEmpty(hostname) || work.getContext().getAvailableBits().stream() + .noneMatch(db -> db.getAddress().equals(hostname))) { + throw new IllegalArgumentException("Invalid drillbit hostname: " + hostname); + } + URL shutdownURL = WebUtils.getDrillbitURL(work, request, hostname, "/gracefulShutdown"); return WebUtils.doHTTPRequest(new HttpPost(shutdownURL.toURI()), work.getContext().getConfig()); }