Macros are frequently used in the remediation of existing code to globally replace one identifier with another, for example, when an existing API changes. Although some risk is always involved, this practice becomes particularly dangerous if a function name is replaced with the function name of a deprecated or obsolescent function. Deprecated functions are defined by the C Standard and Technical Corrigenda. Obsolescent functions are defined by MSC34MSC24-C. Do not use deprecated or obsolete obsolescent functions.
Although compliance with rule MSC34MSC24-C. Do not use deprecated or obsolete obsolescent functions guarantees compliance with this recommendation, the emphasis of this recommendation is the extremely risky and deceptive practice of replacing functions with less secure alternatives.
...
The Internet Systems Consortium's (ISC) Dynamic Host Configuration Protocol (DHCP) contained a vulnerability that introduced several potential buffer overflow conditions [VU#654390]. ISC DHCP makes use of the vsnprintf()
function for writing various log file strings, which ; vsnprintf()
is defined in the Open Group the Portable Operating System Interface (POSIX®), Base Specifications, Issue 6 [Open Group 20047 [IEEE Std 1003.1:2013] as well as in the C Standard. For systems that do not support vsnprintf()
, a C include file was created that defines the vsnprintf()
function to vsprintf()
, as shown in this noncompliant code example:
...
Replacing secure functions with less secure functions is a very risky practice because developers can be easily fooled into trusting the function to perform a security check that is absent. This may be a concern, for example, as developers attempt to adopt more secure functions, like such as the C11 Annex K functions [ISO/IEC 9899:2011] that , that might not be available on all platforms. (See STR07-C. Use the bounds-checking interfaces for remediation of existing string manipulation code.)
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
PRE09-C |
High |
Likely |
Medium | P18 | L1 |
Automated Detection
Tool | Version | Checker | Description |
---|
Astrée |
| Supported, but no explicit checker | |||||||
Axivion Bauhaus Suite |
| CertC-PRE09 | |||||||
Helix QAC |
| C5003 | |||||||
Polyspace Bug Finder |
| Checks for:
Rec. fully covered. |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
SEI CERT C++ |
Coding Standard | VOID PRE09-CPP. Do not replace secure functions with less secure functions |
ISO/IEC TR 24772:2013 | Executing or Loading Untrusted Code [XYS] |
MITRE CWE | CWE-684, Failure to provide specified functionality |
Bibliography
[ |
IEEE Std 1003.1:2013] |
vsnprintf()
[XSH, System Interfaces, vsnprintf, vsprintf | |
[Seacord 2013] | Chapter 6, "Formatted Output" |
[ |
vsnprintf
Function"VU#654390] |
...
...