Skip to content

Commit

Permalink
docs: Documenting use of suppress warnings for path traversal in secu…
Browse files Browse the repository at this point in the history
…rity utils
  • Loading branch information
sapessi committed Aug 18, 2022
1 parent 0b92c8e commit 768732a
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package com.amazonaws.serverless.proxy.internal;

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

0 comments on commit 768732a

Please sign in to comment.