Kotlin Path Traversal Unsanitized Param
Description
Detects path traversal vulnerabilities in Kotlin applications using JAX-RS framework where file paths from user input are not properly sanitized. This could allow attackers to access files outside the intended directory using path manipulation techniques like "../" sequences.
Detection Strategy
• Verifies that the application imports javax.ws.rs packages indicating JAX-RS usage
• Identifies endpoints that handle file operations using dangerous methods like File(), Paths.get(), or similar file manipulation functions
• Checks if these file operations use parameters directly from user input without proper path sanitization
• Reports a vulnerability when file operations use unvalidated input parameters that could allow directory traversal
Vulnerable code example
import java.io.File
import java.nio.file.Paths
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.PathParam
@Path("/api")
class VulnerableEndpoint {...✅ Secure code example
import org.apache.commons.io.FilenameUtils
import java.io.File
import java.nio.file.Paths
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.core.Response
...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.