logo

Database

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.

Weakness:

100 - Server-side request forgery (SSRF)

Category: Deceptive Interactions

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...