Cleartext Transmission of Sensitive Information in the nntplib
Module
The Python module nntplib
provides a number of functions for accessing
NNTP servers. However, the default behavior of the module does not provide
utilize secure connections. This means that data transmitted over the network,
including passwords, is sent in cleartext. This makes it possible for attackers
to intercept and read this data.
The Python module nntplib should only in a secure mannner to protect sensitive data when accessing NNTP servers.
Example
from nntplib import NNTP
with NNTP('news.gmane.io') as n:
n.login('user', 'password')
n.group('gmane.comp.python.committers')
Remediation
If the NNTP protocol must be used and sensitive data will be transferred, it
is recommended to secure the connection using NNTP_SSL
class.
Alternatively, the starttls
function can be used to enter a secure session.
from nntplib import NNTP
with NNTP_SSL('news.gmane.io') as n:
n.login('user', 'password')
n.group('gmane.comp.python.committers')
False Positives
In the case of a false positive the rule can be suppressed. Simply add a
trailing or preceding comment line with either the rule ID (PY012
) or
rule category name (cleartext_transmission
).
- Using rule ID
- Using category name
from nntplib import NNTP
# suppress: PY012
with NNTP('news.gmane.io') as n:
# suppress: PY012
n.login('user', 'password')
n.group('gmane.comp.python.committers')
from nntplib import NNTP
# suppress: cleartext_transmission
with NNTP('news.gmane.io') as n:
# suppress: cleartext_transmission
n.login('user', 'password')
n.group('gmane.comp.python.committers')