Java Unencrypted Telnet Connection
Description
Detects the usage of unencrypted Telnet connections in Java applications using the Apache Commons Net library. This is a security concern because Telnet transmits data in plaintext, potentially exposing sensitive information to network eavesdropping and man-in-the-middle attacks.
Detection Strategy
• Check if the Apache Commons Net Telnet library (org.apache.commons.net.telnet) is imported in the code
• Look for instantiations of TelnetClient objects and track their variable names
• Search for connect() method calls on identified TelnetClient variables within the same scope
• Report a vulnerability when a TelnetClient object is used to establish a connection
Vulnerable code example
import org.apache.commons.net.telnet.TelnetClient;
public class VulnerableTelnetExample {
public void connectToServer(String host) {
try {
// Vulnerable: Using telnet which transmits data in plaintext
TelnetClient telnet = new TelnetClient();
telnet.connect(host, 23);...✅ Secure code example
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
public class SecureConnectionExample {
public void connectToServer(String host, String user, String password) {
try {
// Secure: Using SSH instead of telnet for encrypted communication
JSch jsch = new JSch();...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.