logo

Database

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.

Weakness:

151 - Use of an insecure channel - Telnet

Category: Information Collection

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();...