CodeQL documentation

Cleartext transmission of sensitive information

ID: swift/cleartext-transmission
Kind: path-problem
Security severity: 7.5
Severity: warning
Precision: high
   - security
   - external/cwe/cwe-319
Query suites:
   - swift-code-scanning.qls
   - swift-security-extended.qls
   - swift-security-and-quality.qls

Click to see the query in the CodeQL repository

Sensitive information that is transmitted without encryption may be accessible to an attacker.


Ensure that sensitive information is always encrypted before being transmitted over the network. In general, decrypt sensitive information only at the point where it is necessary for it to be used in cleartext. Avoid transmitting sensitive information when it is not necessary to.


The following example shows three cases of transmitting information. In the ‘BAD’ case, the data transmitted is sensitive (a credit card number) and is not encrypted. In the ‘GOOD’ cases, the data is either not sensitive, or is protected with encryption.

func transmitMyData(connection : NWConnection, faveSong : String, creditCardNo : String) {
	// ...

	// GOOD: not sensitive information
	connection.send(content: faveSong, completion: .idempotent)

	// BAD: sensitive information saved in cleartext
	connection.send(content: creditCardNo, completion: .idempotent)

	// GOOD: encrypted sensitive information saved
	connection.send(content: encrypt(creditCardNo), completion: .idempotent

	// ...


  • © GitHub, Inc.
  • Terms
  • Privacy