Kotlin Ssrf From Untrusted Socket
Description
Detects Server-Side Request Forgery (SSRF) vulnerabilities in Kotlin Spring applications where untrusted input from web requests could be used to make dangerous network connections. This poses a security risk as attackers could manipulate the application to make malicious network requests to internal or external systems.
Detection Strategy
• Application must be using Spring Framework with Controller or RestController annotations
• Checks for network connection functions (e.g. Socket, URL connections) that accept user-controlled input
• Reports a vulnerability when untrusted data from web requests flows into network connection operations
Vulnerable code example
import java.net.ServerSocket
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.QueryParam
@Path("/api")
class ResourceController {
@GET...✅ Secure code example
import java.net.ServerSocket
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.QueryParam
@Path("/api")
class ResourceController {
private val ALLOWED_PORTS = setOf(80, 443, 8080, 8443) // Only allow specific ports...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.