Path Traversal (ARCH8103)
Esta página aún no está disponible en tu idioma.
Key kotlin.security.path-traversal · Severity error · Category security · CWE CWE-22
Flags File / Paths.get / FileInputStream built from request, intent or parameter data without normalisation. A template that only splices values the app produced itself (a clock, a UUID, a constant) is not untrusted.
Incorrect
Section titled “Incorrect”val file = File(uploadDir, request.getParameter("name"))Correct
Section titled “Correct”val file = File(uploadDir, name).canonicalFilerequire(file.startsWith(uploadDir.canonicalFile))Canonicalise the path and check it stays under the intended directory.