Code Audit Report
Total Page:16
File Type:pdf, Size:1020Kb
Code Audit Report Muhammad Uzair May 25, 2017 Abstract Many applications are being used by individuals and businesses these days. Also, these applications becoming a part of daily life. These appli- cations use personal information and sometimes very important business transaction information. The security of that information is a very im- portant issue. To make the information secure enough, it is required that the application is working as it should be. Code audit/review is done in this regard. If there are any flaws, weaknesses, threats or any kind of vulnerabilities found in the code, then actions are taken accordingly and fixes are applied. Some code audits examples are presented in this report and then the code audit report of DigiDoc is presented, which is a module of Open-EID. 1 Introduction Security of the applications being used is a major concern nowadays. Applica- tions have become a very common part of our daily life. These applications are being used for business and for personal use. Personal data, internal organi- zational data is managed by these applications so it is critical and essential to protect this data. There are many challenges when we talk about the protection of this important data and the security of these applications. Also the exposure to internet has made these applications a prime target for the information they contain. There are many advantages of Free and Open-Source Software (FOSS). One of them is that their source code is available which enables anyone to check the code and fix bugs, anyone can add new features and it is also important from security point of that anyone can check the security of the code and make it better. The free availability of the code also enables the organizations to find any vulnerabilities in the code and allow them to refine the security which results into a safer user experience and also make the applications secure. 2 Background Here are some of the code audits done by the EU-FOSSA (Free and Open-Source Software Auditing). FOSSA focuses on the security aspects of the software. Following code audits are included in this report: 1 • Apache Core & APR (Apache Portable Runtime) • KeePass Password Safe The details of the code analysis are below: 2.1 Apache Core & APR Code Review Apache HTTP server is one of the widely used HTTP and proxy server and it is a FOSS (Free and Open Source Software) [3]. It has become mature because many security flaws have been detected and corrected since it started running in 1995. The objective of the code review was to examine the Apache Core & APR and the main focus was on security aspects. 2.1.1 Scope Application Name Apache Core & APR Code Reviewer owner European Commission { Directorate-General for Informatics (DIGIT) Review Start 25/07/2016 Review End 22/08/2016 Objective Security Code Review Number of Lines 61286 Code Review Mode • Managed • Defined • Optimized Libraries • Apache Core • Apache Portable Runtime Extensions N/A Services Required N/A Table 1: Scope of Apache Core & APR 2.1.2 Executive Summary The Apache server is composed of many components. This code review only focused on the core of Apache server and did not include any external module or extension. 2 The reviewed modules are Apache HTTP core and the Apache Portable Run- time. The total number of reviewed lines were 61286 which makes nearly 20% of the total lines of Apache server. When doing code review, the Linux and Windows were considered because they are the most widely used operating sys- tems. Talking about the code review, there were many findings discovered and all of those findings were within the Secure Code Design and Specific C controls categories. Only 7 out of 160 controls had at least one finding detected in them which is a low percentage overall. Following is the summary of the findings and their risk level: Risk Level Finding Critical 0 High 0 Medium 0 Low 2 Info 5 Table 2: Summary of findings in Apache Core & APR It is obvious that there were no critical or even medium or high risks. The findings were classified as low or informative, but they still should be fixed. 2.1.3 Methodology The methodology was consisting of four phases and each phase had 3 further activities. Following are the phases and their activities: 1. Planning The first phase is all about gathering the required information which can be useful for code review. It includes the basic information about code review, applicable test cases and the preparation of test environments if there is any need. • Preparation { information is gathered to define the scope for the code review. • Test Design { test cases are defined once the scope is defined in order to achieve the objectives. • Environment Preparation { before starting the next phase, it is made sure that the environment is ready for conducting the test cases. 2. Execution In this phase, the test cases are executed which were selected in the previ- ous phase. The execution was divided into three parts. Each part provide data as input for the other part. 3 • Managed Mode { this phase uses the automated tools for the execution of test cases. Following categories were analyzed: • Data/Input Management (DIM) • Authentication Controls (AUT) • Session Management (SMG) • Authorization Management (ATS) • Cryptography (CPT) • Error Handling/Information Leakage (EHI) • Software communication (COM) • Logging/Auditing (LOG) • Secure Code Design All of the above mentioned categories have further sub-categories but those are not important to mention here. • Defined Mode { the results are gathered from automated tools and compared with manual tests results for final results. • Optimized Mode { in this section the riskiest parts are evaluated. They are divided into following sub-categories: • Concurrency (CCR) • Denial of Service (DOS) • Memory and resource management (MRM) • Code Structure (COS) • Role-privilege matrix (RPM) There were also language specific controls in the optimized mode as follows: • Pre-Processor (PRE) • Variable Management (VMG) • Memory Management (MEM) • File I/O Management (FIO) • Environment (ENV) • Signal and Error Handling (SEH) • Concurrency (CON) • Miscellaneous (MSC) 3. Assessment The risk analysis of the findings from the previous steps was done in this phase. The score was calculated on the basis of threat and vulnerability level of the findings. Following are the scores that were assigned to the findings: The findings were marked as Low, Medium or High based on their average numeric results. Following are the sub-categories of assessment phase: 4 Numerical Value Impact 0 to 3 Low 4 to 6 Medium 7 to 9 High Table 3: Assessment of findings • Technical Report • Impact Analysis • Finding Prioritization 4. Reporting • Report • Report Dissemination • Post-audit The controls were divided into two main groups: 1. Common controls { these controls are applicable regardless of the language of the code. 2. Language specific controls { for C, C++, JAVA or PHP. The combination of both groups should be used for accurate results. 2.1.4 Detailed Results There were findings in 7 controls. Following are those controls: • Secure Code design { Framework Requirement: SCD-FWK-001 (info) • Specific C Controls { Variable Management: CBC-VMG-004 (info), CBC-VMG-011 (info) { Memory Management: CBC-MEM-001 (low), CBC-MEM-005 (info) { File I/O Management: CBC-FIO-001 (low) { Signal and Error Handling: CBC-SHE-007 (info) There were evidences provided for every control and the recommendations to overcome that risk. 5 2.1.5 Conclusion Most of the findings were language-specific. It is because the reviewed part did not include as many functionalities as other parts of the Apache server. The main focus was on the APR as it is very important from the security point of view. The final conclusion stated that both Apache Core & APR have a good level from a security point of view. There were only few controls with findings and those were not of high severity. Also those findings cannot be considered as directly security flaws because security is a set of layers and therefore several risky findings are necessary to compromise the software. 2.2 KeePass Code Review KeePass is a free and open source software tool that helps to manage passwords in a secure way [4]. The passwords can be stored in one database which is locked with one master key or a key file. So only one password or key file is required to unlock the database. AES and Twofish encryption algorithms are used to encrypt the databases. 2.2.1 Scope Application Name KeePass Password Safe Code Reviewer owner European Commission { Directorate-General for Informatics (DIGIT) Review Start 24/08/2016 Review End 23/09/2016 Objective Security Code Review Number of Lines 84622 Code Review Mode • Managed • Defined • Optimized Libraries MFC v 9.0 (It was not in the scope of code review because it is not open source) Extensions N/A Services Required N/A Table 4: Scope of KeePass Password Safe 6 2.2.2 Executive Summary There were 84622 lines to be reviewed. To speed up the process, the total was divided into 33 sub-sections and it was handed over to the review team. Following are the categories in which the team discovered findings: • Error Handling/Information Leakage • Logging/Auditing • Secure Code Design • Specific C Controls • Specific C++ Controls 2.2.3 Methodology The same methodology was adopted for KeePass as it was used for the code review of Apache Core & APR. 2.2.4 Assessment The same assessment method was adopted for KeePass as it was used for the code review of Apache Core & APR. 2.2.5 Detailed Results There were 14 controls with findings. Following are those categories and sub- categories with findings: • Error Handling/Information Leakage { Error Handling (1 info) • Logging/Auditing { Log Configuration Management (1 info) • Secure Code Design { Framework Requirements (1 low) { Variable types/operations (1 low) • Specific C Controls { Variable Management (1 medium, 1 low) { Memory management (1 medium) { Environment (1 medium) { Miscellaneous (1 medium) 7 • Specific C++ Controls { Variable Management (2 info) { Object-Oriented Programming (2 info) { Miscellaneous (1 medium) 2.2.6 Conclusion Again most of the findings were language specific.