761
memcpy( (char *)&server.sin_addr,(char *)hp->h_addr,hp->h_length);
if (argc < 3) port = 80;
else port = (unsigned short)atoi(argv[3]);
server.sin_port = htons(port);
if (connect(sock, (struct sockaddr *)&server, sizeof server) < 0) error("Connecting");
...
while ((n=read(sock,buffer,BUFSIZE-1))!=-1) {
write(dfd,password_buffer,n);
...
While successful, the program does not encrypt the data before writing it to a buffer, possibly
exposing it to unauthorized actors.
Example 3:
The following code attempts to establish a connection to a site to communicate sensitive
information.
Example Language: Java (Bad)
try {
URL u = new URL("http://www.secret.example.org/");
HttpURLConnection hu = (HttpURLConnection) u.openConnection();
hu.setRequestMethod("PUT");
hu.connect();
OutputStream os = hu.getOutputStream();
hu.disconnect();
}
catch (IOException e) {
//...
}
Though a connection is successfully made, the connection is unencrypted and it is possible that all
sensitive data sent to or received from the server will be read by unintended actors.
Observed Examples
Reference Description
CVE-2009-2272 password and username stored in cleartext in a cookie
https://www.cve.org/CVERecord?id=CVE-2009-2272
CVE-2009-1466 password stored in cleartext in a file with insecure permissions
https://www.cve.org/CVERecord?id=CVE-2009-1466
CVE-2009-0152 chat program disables SSL in some circumstances even when the user says to
use SSL.
https://www.cve.org/CVERecord?id=CVE-2009-0152
CVE-2009-1603 Chain: product uses an incorrect public exponent when generating an RSA
key, which effectively disables the encryption
https://www.cve.org/CVERecord?id=CVE-2009-1603
CVE-2009-0964 storage of unencrypted passwords in a database
https://www.cve.org/CVERecord?id=CVE-2009-0964
CVE-2008-6157 storage of unencrypted passwords in a database
https://www.cve.org/CVERecord?id=CVE-2008-6157
CVE-2008-6828 product stores a password in cleartext in memory
https://www.cve.org/CVERecord?id=CVE-2008-6828
CVE-2008-1567 storage of a secret key in cleartext in a temporary file
https://www.cve.org/CVERecord?id=CVE-2008-1567
CVE-2008-0174 SCADA product uses HTTP Basic Authentication, which is not encrypted
https://www.cve.org/CVERecord?id=CVE-2008-0174
CVE-2007-5778 login credentials stored unencrypted in a registry key
https://www.cve.org/CVERecord?id=CVE-2007-5778
CVE-2002-1949 Passwords transmitted in cleartext.
CWE Version 4.14
CWE-311: Missing Encryption of Sensitive Data
CWE-311: Missing Encryption of Sensitive Data