Skip to content

TEZ-4753: ShuffleHandler: input handling improvements - #536

Open
abstractdog wants to merge 1 commit into
apache:masterfrom
abstractdog:TEZ-4753
Open

abstractdog wants to merge 1 commit into
apache:masterfrom
abstractdog:TEZ-4753

Conversation

@abstractdog

Copy link
Copy Markdown
Contributor

Tighten validation of the dag, vertex and map query parameters in the shuffle handler so unexpected shapes are rejected up front rather than carried into filesystem path construction. Adds a regression test.

@abstractdog
abstractdog requested a lite review from Copilot September 18, 2026 12:32
@tez-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 3m 13s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+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.
_ master Compile Tests _
+1 💚 mvninstall 3m 18s master passed
+1 💚 compile 2m 45s master passed
+1 💚 checkstyle 0m 20s master passed
+1 💚 javadoc 0m 14s master passed
+0 🆗 spotbugs 0m 34s tez-plugins/tez-aux-services in master has 5 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚 mvninstall 2m 23s the patch passed
+1 💚 codespell 0m 52s No new issues.
+1 💚 compile 2m 47s the patch passed
+1 💚 javac 2m 47s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 0m 15s /results-checkstyle-tez-plugins_tez-aux-services.txt tez-plugins/tez-aux-services: The patch generated 1 new + 78 unchanged - 0 fixed = 79 total (was 78)
+1 💚 javadoc 0m 14s the patch passed
+1 💚 spotbugs 0m 43s the patch passed
_ Other Tests _
+1 💚 unit 60m 57s root in the patch passed.
+1 💚 asflicense 0m 22s The patch does not generate ASF License warnings.
80m 2s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-536/1/artifact/out/Dockerfile
Optional Tests dupname compile unit asflicense javac javadoc spotbugs checkstyle codespell detsecrets
uname Linux c2eaded8c330 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality tez-personality.sh
git revision master / 0e9f756
Default Java Eclipse Adoptium-21.0.12+8-LTS
Test Results https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-536/1/testReport/
Max. process+thread count 1503 (vs. ulimit of 5500)
modules C: tez-plugins/tez-aux-services U: tez-plugins/tez-aux-services
Console output https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-536/1/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.3 codespell=2.4.1
Powered by Apache Yetus 0.15.1 https://yetus.apache.org

This message was automatically generated.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Query-parameter “shape” validation is still incomplete (multiple dag/vertex values) and the new test should use a consistent valid job id to avoid false-positive coverage.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR strengthens ShuffleHandler HTTP query parameter validation to block path-traversal vectors (dag/vertex/map) before any filesystem path construction or delete/read operations occur, and adds a regression test to cover traversal attempts.

Changes:

  • Added strict regex validation for dag, vertex, and map/attempt identifiers to prevent traversal components from reaching path concatenation logic.
  • Added early request rejection (400) for malformed structural parameters.
  • Added a regression test that issues delete/read requests with traversing values and asserts they are rejected and do not delete out-of-scope files.
File summaries
File Description
tez-plugins/tez-aux-services/src/main/java/org/apache/tez/auxservices/ShuffleHandler.java Adds parameter pattern validation to prevent path traversal via shuffle query parameters and attempt-id handling.
tez-plugins/tez-aux-services/src/test/java/org/apache/tez/auxservices/TestShuffleHandler.java Adds a regression test covering traversal attempts in dag, vertex, and map query parameters.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1208 to +1221
if (dagIdQ != null && !dagIdQ.isEmpty()) {
String dagId = dagIdQ.get(0);
if (dagId == null || !DAG_ID_PATTERN.matcher(dagId).matches()) {
sendError(ctx, "Bad dag parameter", BAD_REQUEST);
return false;
}
}
if (vertexIdQ != null && !vertexIdQ.isEmpty()) {
String vertexId = vertexIdQ.get(0);
if (vertexId == null || !VERTEX_ID_PATTERN.matcher(vertexId).matches()) {
sendError(ctx, "Bad vertex parameter", BAD_REQUEST);
return false;
}
}

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.

ack

Comment on lines +1912 to +1913
conn = (HttpURLConnection) URI.create(
base + "/mapOutput?job=job_12345_1&dag=1&reduce=1&map="

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.

ack

Comment on lines +1205 to +1207
private boolean validateShufflePathParams(ChannelHandlerContext ctx,
List<String> dagIdQ, List<String> vertexIdQ, List<String> mapIds,
boolean isDeleteRequest) {

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.

ack

Tighten validation of the dag, vertex and map query parameters in the
shuffle handler so unexpected shapes are rejected up front rather than
carried into filesystem path construction. Also reject requests where
dag or vertex is present more than once, since downstream code only
reads the first occurrence and a permissive validator would let a
submitter pair a benign first value with a hostile second one. Adds
regression tests.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@tez-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 8s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+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.
_ master Compile Tests _
+1 💚 mvninstall 3m 7s master passed
+1 💚 compile 2m 30s master passed
+1 💚 checkstyle 0m 21s master passed
+1 💚 javadoc 0m 19s master passed
+0 🆗 spotbugs 0m 34s tez-plugins/tez-aux-services in master has 5 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚 mvninstall 2m 14s the patch passed
+1 💚 codespell 0m 50s No new issues.
+1 💚 compile 2m 27s the patch passed
+1 💚 javac 2m 27s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 0m 18s /results-checkstyle-tez-plugins_tez-aux-services.txt tez-plugins/tez-aux-services: The patch generated 1 new + 78 unchanged - 0 fixed = 79 total (was 78)
+1 💚 javadoc 0m 19s the patch passed
+1 💚 spotbugs 0m 38s the patch passed
_ Other Tests _
+1 💚 unit 60m 30s root in the patch passed.
+1 💚 asflicense 0m 19s The patch does not generate ASF License warnings.
75m 39s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-536/2/artifact/out/Dockerfile
Optional Tests dupname compile unit asflicense javac javadoc spotbugs checkstyle codespell detsecrets
uname Linux c6cf5f0a2556 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality tez-personality.sh
git revision master / 0e9f756
Default Java Eclipse Adoptium-21.0.12+8-LTS
Test Results https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-536/2/testReport/
Max. process+thread count 1447 (vs. ulimit of 5500)
modules C: tez-plugins/tez-aux-services U: tez-plugins/tez-aux-services
Console output https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-536/2/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.3 codespell=2.4.1
Powered by Apache Yetus 0.15.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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants