^

Standards Compliance

Standards Compliance

Mastering CWE: Overview, the top 25 and CWE 4.14

According to the website, “CWE™ is a community-developed list of software and hardware weakness types. It serves as a common language, a measuring stick for security tools, and as a baseline for weakness identification, mitigation, and prevention efforts.”

The Common Weakness Enumeration (CWE) list therefore covers a broad spectrum of hardware and software issues. It itemises over 800 programming errors, design errors, and architecture errors, any of which may lead to exploitable vulnerabilities.

What is CWE?

CWE is an abbreviation for “Common Weakness Enumeration”. It is a community-developed list of software and hardware weakness types, covering the whole range of connected hardware and software. The list includes programming errors, design errors, and architecture errors, any of which may lead to exploitable vulnerabilities.

The CWE list aims to cover weaknesses throughout the different phases of software development and across many programming languages. These weaknesses are categorized and organized into views that can help software developers quickly find weaknesses based on specific criteria or use cases.

CWE allows developers to identify and minimize weaknesses as early in the lifecycle as possible, improving its overall security and helping to prevent vulnerabilities. 

Is CWE a coding standard?

As the above implies, there is no such thing as a CWE security coding standard. It is not directly comparable to (for example) the Cert C coding standard or the MISRA C++ Guidelines. However, the illustration above – extracted from  the CWE website –  reflects the fact that many of the weaknesses it lists are such that language-specific software security tools like the LDRA tool suite can find them in source code. It is therefore often referred to as the “CWE coding standard” for convenience.  

WHY is CWE important?

Adherence to the CWE “coding standard” brings several key benefits: 

Enhanced Security: By addressing common software weaknesses identified in the CWE coding standard, organizations can significantly enhance the security of their source code. This minimizes the likelihood of successful cyberattacks, data breaches, and other security failures, protecting sensitive information and preserving customer trust. 

Reduced Risk: Proactively addressing known vulnerabilities helps mitigate risks associated with software weaknesses. This reduces the likelihood of financial losses, regulatory penalties, reputational damage, and other negative consequences resulting from security breaches or non-compliance with industry standards and regulations. 

Cost Savings: Addressing vulnerabilities early in the software development lifecycle is generally more cost-effective than fixing them after deployment. By implementing CWE and conducting thorough security testing, organizations can identify and ultimately fix any vulnerabilities before they become too costly to resolve or cause disruptions to business operations. 

Compliance Requirements: Many regulatory and industry standards mandate the implementation of security best practices, including addressing common software weaknesses. Adhering to CWE can help organizations demonstrate compliance with regulations such as GDPR, HIPAA, PCI DSS, and others, avoiding potential fines, legal issues, and loss of business opportunities. 

Improved Customer Satisfaction: Building secure software products instils confidence in customers and stakeholders, leading to improved satisfaction and customer loyalty. Demonstrating a commitment to security by implementing CWE can give businesses a competitive advantage in the marketplace and attract new customers who prioritize security and privacy. 

Faster Time to Market: By incorporating software security checking into the development process from the beginning, businesses can avoid delays caused by last-minute security fixes. This enables a faster time-to-market for products and services, allowing businesses to capitalize on market opportunities and gain a competitive edge. 

Protection of Intellectual Property: Addressing vulnerabilities helps protect intellectual property and proprietary information from unauthorized access, theft, or exploitation. This safeguards valuable assets and prevents competitors or malicious actors from gaining access to sensitive data or compromising the organization’s competitive advantage. 

Overall, implementing the CWE standard aligns with sound business practices, promotes a culture of software security, and contributes to the long-term success and resilience of organizations in an increasingly digitally connected world.

Who is MITRE in relation to CWE?

The common Weakness Enumeration database is a US governmental project, sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA). It is managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE).

What is the CWE Top 25?

The Common Weakness Enumeration (CWE) Top 25 Most Dangerous Software Weaknesses (CWE Top 25) is a subset of the full Common Weakness Enumeration list. It highlights the most common and critical issues experienced over the previous two calendar years.

The issues are commonplace generally because they are easy to find and exploit. They are dangerous because they allow bad actors to steal data, take over a system, or stop it from working.

The latest version of the CWE Top 25 does not list 25 rules – but it retains the “top 25” moniker irrespective! Some of the rules are enforceable by means of automated tools such as those provided by LDRA, including the examples listed below. Others are not. 

What is the difference between CWE and CVE?

CWE and CVE (Common Vulnerabilities and Exposures and NOT Common Vulnerability Enumeration!) are closely related, but subtly different. CWE lists types of software weaknesses, and hence provides a software vulnerability encyclopaedic reference. CVE lists instances of vulnerabilities for specific applications. 

How does NIST 500-268 relate to CWE?

NIST 500-268 is a static analysis implementation standard that calls out specific CWE entries relevant to C and C++. Although it dates from 2011, its focus on issues such as stack and heap safety, exceptions, and range-based errors (e.g. buffer overflows and underflows) make it just as relevant today 

What are CWSS and CVSS?

The Common Weakness Scoring System (CWSS) is an open framework for the documentation of software weaknesses. It uses three metrics – Attack surface, Base, and Environmental – to help grade the weaknesses according to severity.

Similarly, the Common Vulnerability Scoring System (CVSS) is an open framework for communicating the characteristics and severity of instances of software vulnerabilities using Base, Temporal, and Environmental metrics to grade each of them.

The relationship between CWSS and CVSS is therefore analogous to that between CWE and CVE.

How does NVD relate to CVE and CVSS?

The National Vulnerability Database (NVD) is not directly related to CWE or CVE despite being complementary to them. It is managed by the National Institute of Standards and Technology (NIST), rather than MITRE.

However, the CVE list feeds into the National Vulnerability Database (NVD). It provides enhanced information above and beyond what’s in the CVE list, including CVSS Base metric scores.

What is CWE 4.14?

CWE 4.14 is the current version of CWE. It lists a total of 938 weaknesses. 

The goal of the CWE list is to offer clear and concise definitions for each type of common weakness, helping the community grasp and tackle vulnerabilities in software and hardware more effectively. This initiative is dynamic, regularly improved and enhanced through input and feedback from users. 

What are the differences between CWE 3.4 and CWE 4.14? 

The primary difference between CWE 3.4 and CWE 4.14 is that the latter includes a number of new, additional weaknesses. 

According to the CWE website, CWE 3.4.1 lists a total of 808 weaknesses while CWE 4.0 (starting at CWE-1189) lists a total of 839 weaknesses.  

CWE 4.14 (up to CWE-1424) lists a total of 938 weaknesses, implying that it lists 130 more weaknesses than CWE 4.0. 

However, of these 130 new weaknesses, only 3 are applicable to C/C++ – namely CWE-1325, CWE-1335, and CWE-1341: 

Along with new weaknesses, other enhancements in the new version include refinement and clarification to the CWE list.These reflect the ongoing efforts to improve the Common Weakness Enumeration and to provide a more comprehensive and effective resource for addressing software and hardware vulnerabilities.

How is CWE organized?

The Common Weakness Enumeration database is organized based on abstractions of behaviour rather than on more pragmatic considerations such as where weaknesses might be found in source code. This gives rise to a tree-like structure that organises and groups the base-level weaknesses.

At the highest level, there are categories and pillars designed to group weaknesses. Strictly speaking, these are not weaknesses themselves but the fact that they are afforded entries in the CWE database sometimes gives rise to references to a “pillar weakness” or a “category weaknesses”. Pillars and categories work in combination. Pillars offer a high-level view, and categories provide a more specific breakdown within each pillar. Beneath these top-level entries, weaknesses are organized at various levels of abstraction.

What are CWE weakness levels?

Each Common Weakness Enumeration weakness is assigned a level to indicate relative severity and hence help with prioritization. They are as follows: 

  • Class: Class-level weaknesses are concerned with the overall structure of the software system and its potential for security vulnerabilities. They are often broad and fundamental in nature. 
  • Base: Base-level weaknesses are more specific code flaws that can lead to security vulnerabilities, such as buffer overflows, and SQL injection.  

These are typically easier to spot than class-level issues during code review or automated analysis.

What is Common Weakness Enumeration Compatibility (or CWE Compatibility)?

The Common Weakness Enumeration Compatibility and Effectiveness Program provides a mechanism for a product or service to be reviewed and registered as officially “CWE-Compatible” and “CWE-Effective”. The listed products and services in the CWE program enable development teams to identify and evaluate tools, training, and/or services pertinent to their development project.

CWE-compatible products and services must meet the following criteria:

  • CWE Searchable – Users may search security elements using CWE identifiers
  • CWE Output – Security elements presented to users includes, or enables users to obtain, associated CWE identifiers
  • Mapping Accuracy – Security elements accurately link to the appropriate CWE identifiers
  • CWE Documentation – Capability’s documentation describes CWE, CWE compatibility, and how CWE-related functionality in the capability is used

As this CWE certificates illustrates the LDRA Testbed and TBvision components of the LDRA tool suite are listed as CWE‑Compatible, alongside the LDRArules point product.

How can LDRA help with CWE compliance?

The ability to statically analyse software efficiently with reference to the Common Weakness Enumeration list of vulnerabilities delivers tangible benefits to development teams in terms of code security, quality, and reduced time-to-deployment. Help is available from LDRA in the form of consultancy and the CWE security tools (sometimes called “CWE checkers”) found in both the LDRA tool suite and LDRArules.

More specifically, LDRA tools can help in the following ways: 

  • Identification of Vulnerabilities: LDRAs static analysis tools can scan source code to identify potential vulnerabilities that align with the CWE standard as well as countless other security and functional safety standards. By leveraging advanced analysis techniques, LDRA tools can pinpoint areas of concern, such as improper input validation, buffer overflows, or insecure authentication mechanisms, allowing users to address those concerns early and often.

  • Early Detection in the Development Lifecycle: LDRAs Tool suite enables developers to detect vulnerabilities early in the software development lifecycle, even before the code is compiled or executed. By integrating static analysis into the development process, organizations can address weaknesses at the source code level, reducing the likelihood of security breaches and minimizing the need to re-write sections of code.

  • Comprehensive Testing: LDRA offers a suite of tools for static and dynamic analysis, as well as unit testing, allowing customers to perform comprehensive testing of their source code. Dynamic analysis tools simulate real-world scenarios and interactions with the software, helping to uncover vulnerabilities related to runtime behaviour, input validation, and data flow. Unit testing allows the user to isolate single files or procedures of their source code and execute them with custom inputs and outputs. This allows the user to test their code outside of normal operating conditions.

  • Customizable Rule Sets: LDRAs tools provide customizable rule sets that can be tailored to address specific CWE rules or other industry standards and regulations. This flexibility enables organizations to focus their efforts on the most critical vulnerabilities and prioritize remediation efforts accordingly.

  • Integration with Development Environments: LDRA tools can seamlessly integrate with popular development environments and IDE’s, facilitating the incorporation of security analysis into existing workflows. This integration streamlines the process of identifying and addressing vulnerabilities, minimizing disruption to the development process.

  • Compliance Reporting: LDRA tools include features for generating compliance reports that will document the source code’s adherence to any security standards or regulations, including CWE. These reports provide managers with visibility into the project’s security posture and demonstrate a commitment to best practices in software security.

  • Training and Support: LDRA typically offers training and support services to help customers maximize the effectiveness of their tools by teaching the importance of good quality coding, implementing CWE scanning as well as using other standards to address any security challenges. This includes training on tool usage, best practices in software security, and guidance on interpreting analysis results. 

By leveraging LDRAs expertise and tool suite for static and dynamic analysis, organizations can effectively apply the CWE standard, strengthen the security of their software, and mitigate the risk of security breaches and compliance violations. 

 

 

Examples of CWE rules found by LDRA tools 

CWE rules include some of the most common and most exploitable software weaknesses that developers and security professionals need to address before a final release. LDRA’s tool suite can play a crucial role in identifying and mitigating these weaknesses throughout the software development lifecycle. They include: 

  • Out of Bounds Write (CWE-787):  Failing to inspect data before it is written to a buffer can result in buffer overrun which in turn can result in the execution of malicious code. 

  • Use after free (CWE-416): If pointers are used after they are free’d or deleted this can lead to unintended data access.  
  • Improper Neutralization of Special Elements used in OS Command (CWE-78): When data comes in from insecure sources, it must be inspected before being used in unsecured commands. 
  • Improper Input Validation (CWE-20): Failure to properly validate inputs can lead to various security vulnerabilities, such as buffer overflows, SQL injection, and cross-site scripting (XSS). 

  • Out of Bounds Read (CWE-125): Just like the out of bounds write, an out of bounds read can result in access to privileged information by unprivileged actors. Therefore, it is important to inspect reads against buffers to make sure the buffers are correctly sized and contain secured data. 
  • Improper Limitation of Pathname to a Restricted Directory (CWE-22): Application code often has access to the file system. If care is not taken to restrict data that access the file system, use of improper paths can allow access to secure data from an unsecure application. 
  • Concurrent Execution using Shared Resources with Improper Synchronization (CWE-362): In multi-threaded access scenarios it is important that shared resources are protected with guarding constructs. If this is not done, race conditions can cause program halts and switch to safe state, which could allow access to unintended resources. 
  • Null pointer dereference (CWE-476): Pointers should always be checked before use to avoid dereferencing null pointers. This can lead to program halts and uncontrolled operation which can allow unintended access to secure elements. 

What role does LDRA static analysis play?

Static analysis can be initiated to ensure Common Weakness Enumeration security compliance as code is developed, and automatically applied during unit, system, or integration testing to ensure that compliance achieved at the outset is not compromised throughout the software development life cycle. Pertinent CWE rules are completely integrated into LDRA tools for efficient checking within a familiar development environment.

LDRA static analysis tools locate and highlight areas of non-conformant code to aid documentation and modification. Extensive reports and graphical displays enhance understanding of the source code, facilitating improvements in line with Common Weakness Enumeration rules.

What role does LDRA dynamic analysis play?

The use of static and dynamic analysis in tandem provides the opportunity to identify possible weaknesses both in the source code and in the executable. 

The TBvision and TBrun components of the LDRA tool suite are examples of tools that support unit testing, integration testing, System Integration Testing (SIT) and system testing. Black box and white box testing are supported, where black box testing focuses on external behaviour and functionality, while white box testing also assesses the internal behaviour of the code under review.  

Unit testing v integration testing

The TBrun component of the LDRA tool suite supports both unit testing and integration testing. Unit testing focuses on isolated units of code often with external dependencies replaced by stubs, while integration testing evaluates how those units work togetherperhaps with stubs at the outer reaches of the code under test. 

System testing v integration testing

The TBvision and TBrun components of the LDRA tool suite in tandem support integration testing, system integration testing, and system testing  

Both integration testing and system testing are essential for ensuring the quality and reliability of a software system. Integration testing is performed to detect issues that arise when components are integrated.  

System Integration Testing (SIT) extends that principle by focusing on the interactions and interfaces between subsystems within a larger software system.  

System testing verifies that the complete software system meets its intended objectives.  

CWE and dynamic testing

Dynamic analysis is called out in some CWE weaknesses. For example, LDRA dynamic analysis tools facilitate structural coverage analysis to ensure that software “testedness” is measured and maintained, as recommended inCWE-912 (Hidden functionality) and related CWE weaknesses. 

More generally, benefits of dynamic analysis in this context include: 

  • Identifying actual vulnerabilities: The provision of information on how the software behaves during execution reveals different kinds of vulnerabilities as compared to static analysis. 
  • Testing for security misconfigurations: CWE weaknesses often include issues related to security misconfigurations. The LDRA tool suite can help to identify these misconfigurations by simulating various runtime conditions and configurations and then assessing how the application responds. 
  • Detecting runtime flaws: Many CWE weaknesses are related to memory management issues, such as buffer overflows or use-after-free vulnerabilities. The LDRA tool suite can help to flag execution-time anomalies, helping to pinpoint these types of runtime flaws. 
  • Assessing for Injection Attacks: Dynamic analysis can be used to simulate input attacks, like SQL injection. By monitoring how the application processes and responds to these attacks during runtime, the LDRA tool suite can help identify CWE weaknesses related to injection vulnerabilities. 
  • Evaluating Resilience to Attacks: CWE weaknesses often relate to the application’s resilience against various attacks. Dynamic analysis can be used to simulate different attack scenarios, with the TBextreme module being especially valuable in this regard. 

CWE compliance tools from LDRA

  • Some CWE weaknesses are best identified by means of static analysis. Dynamic analysis is more suited to others. The LDRA tool suiteprovides both
  • The TBvision component of the LDRA tool suite automates static source code checking. And it includes checks to ensure the avoidance of CWE listed weaknesses. It also supports dynamic system testing. 
  • The TBrun component of the LDRA tool suite supports unit test, integration test, System Integration Test (SIT), and system test. 
  • The TBextreme module supplements TBrun to provide an automated means of test vector generation. 
  • LDRArules is a cost-effective, stand-alone rules checker independent from the LDRA tool suite. It includes checks to ensure the avoidance of CWE listed weaknesses.
  • The TBsecure module enables CWE reporting. It identifies security vulnerabilities, including dynamic memory allocation concerns and other common programming errors.  When used with the LDRA tool suite, TBsecure produces additional code reviews capturing memory and security analysis results.
  • The TBexclude supplementary module provides for the efficient management of justified rule violations.
  • LDRA’s structural coverage analysis supports the recommendations of CWE-912 (Hidden functionality) and related CWE listed weaknesses. Related requirements traceability can be automated using the TBmanager component of the LDRA tool suite.

CWE compliance matrix

LDRA offers complete transparency on compliance with every supported standard including Common Weakness Enumeration listed weaknesses. A compliance matrix shows exactly which rules are implemented.

A summary of LDRA static analysis tools’ compliance with the Common Weakness Enumeration listed weaknesses can be found below and the detailed matrix can be downloaded by registered users.

Note that the Common Weakness Enumeration list includes a wider range of vulnerability types. This matrix excludes those that concern libraries, languages that are not supported by LDRA, and issues that are not statically checkable.

For many CWE rules, some parts can be implemented automatically while other parts require some manual review. Such rules are listed as partially implemented. Almost all CWE rules related to C/C++ are implemented to a greater or lesser degree. 

Additional information

FREE 30 Day
TRIAL

Email Us

Email: info@ldra.com

Call Us

EMEA: +44 (0)151 649 9300

USA: +1 (855) 855 5372

INDIA: +91 80 4080 8707

Connect with LDRA