Skip to content

Commit 768732a

Browse files
committed
docs: Documenting use of suppress warnings for path traversal in security utils
1 parent 0b92c8e commit 768732a

File tree

1 file changed

+9
-0
lines changed
  • aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal

1 file changed

+9
-0
lines changed

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/SecurityUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
package com.amazonaws.serverless.proxy.internal;
1414

15+
import com.amazonaws.serverless.proxy.model.ContainerConfig;
1516
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
1617
import org.slf4j.Logger;
1718
import org.slf4j.LoggerFactory;
@@ -174,6 +175,14 @@ public static String getValidFilePath(String inputPath) {
174175
/**
175176
* Returns an absolute file path given an input path and validates that it is not trying
176177
* to write/read from a directory other than /tmp.
178+
*
179+
* We suppress the path traversal warnings because this method is used to validate paths passed
180+
* to the servlet implementation methods such as {@link com.amazonaws.serverless.proxy.internal.servlet.AwsProxyRequestPart#write(String)}.
181+
* Using relative paths is a valid use-case for developers implementing a servlet-based API. We
182+
* mitigate the potential partial path traversal by checking the resulting absolute path against
183+
* the list of allowed paths specified in {@link ContainerConfig#getValidFilePaths()}. We also
184+
* block the /var/task directory regardless.
185+
*
177186
* @param inputPath The input path
178187
* @return The absolute path to the file
179188
* @throws IllegalArgumentException If the given path is not valid or outside of /tmp

0 commit comments

Comments
 (0)