Difference between revisions of "Use of Obsolete Methods"

From OWASP
Jump to: navigation, search
 
Line 1: Line 1:
 
{{Template:Vulnerability}}
 
{{Template:Vulnerability}}
 +
{{Template:Fortify}}
 +
 +
==Abstract==
 +
 +
The use of deprecated or obsolete functions may indicate neglected code.
  
 
==Description==
 
==Description==
 +
 +
As programming languages evolve, functions occasionally become obsolete due to:
 +
 +
Advances in the language
 +
Improved understanding of how operations should be performed effectively and securely
 +
Changes in the conventions that govern certain operations
 +
Functions that are removed are usually replaced by newer counterparts that perform the same task in some different and hopefully improved way.
 +
 +
Refer to the documentation for this function in order to determine why it is deprecated or obsolete and to learn about alternative ways to achieve the same functionality. The remainder of this text discusses general problems that stem from the use of deprecated or obsolete functions.
  
 
==Examples ==
 
==Examples ==
 +
 +
The following code uses the deprecated function getpw() to verify that a plaintext password matches a user's encrypted password. If the password is valid, the function sets result to 1; otherwise it is set to 0.
 +
 +
<pre> ...
 +
getpw(uid, pwdline);
 +
for (i=0; i<3; i++){
 +
cryptpw=strtok(pwdline, ":");
 +
pwdline=0;
 +
}
 +
result = strcmp(crypt(plainpw,cryptpw), cryptpw) == 0;
 +
...
 +
</pre>
 +
 +
Although the code often behaves correctly, using the getpw() function can be problematic from a security standpoint, because it can overflow the buffer passed to its second parameter. Because of this vulnerability, getpw() has been supplanted by getpwuid(), which performs the same lookup as getpw() but returns a pointer to a statically-allocated structure to mitigate the risk.
 +
 +
Not all functions are deprecated or replaced because they pose a security risk. However, the presence of an obsolete function often indicates that the surrounding code has been neglected and may be in a state of disrepair. Software security has not been a priority, or even a consideration, for very long. If the program uses deprecated or obsolete functions, it raises the probability that there are security problems lurking nearby.
  
 
==Related Threats==
 
==Related Threats==
Line 15: Line 45:
 
==Categories==
 
==Categories==
  
{{Template:Stub}}
+
[[Category:Code Quality Vulnerability]]
 +
 
 +
[[Category:C]]
  
 
[[Category:Implementation]]
 
[[Category:Implementation]]
  
[[Category:Code Quality Vulnerability]]
+
[[Category:Code Snippet]]
 +
 
 +
[[Category:Use of Dangerous API]]

Revision as of 13:16, 20 July 2006

This is a Vulnerability. To view all vulnerabilities, please see the Vulnerability Category page.


This article includes content generously donated to OWASP by Fortify.JPG.

Abstract

The use of deprecated or obsolete functions may indicate neglected code.

Description

As programming languages evolve, functions occasionally become obsolete due to:

Advances in the language Improved understanding of how operations should be performed effectively and securely Changes in the conventions that govern certain operations Functions that are removed are usually replaced by newer counterparts that perform the same task in some different and hopefully improved way.

Refer to the documentation for this function in order to determine why it is deprecated or obsolete and to learn about alternative ways to achieve the same functionality. The remainder of this text discusses general problems that stem from the use of deprecated or obsolete functions.

Examples

The following code uses the deprecated function getpw() to verify that a plaintext password matches a user's encrypted password. If the password is valid, the function sets result to 1; otherwise it is set to 0.

	...
	getpw(uid, pwdline); 	
	for (i=0; i<3; i++){
		cryptpw=strtok(pwdline, ":");
		pwdline=0;
	}
	result = strcmp(crypt(plainpw,cryptpw), cryptpw) == 0;
	...

Although the code often behaves correctly, using the getpw() function can be problematic from a security standpoint, because it can overflow the buffer passed to its second parameter. Because of this vulnerability, getpw() has been supplanted by getpwuid(), which performs the same lookup as getpw() but returns a pointer to a statically-allocated structure to mitigate the risk.

Not all functions are deprecated or replaced because they pose a security risk. However, the presence of an obsolete function often indicates that the surrounding code has been neglected and may be in a state of disrepair. Software security has not been a priority, or even a consideration, for very long. If the program uses deprecated or obsolete functions, it raises the probability that there are security problems lurking nearby.

Related Threats

Related Attacks

Related Vulnerabilities

Related Countermeasures

Categories