Using clear-text protocols exposes data in transit to eavesdropping and man-in-the-middle attacks.

Why is this an issue?

An attacker who can observe network traffic — for example through a compromised network device, a position on the same network segment, or a cloud environment breach — can read, modify, or inject data sent over ftp, telnet, http, or unencrypted SMTP without detection. This is true even on internal or isolated networks, where insider threats or lateral movement after an initial compromise can expose unencrypted traffic. This rule raises an issue when a clear-text protocol scheme is used or when encryption is explicitly disabled for a network connection.

What is the potential impact?

Sensitive data exposure

An attacker who can intercept network traffic can read all data transmitted over clear-text connections, including credentials, session tokens, API keys, or personal data.

Data tampering

Because clear-text protocols provide no integrity protection, an attacker in a man-in-the-middle position can silently modify data in transit — redirecting users to malicious endpoints, injecting malicious content into responses, or altering commands sent to remote services.

How to fix it in Apache Commons Net

Code examples

The following code uses a clear-text protocol or disables encryption for a network connection, leaving transmitted data exposed to interception.

Noncompliant code example

val telnet = TelnetClient(); // Noncompliant

val ftpClient = FTPClient(); // Noncompliant

val smtpClient = SMTPClient(); // Noncompliant

Compliant solution

val jsch = JSch();

if(implicit) {
  // implicit mode is considered deprecated but offer the same security than explicit mode
  val ftpsClient = FTPSClient(true);
}
else {
  val ftpsClient = FTPSClient();
}

if(implicit) {
  // implicit mode is considered deprecated but offer the same security than explicit mode
  val smtpsClient = SMTPSClient(true);
}
else {
  val smtpsClient = SMTPSClient();
  smtpsClient.connect("127.0.0.1", 25);
  if (smtpsClient.execTLS()) {
    // commands
  }
}

How to fix it in OkHttp

Code examples

The following code uses a clear-text protocol or disables encryption for a network connection, leaving transmitted data exposed to interception.

Noncompliant code example

val spec: ConnectionSpec = ConnectionSpec.Builder(ConnectionSpec.CLEARTEXT) // Noncompliant
  .build()

Compliant solution

val spec: ConnectionSpec =ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
  .build()

How to fix it in Android WebView

Code examples

The following code uses a clear-text protocol or disables encryption for a network connection, leaving transmitted data exposed to interception.

Noncompliant code example

import android.webkit.WebView

val webView: WebView = findViewById(R.id.webview)
webView.getSettings().setMixedContentMode(MIXED_CONTENT_ALWAYS_ALLOW) // Noncompliant

Compliant solution

import android.webkit.WebView

val webView: WebView = findViewById(R.id.webview)
webView.getSettings().setMixedContentMode(MIXED_CONTENT_NEVER_ALLOW)

Exceptions

No issue is reported for the following cases:

Resources

Documentation

Articles & blog posts

Standards