logo

Database

Python Unencrypted Telnet Connection

Description

Detects usage of unencrypted Telnet connections through Python's telnetlib module. Telnet protocol transmits data including credentials in plaintext, making it vulnerable to network sniffing attacks and unauthorized access.

Weakness:

151 - Use of an insecure channel - Telnet

Category: Information Collection

Detection Strategy

    Check if 'telnetlib' module is imported in the Python code

    Look for usage of 'telnetlib.Telnet' class or 'Telnet' after import

    Report vulnerability when Telnet connection creation is detected through these classes

Vulnerable code example

from telnetlib import Telnet

# VULNERABLE: Using Telnet which transmits credentials in cleartext
tn = Telnet("router.example.com", 23)
tn.write(b"admin\n")
tn.write(b"password\n")

✅ Secure code example

import paramiko

# SAFE: Using SSH instead of Telnet for encrypted communication
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('router.example.com', username='admin', password='password')

# Execute commands over secure SSH channel ...