The CERT C++ Programming Language Secure Coding Standard was developed specifically for versions of the C++ programming language defined by the following:
- ISO/IEC 14882-2003. Programming Languages â” C2014, Programming Languages—C++, Second Fourth Edition, 2003.
- C++0X standard (forthcoming)
- 2014 [ISO/IEC 14882-2014]
Although the guidelines for this standard were developed for C++14, they Some of the material included in this standard can also be applied to earlier versions of the C++ programming language.Rules and recommendations included in this CERT , including C++11. Variations between versions of the C++ Programming Language Secure Coding Standard are designed to be operating system and platform independent. However, the best solutions to secure coding problems are often platform specific. In most cases, this standard provides appropriate compliant solutions for POSIX-compliant and Windows operating systems. In many cases, compliant solutions have also been provided for specific platforms such as Linux or OpenBSD. Occasionally, we also point out implementation-specific behaviors when these behaviors are of interest.
Rationale
Wiki Markup |
---|
A secure coding standard for the C\+\+ programming language can create the highest value for the longest period of time by focusing on C\+\+03. In addition, because considerably more money and effort is devoted to developing new code than maintaining existing code, the highest return on investment comes from influencing programmers who are developing new code \[[Seacord 03|AA. Bibliography#Seacord 03]\]. Maintaining existing code is still an important concern, however. |
Standard that would affect the proper application of these guidelines are noted where applicable.
Most guidelines have a noncompliant code example that is a C++14-conforming program to ensure that the problem identified by the guideline is within the scope of the standard. Most guidelines also include a compliant solution that applies to multiple platforms. Language and library extensions that have been published as ISO/IEC technical reports or technical specifications are frequently given precedence. Occasionally, interesting or illustrative implementation-specific behaviors are described.
Rationale
A coding standard for the C++ programming language can create the highest value for the longest period of time by focusing on the C++ Standard (C++14) and any relevant post-C++14 technical reports.
The C++ Standard The C++ standard documents existing practice where possible. That is, most features must be tested in an an implementation before being included in the standard. The CERT C++ secure coding standard Coding Standard has a different purpose. When existing practice serves this purpose, that is fine, but the goal is to create a new secondary purpose: to establish a set of best practices, and that includes introducing some concepts that are not yet widely knownwhich sometimes requires introducing new practices that may not be widely known or used when existing practices are inadequate. To put it a different way, the CERT C++ secure coding guidelines are attempting Coding Standard attempts to drive change rather than just document it.
Some vendors have extensions to C++, and some also have implemented only part of the C++ standard Standard before stopping development. Consequently, it is not possible to back up and only discuss discuss only C++98, C++97 or an earlier version of 03, or C++11. The vendor support equation is too complicated to draw a line and say that a certain compiler supports exactly a certain standard. Whatever demarcation point is selected, different vendors are on opposite sides of it for different parts of the language. Supporting all possibilities would require testing the cross-product of each compiler with each language feature. Consequently, we have selected a demarcation point that is the most recent in time , so that the rules and recommendations defined by the standard will be applicable for as long as possible. As a result of the variations in support, source-code portability is enhanced when the programmer uses only the features specified by C++9714. This is one of many trade-offs between security and portability inherent to C++ language programming.
The value of forward-looking information increases with time before it starts to decrease. The value of backward-looking information starts to decrease immediately.
For all of these reasons, the priority of this standard is to support new code development using C++0314. A close-second priority is supporting remediation of old code using C++0311.
This coding standard does try to make contributions to support older compilers when these contributions can be significant and doing so does not compromise other priorities. The intent is not to capture all deviations from the standard but to capture only a few important ones.
Issues Not Addressed
There are a A number of issues are not addressed by this secure coding standard.
...
Coding style issues are subjective, and it has proven impossible to develop a consensus on appropriate style guidelines. Consequently, the CERT C++ Secure Coding standard Standard does not require the enforcement of any particular coding style to be enforced but only that the user defines suggests that development organizations define or adopt style guidelines and apply these guidelines consistently. The easiest way to consistently apply a coding style consistently is with the to use of a code-formatting tool. Many interactive development environments (IDEs) provide such capabilities.
Tools
As a federally funded research and development center (FFRDC), the SEI is not in a position to recommend particular vendors or tools to enforce the restrictions adopted. The user of this document is free to choose tools, and vendors are encouraged to provide tools to enforce the rules.
Controversial Rules
In general, the CERT secure coding standards try to avoid the inclusion of controversial rules that lack a broad consensus.