Summary
Java Debug Wire Protocol (JDWP) is a communication protocol used between a Java Virtual Machine (JVM) and a debugger.
It allows a debugger to interact with a running Java application - inspecting variables, threads, setting breakpoints, and controlling execution.
JDWP is commonly exposed over TCP.
An exposed JDWP interface can be a security risk because it may allow an attacker to interact with and potentially execute code within the Java process. Such endpoint may provide significant control over the Java process and even give remote code execution.
Identifying JDWP
Look for it on the port 8000 with nmap. Locally you can run ps auxf and look for arguments such as -Xrunjdwp:transport=dt_socket,address=8000,server=y - you can also check running Java processes with ss -lntp.
JDWP Configuration
Example:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y /opt/stats/App.java
-Xdebug- enables JVM debugging-Xrunjdwp- configures the JDWP debugging agenttransport=dt_socket- uses a TCP socketaddress=8000- listens on TCP port 8000server=y- JVM acts as the debugger server and waits for a debugger
Modern JVM syntax commonly uses -agentlib:jdwp=transport=dt_socket,address=8000,server=y
Connecting with JDB
Java’s command-line debugger:
jdb -attach TARGET:8000