You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "saurabhd336 (via GitHub)" <gi...@apache.org> on 2023/07/21 07:32:29 UTC

[GitHub] [pinot] saurabhd336 commented on a diff in pull request #11132: Sanitise API inputs used as file path variables

saurabhd336 commented on code in PR #11132:
URL: https://github.com/apache/pinot/pull/11132#discussion_r1270323609


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/LLCSegmentCompletionHandlers.java:
##########
@@ -448,8 +448,13 @@ private static File extractSegmentFromFormToLocalTempFile(FormDataMultiPart form
           "Invalid multi-part for segment: %s", segmentName);
       FormDataBodyPart bodyPart = map.values().iterator().next().get(0);
 
-      File localTempFile = new File(ControllerFilePathProvider.getInstance().getFileUploadTempDir(),
-          getTempSegmentFileName(segmentName));
+      File fileUploadTempDir = ControllerFilePathProvider.getInstance().getFileUploadTempDir();
+      File localTempFile = new File(fileUploadTempDir, getTempSegmentFileName(segmentName));
+
+      if (!localTempFile.getCanonicalPath().startsWith(fileUploadTempDir.getPath())) {
+        throw new IllegalArgumentException("Invalid segment name: " + segmentName);
+      }

Review Comment:
   Makes sense. Addressed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org