<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jlaliberte</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jlaliberte"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Jlaliberte"/>
		<updated>2026-04-22T16:26:50Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Security_Code_Review_Coverage&amp;diff=23550</id>
		<title>Security Code Review Coverage</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Security_Code_Review_Coverage&amp;diff=23550"/>
				<updated>2007-11-19T18:25:33Z</updated>
		
		<summary type="html">&lt;p&gt;Jlaliberte: capitalization, spelling, rewording, spacing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[OWASP Code Review Guide Table of Contents]]__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Transactional Analysis: ==&lt;br /&gt;
&lt;br /&gt;
''“For every input there will be an equal and opposite output (Well sort of)”''&lt;br /&gt;
&lt;br /&gt;
A major part of actually performing a Secure Code inspection is performing a transactional analysis. An application takes inputs and produces output of some kind.&lt;br /&gt;
&lt;br /&gt;
All input to the code needs to be defined.&lt;br /&gt;
For example, input can come from:&lt;br /&gt;
* Browser input (HTTP)&lt;br /&gt;
* Cookies&lt;br /&gt;
* Other Entity  (machines/external processes).&lt;br /&gt;
* Property files&lt;br /&gt;
* ….&lt;br /&gt;
Input changes the state of an application. Attackers use input streams to attack applications. Would systems lacking an input mechanism be 100% secure?  Probably not.&lt;br /&gt;
&lt;br /&gt;
The input mechanisms, the path the input takes throughout the application, and the output based on the transformed input needs to be documented.&lt;br /&gt;
&lt;br /&gt;
Transactional analysis is of paramount importance when performing code inspection. Any input stream that is overlooked may be a potential door for an attacker.&lt;br /&gt;
&lt;br /&gt;
Transactional analysis includes any cookie or state information passed between the client and server and not just information inputted by the user, the payload.&lt;br /&gt;
&lt;br /&gt;
Take into account any potential errors that can occur in the application for a given input. Are the errors handled properly by the application?&lt;br /&gt;
&lt;br /&gt;
Transactional Analysis includes dynamic and static data flow analysis;&lt;br /&gt;
where and when variables are set, how the variable are used throughout the workflow, and how attributes of objects and parameters might affect other data within the program. Transactional analysis can help to determine if the parameters, method calls, and data exchange mechanisms implement the required security.&lt;br /&gt;
&lt;br /&gt;
All transactions within the application need to be identified and analyzed along with the relevant security functions they invoke.&lt;br /&gt;
The areas that are covered during transaction analysis are:&lt;br /&gt;
* Authentication &lt;br /&gt;
* Authorization&lt;br /&gt;
* Cookie Management&lt;br /&gt;
* Data/Input Validation from all external sources.&lt;br /&gt;
* Error Handling /Information Leakage&lt;br /&gt;
* Logging /Auditing&lt;br /&gt;
* Cryptography (Data at rest and in transit)&lt;br /&gt;
* Secure Code Environment&lt;br /&gt;
* Session Management (Login/Logout)&lt;br /&gt;
&lt;br /&gt;
== General principles (What to look for) ==&lt;br /&gt;
&lt;br /&gt;
For each of the areas above a reviewer must look at the following principles in the enforcement of the requirement:&lt;br /&gt;
&lt;br /&gt;
===Authentication: ===&lt;br /&gt;
&lt;br /&gt;
* Ensure all internal and external connections (user and entity) go through an appropriate and adequate form of authentication. Be assured that this control cannot be bypassed.&lt;br /&gt;
* Ensure all pages enforce the requirement for authentication.&lt;br /&gt;
* Ensure that whenever authentication credentials or any other sensitive information is passed, only accept the information via the HTTP “POST” method and will not accept it via the HTTP “GET” method.&lt;br /&gt;
* Any page deemed by the business or the development team as being outside the scope of authentication should be reviewed in order to assess any possibility of security breach.&lt;br /&gt;
* Ensure that authentication credentials do not traverse the wire in clear text form.&lt;br /&gt;
* Ensure development/debug backdoors are not present in production code.&lt;br /&gt;
&lt;br /&gt;
===Authorization: ===&lt;br /&gt;
&lt;br /&gt;
* Ensure that there are authorization mechanisms in place.&lt;br /&gt;
* Ensure that the application has clearly defined the user types and the rights of said users.&lt;br /&gt;
* Ensure there is a least privilege stance in operation.&lt;br /&gt;
* Ensure that the Authorization mechanisms work properly, fail securely, and cannot be circumvented.&lt;br /&gt;
* Ensure that authorization is checked on every request.&lt;br /&gt;
* Ensure development/debug backdoors are not present in production code.&lt;br /&gt;
&lt;br /&gt;
===Cookie Management: ===&lt;br /&gt;
&lt;br /&gt;
* Ensure that sensitive information is not compromised.&lt;br /&gt;
* Ensure that unauthorized activities cannot take place via cookie manipulation.&lt;br /&gt;
* Ensure that encryption is used properly.&lt;br /&gt;
* Ensure secure flag is set to prevent accidental transmission over “the wire” in a non-secure manner.&lt;br /&gt;
* Determine if all state transitions in the application code properly check for the cookies and enforce their use.&lt;br /&gt;
* Ensure the session data is being validated.&lt;br /&gt;
* Ensure cookie contains as little private information as possible.&lt;br /&gt;
* Ensure entire cookie should be encrypted if sensitive data is persisted in the cookie.&lt;br /&gt;
* Define all cookies being used by the application, their name and why they are needed.&lt;br /&gt;
&lt;br /&gt;
=== Data/Input Validation: ===&lt;br /&gt;
&lt;br /&gt;
* Ensure that a DV mechanism is present.&lt;br /&gt;
* Ensure all input that can (and will) be modified by a malicious user such as http headers, input fields, hidden fields, drop down lists &amp;amp; other web components are properly validated.&lt;br /&gt;
* Ensure that the proper length checks on all input exist.&lt;br /&gt;
* Ensure that all fields, cookies, http headers/bodies &amp;amp; form fields are validated.&lt;br /&gt;
* Ensure that the data is well formed and contains only known good chars is possible.&lt;br /&gt;
* Ensure that the data validation occurs on the server side.&lt;br /&gt;
* Examine where data validation occurs and if a centralized model or decentralized model is used.&lt;br /&gt;
* Ensure there are no backdoors in the data validation model.&lt;br /&gt;
* '''''Golden Rule: All external input, no matter what it is, is examined and validated.'''''&lt;br /&gt;
&lt;br /&gt;
===Error Handling/Information leakage: ===&lt;br /&gt;
&lt;br /&gt;
* Ensure that all method/function calls that return a value have proper error handling and return value checking.&lt;br /&gt;
* Ensure that exceptions and error conditions are properly handled.&lt;br /&gt;
* Ensure that no system errors can be returned to the user.&lt;br /&gt;
* Ensure that the application fails in a secure manner.&lt;br /&gt;
* Ensure resources are released if an error occurs.&lt;br /&gt;
&lt;br /&gt;
===Logging/Auditing: ===&lt;br /&gt;
&lt;br /&gt;
* Ensure that no sensitive information is logged in the event of an error.&lt;br /&gt;
* Ensure the payload being logged is of a defined maximum length and that the logging mechanism enforces that length.&lt;br /&gt;
* Ensure no sensitive data can be logged; E.g. cookies, HTTP “GET” method, authentication credentials.&lt;br /&gt;
* Examine if the application will audit the actions being taken by the application on behalf of the client particularly and data manipulation/Create, Update, Delete (CUD) operations.&lt;br /&gt;
* Ensure successful &amp;amp; unsuccessful authentication is logged.&lt;br /&gt;
* Ensure application errors are logged.&lt;br /&gt;
* Examine the application for debug logging with the view to logging of sensitive data.&lt;br /&gt;
&lt;br /&gt;
===Cryptography: ===&lt;br /&gt;
&lt;br /&gt;
* Ensure no sensitive data is transmitted in the clear, internally or externally.&lt;br /&gt;
* Ensure the application is implementing known good cryptographic algorithms. &lt;br /&gt;
&lt;br /&gt;
===Secure Code Environment: ===&lt;br /&gt;
&lt;br /&gt;
* Examine the file structure, are any components that should not be directly accessible available to the user.&lt;br /&gt;
* Examine all memory allocations/de-allocations.&lt;br /&gt;
* Examine the application for dynamic SQL and determine is vulnerable to injection.&lt;br /&gt;
* Examine the application for “main()” executable functions and debug harnesses/backdoors&lt;br /&gt;
* Search for commented out code, commented out test code, which may contain sensitive information.&lt;br /&gt;
* Ensure all logical decisions have a default clause.&lt;br /&gt;
* Ensure no development environment kit is contained on the build directories.&lt;br /&gt;
* Search for any calls to the underlying operating system or file open calls and examine the error possibilities.&lt;br /&gt;
&lt;br /&gt;
=== Session management: ===&lt;br /&gt;
&lt;br /&gt;
* Examine how and when a session is created for a user, unauthenticated and authenticated.&lt;br /&gt;
* Examine the session ID and verify is a complex enough to fulfill requirements regarding strength.&lt;br /&gt;
* Examine how sessions are stored: E.g. In a database, in memory etc.&lt;br /&gt;
* Examine how the application tracks sessions.&lt;br /&gt;
* Determine the actions the application takes if an invalid session ID occurs.&lt;br /&gt;
* Examine session invalidation.&lt;br /&gt;
* Determine how multithreaded/multi-user session management is performed.&lt;br /&gt;
* Determine the session HTTP inactivity timeout.&lt;br /&gt;
* Determine how the log-out functionality functions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Understand what you are reviewing: ==&lt;br /&gt;
&lt;br /&gt;
Many modern applications are developed on frameworks. These frameworks provide the developer less work to do as the framework does much of the “House Keeping”. So the objects developed by the development team shall extend the functionality of the framework. &lt;br /&gt;
&amp;lt;u&amp;gt;It is here that the knowledge of a given framework and language which the framework and application is implemented in is of paramount importance&amp;lt;/u&amp;gt;. Much of the transactional functionality may not be visible in the developers code and handled in “Parent” classes. &lt;br /&gt;
&lt;br /&gt;
The analyst must be aware and knowledgeable of the underlying framework&lt;br /&gt;
&lt;br /&gt;
'''For example:'''&lt;br /&gt;
&lt;br /&gt;
===Java: ===&lt;br /&gt;
In struts the ''struts-config.xml'' and the ''web.xml'' files are the core points to view the transactional functionality of an application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;ISO-8859-1&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE struts-config PUBLIC&lt;br /&gt;
          &amp;quot;-//Apache Software Foundation//DTD Struts Configuration 1.0//EN&amp;quot;&lt;br /&gt;
          &amp;quot;http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;struts-config&amp;gt;&lt;br /&gt;
  &amp;lt;!-- Form Bean Definitions  --&amp;gt;&lt;br /&gt;
  &amp;lt;form-beans&amp;gt;&lt;br /&gt;
  	&amp;lt;form-bean name=&amp;quot;login&amp;quot; type=&amp;quot;test.struts.LoginForm&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/form-beans&amp;gt;&lt;br /&gt;
  &amp;lt;!--  Global Forward Definitions  --&amp;gt;&lt;br /&gt;
  &amp;lt;global-forwards&amp;gt;&lt;br /&gt;
  &amp;lt;/global-forwards&amp;gt;&lt;br /&gt;
  &amp;lt;!--  Action Mapping Definitions  --&amp;gt;&lt;br /&gt;
  &amp;lt;action-mappings&amp;gt;&lt;br /&gt;
    &amp;lt;action&lt;br /&gt;
    	path=&amp;quot;/login&amp;quot;&lt;br /&gt;
    	type=&amp;quot;test.struts.LoginAction&amp;quot; &amp;gt;&lt;br /&gt;
	    &amp;lt;forward name=&amp;quot;valid&amp;quot; path=&amp;quot;/jsp/MainMenu.jsp&amp;quot; /&amp;gt;&lt;br /&gt;
	    &amp;lt;forward name=&amp;quot;invalid&amp;quot; path=&amp;quot;/jsp/LoginView.jsp&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/action&amp;gt;&lt;br /&gt;
  &amp;lt;/action-mappings&amp;gt;&lt;br /&gt;
 &amp;lt;!-- Validator Configuration --&amp;gt;&lt;br /&gt;
 &amp;lt;plug-in className=&amp;quot;org.apache.struts.validator.ValidatorPlugIn&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;set-property property=&amp;quot;pathnames&amp;quot;&lt;br /&gt;
 value=&amp;quot;/test/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/plug-in&amp;gt;&lt;br /&gt;
 &amp;lt;/struts-config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''struts-config.xml'' file contains the action mappings for each HTTP request while the ''web.xml'' file contains the deployment descriptor.&lt;br /&gt;
&lt;br /&gt;
'''Example''': The struts framework has a validator engine, which relies on regular expressions to validate the input data. The beauty of the validator is that no code has to be written for each form bean. (Form bean is the java object which received the data from the HTTP request) . The validator is not enabled by default in struts. To enable the validator a plug-in must be defined in the &amp;lt;plug-in&amp;gt; section of struts-config.xml in Red above. The property defined tells the struts framework where the custom validation rules are defined (validation.xml) and a definition of the actual rules themselves (validation-rules.xml).&lt;br /&gt;
&lt;br /&gt;
Without a proper understanding of the struts framework and by simply auditing the Java code one would not see any validation being executed and one does not see the relationship between the defined rules and the java functions.&lt;br /&gt;
&lt;br /&gt;
The action mappings in Blue define the action taken by the application upon receiving a request. Here, above we can see that when the URL contains /login the '''''LoginAction''''' shall be called. From the action mappings we can see the transactions the application performs when external input is received. &lt;br /&gt;
&lt;br /&gt;
===.NET: ===&lt;br /&gt;
ASP.NET/ IIS applications use an optional XML-based configuration file named ''web.config'', to maintain application configuration settings. This covers issues such as authentication, authorisation, Error pages, HTTP settings, debug settings, web service settings etc..&lt;br /&gt;
&lt;br /&gt;
Without knowledge of these files a transactional analysis would be very difficult and not accurate.&lt;br /&gt;
&lt;br /&gt;
Optionally, you may provide a file ''web.config'' at the root of the virtual directory for a Web application. If the file is absent, the default configuration settings in ''machine.config'' will be used. If the file is present, any settings in ''web.config'' will override the default settings.&lt;br /&gt;
&lt;br /&gt;
Example of the web.config file:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;authentication mode=&amp;quot;Forms&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;forms name=&amp;quot;name&amp;quot;&lt;br /&gt;
          loginUrl=&amp;quot;url&amp;quot; &lt;br /&gt;
          protection=&amp;quot;Encryption&amp;quot;&lt;br /&gt;
          timeout=&amp;quot;30&amp;quot; path=&amp;quot;/&amp;quot; &amp;gt;&lt;br /&gt;
          requireSSL=&amp;quot;true|&amp;quot;&lt;br /&gt;
          slidingExpiration=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;credentials passwordFormat=&amp;quot;Clear&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;user name=&amp;quot;username&amp;quot; password=&amp;quot;password&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/credentials&amp;gt;&lt;br /&gt;
   &amp;lt;/forms&amp;gt;&lt;br /&gt;
   &amp;lt;passport redirectUrl=&amp;quot;internal&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/authentication&amp;gt;&lt;br /&gt;
&lt;br /&gt;
OK so from this config file snippet we can see that:&lt;br /&gt;
&lt;br /&gt;
'''authentication mode''': The default authentication mode is  ASP.NET forms-based authentication.&lt;br /&gt;
&lt;br /&gt;
'''loginUrl: '''Specifies the URL where the request is redirected for logon if no valid authentication cookie is found.&lt;br /&gt;
&lt;br /&gt;
'''protection: '''Sepcifies that the cookie is encrypted using 3DES or DES but DV is not performed on the cookie. Beware of plaintext attacks!!&lt;br /&gt;
&lt;br /&gt;
'''timeout: '''Cookie expiry time in minutes&lt;br /&gt;
&lt;br /&gt;
The point to make here is that many of the important security settings are not set in the code per se but in the framework configuration files. &lt;br /&gt;
Knowledge of the framework is of paramount importance when reviewing framework-based applications.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;/div&gt;</summary>
		<author><name>Jlaliberte</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Security_Code_Review_in_the_SDLC&amp;diff=23549</id>
		<title>Security Code Review in the SDLC</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Security_Code_Review_in_the_SDLC&amp;diff=23549"/>
				<updated>2007-11-19T17:59:41Z</updated>
		
		<summary type="html">&lt;p&gt;Jlaliberte: capitalization, extra spaces, paren&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[OWASP Code Review Guide Table of Contents]]__TOC__&lt;br /&gt;
&lt;br /&gt;
==Preface==&lt;br /&gt;
&lt;br /&gt;
Code reviews vary widely in their level of formality.  Reviews can be as informal as inviting a friend to help look for a hard to find bug, and they can be as formal as a software inspection process with trained teams, assigned roles and responsibilities, and a formal metric and quality tracking program.&lt;br /&gt;
&lt;br /&gt;
In ''Peer Reviews in Software,'' Karl Wiegers lists seven review processes from least to most formal:&lt;br /&gt;
&lt;br /&gt;
# Ad hoc review&lt;br /&gt;
# Passaround&lt;br /&gt;
# Pair programming&lt;br /&gt;
# Walkthrough&lt;br /&gt;
# Team review&lt;br /&gt;
# Inspection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mature Secure Code Review (SCR) Model ==&lt;br /&gt;
&lt;br /&gt;
Throughout the SDLC there are points at which an application security consultant should get involved. These points, &amp;quot;touch points&amp;quot; can be used to investige the status of the code being developed from a security standpoint. The reason for interviening at regular intervals is that potential issues can be detected early on in the development life cycle and hence total cost of ownership (TCO) is less in the long term.&lt;br /&gt;
&lt;br /&gt;
'''Waterfall SDLC exmaple'''&lt;br /&gt;
# Requirements definition&lt;br /&gt;
## Functional specification&lt;br /&gt;
# Design&lt;br /&gt;
## Detailed design specification&lt;br /&gt;
# Development&lt;br /&gt;
## Coding&lt;br /&gt;
## Unit tests&lt;br /&gt;
# Test&lt;br /&gt;
## Functional testing&lt;br /&gt;
## System testing&lt;br /&gt;
## Integration testing&lt;br /&gt;
## UAT (User acceptance testing)&lt;br /&gt;
# Deployment&lt;br /&gt;
## Change control&lt;br /&gt;
# Maintenance&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Minimal Resource Available Code Review for Web Applications Model ==&lt;br /&gt;
&lt;br /&gt;
Very often, risk managers are tasked to manually code review large applications with minimal time and resources. This guide will focus on streamlining the manual code review process and outline the bare minimal essentials that are required for review.&lt;br /&gt;
&lt;br /&gt;
'''Manual Code Review should at LEAST focus on:'''&lt;br /&gt;
#Authorization&lt;br /&gt;
#Access Control&lt;br /&gt;
#Input Validation&lt;br /&gt;
#Error Handling&lt;br /&gt;
#Session Management&lt;br /&gt;
#Form Keys or Frequent Session Rotation (for CSRF defense)&lt;br /&gt;
#Proper Application Logging&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;/div&gt;</summary>
		<author><name>Jlaliberte</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Steps_and_Roles&amp;diff=23548</id>
		<title>Steps and Roles</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Steps_and_Roles&amp;diff=23548"/>
				<updated>2007-11-19T17:54:49Z</updated>
		
		<summary type="html">&lt;p&gt;Jlaliberte: spelling, paragraph spacing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[OWASP Code Review Guide Table of Contents]]__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Roles==&lt;br /&gt;
&lt;br /&gt;
Code reviews are carried out by personnel in four roles: author, moderator, reader, and scribe.  There are typically reviewers who are simply inspectors, focused on finding defects in the code, who do not fit in any of the four roles.  Depending on the size of your inspection team and the formality of your inspection process, some people may serve in multiple roles at the same time.  However, if you have a large enough team, it is useful to assign each role to a different person so each person can focus on their duties.&lt;br /&gt;
&lt;br /&gt;
#'''Moderator''': The Moderator is the key role in a code review.  The moderator is responsible for selecting a team of reviewers, scheduling the code review meeting, conducting the meeting, and working with the author to ensure that necessary corrections are made to the reviewed document.&lt;br /&gt;
&lt;br /&gt;
#'''Author''': The Author wrote the code that is being reviewed.  The author is responsible for starting the code review process by finding a Moderator.  The role of Author must be separated from that of Moderator, Reader, or Recorder to ensure the objectivity and effectiveness of the code review.  However, the Author serves an essential role in answering questions and making clarifications during the review and making corrections after the review.&lt;br /&gt;
&lt;br /&gt;
#'''Reader''': The Reader presents the code during the meeting by paraphrasing it in his own words.  It's important to separate the role of Reader from Author, because it's too easy for an author to explain what he meant the code to do instead of explaining what it actually does.  The reader's interpretation of the code can reveal ambiguities, hidden assumptions, poor documentation and style, and other errors that the Author would not be likely to catch on his own.&lt;br /&gt;
&lt;br /&gt;
#'''Scribe''': The Scribe records all issues raised during the code review.  Separating the role of Scribe from the other roles allows the other reviewers to focus their entire attention on the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Steps==&lt;br /&gt;
&lt;br /&gt;
Code reviews consist of the following four steps:&lt;br /&gt;
&lt;br /&gt;
#'''Initialization''': The Author informs a Moderator that a deliverable will be ready for inspection in the near future.  The Moderator selects a team of inspectors and assigns roles to them.  The Author and the Moderator together prepare a review package consisting of the code to be reviewed, documentation, review checklists, coding rules, and other materials such as the output of static analysis tools.  The Moderator will announce the time, place, and duration for the code review meeting.&lt;br /&gt;
&lt;br /&gt;
#'''Preparation''': After receiving the review package, the inspectors study the code individually to search for defects.  Preparation should take about as long as the duration of the meeting.  Some less formal code review techniques skip the preparation phase.&lt;br /&gt;
&lt;br /&gt;
#'''Meeting''': The Moderator initiates the meeting, then the Reader describes the code to the participants.  After each segment of code is presented, reviewers will bring up any issues they found during Preparation or discovered during the meeting.  The interaction between reviewers during the meeting will usually bring up issues that were not discovered during the Preparation step.  The Scribe notes each defect with enough detail for the Author to address it afterwards.  It is the responsibility of the Moderator to keep the meting focused on defects, ensuring that the participants do not attempt to produce solutions during the meeting instead.  Some less formal code review steps skip the meeting phase, choosing instead to e-mail the code to one or more reviewers who return comments without ever meeting as a group.&lt;br /&gt;
&lt;br /&gt;
#'''Corrections''': The Author addresses the defects recorded during the meeting, and the Moderator checks the corrections to ensure that all problems are resolved.  If the number of defects raised was large, the Moderator may decide to schedule a review of the revised code.&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;/div&gt;</summary>
		<author><name>Jlaliberte</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Code_Review_Introduction&amp;diff=23547</id>
		<title>Code Review Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Code_Review_Introduction&amp;diff=23547"/>
				<updated>2007-11-19T17:49:06Z</updated>
		
		<summary type="html">&lt;p&gt;Jlaliberte: spelling and other various corrections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[OWASP Code Review Guide Table of Contents]]__TOC__&lt;br /&gt;
&lt;br /&gt;
==Preface==&lt;br /&gt;
&lt;br /&gt;
This document is not a “How to perform a Secure Code review” walkthrough but more a guide on how to perform a successful review. Knowing the mechanics of code inspection is a half the battle but I’m afraid people is the other half.&lt;br /&gt;
&lt;br /&gt;
A proper code review will not only identify vulnerabilities, but will assess which vulnerabilities are at the greatest risk for exploitation.&lt;br /&gt;
&lt;br /&gt;
This document describes how to make the most of a secure code review.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The only possible way of developing secure software and keeping it secure going into the future is to make security part of the design. When cars are designed safety is considered and is now a big selling point for people buying a new car, “How safe is it?” would be a question a potential buyer may ask, also look at the advertising referring to the “Star” rating for safety a brand/model of car has.&lt;br /&gt;
&lt;br /&gt;
Unfortunately the software industry is not as evolved and hence people still buy software without paying any regard to the security aspect of the application.&lt;br /&gt;
&lt;br /&gt;
Every day more and more vulnerabilities are discovered in popular applications, which we all know and use and even use for private transactions over the web.&lt;br /&gt;
&lt;br /&gt;
I’m writing this document not from a puristic point of view. Not everything you may agree with but from experience it is rare that we can have the luxury of being a purist in the real world.&lt;br /&gt;
&lt;br /&gt;
Many forces in the business world do not see value in spending a proportion of the budget in security and factoring some security into the project timeline.&lt;br /&gt;
&lt;br /&gt;
The usual one liners we hear in the wilderness:&lt;br /&gt;
&lt;br /&gt;
  ''“We never get hacked (that I know of), we don’t need security” ''&lt;br /&gt;
&lt;br /&gt;
  ''“We never get hacked, we got a firewall”.''&lt;br /&gt;
&lt;br /&gt;
  ''Question: “How much does security cost”? Answer: “How much shall no security cost”?''&lt;br /&gt;
&lt;br /&gt;
  ''&amp;quot;Not to know is bad; not to wish to know is worse.&amp;quot;'' &lt;br /&gt;
&lt;br /&gt;
Code inspection is a fairly low-level approach to securing code but is very effective.&lt;br /&gt;
&lt;br /&gt;
==The Basics: What we know we don’t know and what we know we know. ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''&amp;quot;...we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns -- the ones we don't know we don't know''.&amp;quot;&lt;br /&gt;
&amp;lt;br&amp;gt; - Donald Rumsfeld.&lt;br /&gt;
===What is Secure Code Review? ===&lt;br /&gt;
&lt;br /&gt;
Secure code review is the process of auditing code for an application on a line by line basis for its security quality. Code review is a way of ensuring that the application is developed in an appropriate fashion so as to be “self defending” in its given environment.&lt;br /&gt;
&lt;br /&gt;
Secure Code review is a method of assuring secure application developers are following secure development techniques. A general rule of thumb is that a pen test should not discover any additional application vulnerabilities relating to the developed code after the application has undergone a proper secure code review. &lt;br /&gt;
&lt;br /&gt;
Secure code review is a manual process. It is labor intensive and not very scalable but it is accurate if performed by humans (and not tools, so far).&lt;br /&gt;
&lt;br /&gt;
Tools can be used to perform this task but they always need human verification. Tools do not understand context, which is the keystone of secure code review. Tools are good at assessing large amounts of code and pointing out possible issues but a person needs to verify every single result and also figure out the false positives and the false negatives.&lt;br /&gt;
&lt;br /&gt;
There are many source code review tool vendors. None have created a “silver bullet” at a reasonable cost. Vendor tools that are effective cost upwards around $60,000 USD per developer seat.&lt;br /&gt;
&lt;br /&gt;
Code review can be broken down into a number of discrete phases.&lt;br /&gt;
&lt;br /&gt;
# Discovery (Pre Transaction analysis).&lt;br /&gt;
# Transactional analysis.&lt;br /&gt;
# Post transaction analysis. &lt;br /&gt;
# Procedure peer review.&lt;br /&gt;
# Reporting &amp;amp; Presentation.&lt;br /&gt;
&lt;br /&gt;
===Laying the ground work ===&lt;br /&gt;
&lt;br /&gt;
(Ideally the reviewer should be involved in the design phase of the application, but this is not always possible so we assume the reviewer was not.)&lt;br /&gt;
&lt;br /&gt;
There are two scenarios to look at.&lt;br /&gt;
&lt;br /&gt;
# The security consultant was involved since project inception and has guided and helped integrate security into the SDLC.&lt;br /&gt;
# The security consultant is brought into the project near project end and is presented with a mountain of code, has no insight into the design, functionality or business requirements.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
So we’ve got 100K lines of code for secure code inspection, how do we handle this?&lt;br /&gt;
&lt;br /&gt;
The most important step is collaboration with developers. Obtaining information from the developers is the most efficient method for performing an accurate code review.&lt;br /&gt;
&lt;br /&gt;
Performing code review can feel like an audit, and everybody hates being audited. The way to approach this is to create an atmosphere of collaboration between the reviewer, the development team and any stakeholders. Portraying an image of an advisor and not a policeman is very important if you wish to get full co-operation from the development team.&lt;br /&gt;
&lt;br /&gt;
“''Help me help you''” is the approach and ideal that needs to be communicated.&lt;br /&gt;
&lt;br /&gt;
===Discovery: Gathering the information ===&lt;br /&gt;
&lt;br /&gt;
As mentioned above talking to developers is arguably the most accurate and the quickest way of gaining insight into the application. &lt;br /&gt;
&lt;br /&gt;
A culture of collaboration between the security analyst and the development team is important to establish.&lt;br /&gt;
&lt;br /&gt;
Design documents, business requirements, functional specifications, and any other documentation relating to the code being reviewed can be helpful.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Before we start:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The reviewer(s) need to be familiar with:&lt;br /&gt;
# '''Code''': The language used, the features and issues of that language from a security perspective. The issues one needs to look out for and best practices from a security and performance perspective.&lt;br /&gt;
# '''Context''': They need to be familiar with the application being reviewed. All security is in context of what we are trying to secure. Recommending military standard security mechanisms on an application that vends apples would be over-kill, and out of context. What type of data is being manipulated or processed and what would the damage to the company be if this data was compromised. Context is the “''Holy Grail''” of secure code inspection and risk assessment…we’ll see more later.&lt;br /&gt;
# '''Audience''': From 2 (above) we need to know the users of the application, is it externally facing or internal to “Trusted” users.  Does this application talk to other entities (machines/services)? Do humans use this application?&lt;br /&gt;
# '''Importance''': The availability of the application is also important. Shall the enterprise be affected in any great way if the application is “bounced” or shut down for a significant or insignificant amount of time?&lt;br /&gt;
&lt;br /&gt;
===Context, Context, Context ===&lt;br /&gt;
&lt;br /&gt;
The context in which the application is intended to operate is a very important issue in establishing potential risk. &lt;br /&gt;
&lt;br /&gt;
Defining context should provide us with the following information:&lt;br /&gt;
*Establish the importance of the application to the enterprise.&lt;br /&gt;
*Establish the boundaries of the application context.&lt;br /&gt;
*Establish the trust relationships between entities.&lt;br /&gt;
*Establish potential threats and possible countermeasures.&lt;br /&gt;
&lt;br /&gt;
So we can establish something akin to a threat model. Take into account where our application sits, what it's expected to do and who uses it.&lt;br /&gt;
&lt;br /&gt;
Simple questions like:&lt;br /&gt;
&lt;br /&gt;
“'''''What type/how sensitive is the data/asset contained in the application?'''''”:&lt;br /&gt;
&lt;br /&gt;
This is a keystone to security and assessing possible risk to the application. How desirable is the information? What effect would it have on the enterprise if the information were compromised in any way?&lt;br /&gt;
&lt;br /&gt;
“'''''Is the application internal or external facing?'''''”, “'''''Who uses the application; are they trusted users?'''”''&lt;br /&gt;
&lt;br /&gt;
This is a bit of a false sense of security as attacks take place by internal/trusted users more often than is acknowledged. It does give us context that the application ''should'' be limited to a finite number of identified users but its not a guarantee that these users shall all behave properly.&lt;br /&gt;
&lt;br /&gt;
''“'''Where does the application host sit'''?”''&lt;br /&gt;
&lt;br /&gt;
Users should not be allowed past the DMZ into the LAN without being authenticated. Internal users also need to be authenticated. No authentication = no accountability and a weak audit trail.&lt;br /&gt;
&lt;br /&gt;
If there are internal and external users, what are the differences from a security standpoint? How do we identify one from another. How does authorisation work?&lt;br /&gt;
&lt;br /&gt;
“'''''How important is this application to the enterprise?'''''”.&lt;br /&gt;
&lt;br /&gt;
Is the application of minor significance or a Tier A / Mission critical application, without which the enterprise would fail? Any good web application development policy would have additional requirements for different applications of differing importance to the enterprise. It would be the analyst’s job to ensure the policy was followed from a code perspective also.&lt;br /&gt;
&lt;br /&gt;
A useful approach is to present the team with a checklist, which asks the relevant, questions pertaining to any web application.&lt;br /&gt;
&lt;br /&gt;
===The Checklist ===&lt;br /&gt;
&lt;br /&gt;
Defining a generic checklist which can be filled out by the development team is of high value is the checklist asks the correct questions in order to give us context. The checklist should cover the “Usual Suspects” in application security such as:&lt;br /&gt;
&lt;br /&gt;
* Authentication&lt;br /&gt;
* Authorization&lt;br /&gt;
* Data Validation (a''nother “holy grail”'')&lt;br /&gt;
* Session management&lt;br /&gt;
* Logging&lt;br /&gt;
* Error handling&lt;br /&gt;
* Cryptography&lt;br /&gt;
* Topology (where is this app in the network context).&lt;br /&gt;
&lt;br /&gt;
An example can be found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;http://www.nemozzang.com/pub/Guide%20Line/OWASP/designreviewchecklist.doc&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The checklist is a good barometer for the level of security the developers have attempted or thought of.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;/div&gt;</summary>
		<author><name>Jlaliberte</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Code_Review_Introduction&amp;diff=23546</id>
		<title>Code Review Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Code_Review_Introduction&amp;diff=23546"/>
				<updated>2007-11-19T17:33:28Z</updated>
		
		<summary type="html">&lt;p&gt;Jlaliberte: cleanup preface paragraphs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[OWASP Code Review Guide Table of Contents]]__TOC__&lt;br /&gt;
&lt;br /&gt;
==Preface==&lt;br /&gt;
&lt;br /&gt;
This document is not a “How to perform a Secure Code review” walkthrough but more a guide on how to perform a successful review. Knowing the mechanics of code inspection is a half the battle but I’m afraid people is the other half.&lt;br /&gt;
&lt;br /&gt;
A proper code review will not only identify vulnerabilities, but will assess which vulnerabilities are at the greatest risk for exploitation.&lt;br /&gt;
&lt;br /&gt;
This document describes how to make the most of a secure code review.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The only possible way of developing secure software and keeping it secure going into the future is to make security part of the design. When cars are designed safety is considered and is now a big selling point for people buying a new car, “How safe is it?” would be a question a potential buyer may ask, also look at the advertising referring to the “Star” rating for safety a brand/model of car has.&lt;br /&gt;
&lt;br /&gt;
Unfortunately the software industry is not as evolved and hence people still buy software without paying any regard to the security aspect of the application.&lt;br /&gt;
&lt;br /&gt;
Every day more and more vulnerabilities are discovered in popular applications, which we all know and use and even use for private transactions over the web.&lt;br /&gt;
&lt;br /&gt;
I’m writing this document not from a puristic point of view. Not everything you may agree with but from experience it is rare that we can have the luxury of being a purist in the real world.&lt;br /&gt;
&lt;br /&gt;
Many forces in the business world do not see value in spending a proportion of the budget in security and factoring some security into the project timeline.&lt;br /&gt;
&lt;br /&gt;
The usual one liners we hear in the wilderness:&lt;br /&gt;
&lt;br /&gt;
  ''“We never get hacked (that I know of), we don’t need security” ''&lt;br /&gt;
&lt;br /&gt;
  ''“We never get hacked, we got a firewall”.''&lt;br /&gt;
&lt;br /&gt;
  ''Question: “How much does security cost”? Answer: “How much shall no security cost”?''&lt;br /&gt;
&lt;br /&gt;
  ''&amp;quot;Not to know is bad; not to wish to know is worse.&amp;quot;'' &lt;br /&gt;
&lt;br /&gt;
Code inspection is a fairly low-level approach to securing code but is very effective.&lt;br /&gt;
&lt;br /&gt;
==The Basics: What we know we don’t know and what we know we know. ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''&amp;quot;...we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns -- the ones we don't know we don't know''.&amp;quot;&lt;br /&gt;
&amp;lt;br&amp;gt; - Donald Rumsfeld.&lt;br /&gt;
===What is Secure Code Review? ===&lt;br /&gt;
&lt;br /&gt;
Secure code review is the process of auditing code for an application on a line by line basis for its security quality. Code review is a way of ensuring that the application is developed in an appropriate fashion so as to be “self defending” in its given environment.&lt;br /&gt;
&lt;br /&gt;
Secure Code review is a method of assuring secure application developers are following secure development techniques. A general rule of thumb is that a pen test should not discover any additional application vulnerabilities relating to the developed code after the application has undergone a proper secure code review. &lt;br /&gt;
&lt;br /&gt;
Secure code review is a manual process. It is labour intensive and not very scalable but it is accurate if performed by humans (and not tools, so far).&lt;br /&gt;
&lt;br /&gt;
Tools can be used to perform this task but they always need human verification. Tools do not understand context, which is the keystone of secure code review. Tools are good at assessing large amounts of code and pointing out possible issues but a person needs to verify every single result and also figure out the false positives and worse again the false negatives.&lt;br /&gt;
&lt;br /&gt;
There are many source code review tool vendors. None have created a “silver bullet” at a reasonable cost. Vendor tools that are effective cost upwards around $60,000 USD per developer seat.&lt;br /&gt;
&lt;br /&gt;
Code review can be broken down into a number of discrete phases.&lt;br /&gt;
&lt;br /&gt;
# Discovery (Pre Transaction analysis).&lt;br /&gt;
# Transactional analysis.&lt;br /&gt;
# Post transaction analysis. &lt;br /&gt;
# Procedure peer review.&lt;br /&gt;
# Reporting &amp;amp; Presentation.&lt;br /&gt;
&lt;br /&gt;
===Laying the ground work ===&lt;br /&gt;
&lt;br /&gt;
(Ideally the reviewer should be involved in the design phase of the application, but this is not always possible so we assume the reviewer was not.)&lt;br /&gt;
&lt;br /&gt;
There are two scenarios to look at.&lt;br /&gt;
&lt;br /&gt;
# The security consultant was involved since project inception and has guided and helped integrate security into the SDLC.&lt;br /&gt;
# The security consultant is brought into the project near project end and is presented with a mountain of code, has no insight into the design, functionality or business requirements.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
So we’ve got 100K lines of code for secure code inspection, how do we handle this?&lt;br /&gt;
&lt;br /&gt;
The most important step is collaboration with developers. Obtaining information from the developers is the most time saving method for performing an accurate code review in a timely manner.&lt;br /&gt;
&lt;br /&gt;
Performing code review can feel like an audit, and everybody hates being audited. The way to approach this is to create an atmosphere of collaboration between the reviewer, the development team &amp;amp; vested interests. Portraying an image of an advisor and not a policeman is very important if you wish to get full co-operation from the development team.&lt;br /&gt;
&lt;br /&gt;
“''Help me help you''” is the approach and ideal that needs to be communicated.&lt;br /&gt;
&lt;br /&gt;
===Discovery: Gathering the information ===&lt;br /&gt;
&lt;br /&gt;
As mentioned above talking to developers is arguably the most accurate and definitely the quickest way of gaining insight into the application. &lt;br /&gt;
&lt;br /&gt;
A culture of collaboration between the security analyst and the development team is important to establish.&lt;br /&gt;
&lt;br /&gt;
Other artifacts required would be design documents, business requirements, functional specifications and any other relating information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Before we start:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The reviewer(s) need to be familiar with:&lt;br /&gt;
# '''Code''': The language used, the features and issues of that language from a security perspective. The issues one needs to look out for and best practices from a security and performance perspective.&lt;br /&gt;
# '''Context''': They need to be familiar with the application being reviewed. All security is in context of what we are trying to secure. Recommending military standard security mechanisms on an application that vends apples would be over-kill, and out of context. What type of data is being manipulated or processed and what would the damage to the company be if this data was compromised. Context is the “''Holy Grail''” of secure code inspection and risk assessment…we’ll see more later.&lt;br /&gt;
# '''Audience''': From 2 (above) we need to know the users of the application, is it externally facing or internal to “Trusted” users.  Does this application talk to other entities (machines/services)? Do humans use this application?&lt;br /&gt;
# '''Importance''': The availability of the application is also important. Shall the enterprise be affected in any great way if the application is “bounced” or shut down for a significant or insignificant amount of time?&lt;br /&gt;
&lt;br /&gt;
===Context, Context, Context ===&lt;br /&gt;
&lt;br /&gt;
The context in which the application is intended to operate is a very important issue in establishing potential risk. &lt;br /&gt;
&lt;br /&gt;
Defining context should provide us with the following information:&lt;br /&gt;
*Establish the importance of application to enterprise.&lt;br /&gt;
*Establish the boundaries of the application context.&lt;br /&gt;
*Establish the trust relationships between entities.&lt;br /&gt;
*Establish potential threats and possible countermeasures.&lt;br /&gt;
&lt;br /&gt;
So we can establish something akin to a threat model. Take into account where our application sits, what it's expected to do and who uses it.&lt;br /&gt;
&lt;br /&gt;
Simple questions like:&lt;br /&gt;
&lt;br /&gt;
“'''''What type/how sensitive is the data/asset contained in the application?'''''”:&lt;br /&gt;
&lt;br /&gt;
This is a keystone to security and assessing possible risk to the application. How desirable is the information? What effect would it have on the enterprise if the information were compromised in any way?&lt;br /&gt;
&lt;br /&gt;
“'''''Is the application internal or external facing?'''''”, “'''''Who uses the application; are they trusted users?'''”''&lt;br /&gt;
&lt;br /&gt;
This is a bit of a false sense of security as attacks take place by internal/trusted users more often than is acknowledged. It does give us context that the application ''should'' be limited to a finite number of identified users but its not a guarantee that these users shall all behave properly.&lt;br /&gt;
&lt;br /&gt;
''“'''Where does the application host sit'''?”''&lt;br /&gt;
&lt;br /&gt;
Users should not be allowed past the DMZ into the LAN without being authenticated. Internal users also need to be authenticated. No authentication = no accountability and a weak audit trail.&lt;br /&gt;
&lt;br /&gt;
If there are internal and external users, what are the differences from a security standpoint? How do we identify one from another. How does authorisation work?&lt;br /&gt;
&lt;br /&gt;
“'''''How important is this application to the enterprise?'''''”.&lt;br /&gt;
&lt;br /&gt;
Is the application of minor significance or a Tier A / Mission critical application, without which the enterprise would fail? Any good web application development policy would have additional requirements for different applications of differing importance to the enterprise. It would be the analyst’s job to ensure the policy was followed from a code perspective also.&lt;br /&gt;
&lt;br /&gt;
A useful approach is to present the team with a checklist, which asks the relevant, questions pertaining to any web application.&lt;br /&gt;
&lt;br /&gt;
===The Checklist ===&lt;br /&gt;
&lt;br /&gt;
Defining a generic checklist which can be filled out by the development team is of high value is the checklist asks the correct questions in order to give us context. The checklist should cover the “Usual Suspects” in application security such as:&lt;br /&gt;
&lt;br /&gt;
* Authentication&lt;br /&gt;
* Authorization&lt;br /&gt;
* Data Validation (a''nother “holy grail”'')&lt;br /&gt;
* Session management&lt;br /&gt;
* Logging&lt;br /&gt;
* Error handling&lt;br /&gt;
* Cryptography&lt;br /&gt;
* Topology (where is this app in the network context).&lt;br /&gt;
&lt;br /&gt;
An example can be found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;http://www.nemozzang.com/pub/Guide%20Line/OWASP/designreviewchecklist.doc&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The checklist is a good barometer for the level of security the developers have attempted or thought of.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;/div&gt;</summary>
		<author><name>Jlaliberte</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Code_Review_Introduction&amp;diff=23544</id>
		<title>Code Review Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Code_Review_Introduction&amp;diff=23544"/>
				<updated>2007-11-19T17:20:28Z</updated>
		
		<summary type="html">&lt;p&gt;Jlaliberte: capitalization error&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[OWASP Code Review Guide Table of Contents]]__TOC__&lt;br /&gt;
&lt;br /&gt;
==Preface==&lt;br /&gt;
&lt;br /&gt;
This document is not a “How to perform a Secure Code review” walkthrough but more a guide on how to perform a successful review. Knowing the mechanics of code inspection is a half the battle but I’m afraid people is the other half.&lt;br /&gt;
&lt;br /&gt;
To perform a proper code review, to give value to the client from a risk perspective and not from an academic or text book perspective we must understand what we are reviewing. &lt;br /&gt;
&lt;br /&gt;
Applications may have faults but the client wants to know the “real risk” and not necessarily what the security textbooks say. &lt;br /&gt;
&lt;br /&gt;
Albeit there are real vulnerabilities in real applications out there and they pose real risk but how do we define real risk as opposed to best practice?&lt;br /&gt;
&lt;br /&gt;
This document describes how to get the most out of a secure code review. What is important when managing an engagement with a client and how to keep your eye on the ball the see the “wood from the trees”.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The only possible way of developing secure software and keeping it secure going into the future is to make security part of the design. When cars are designed safety is considered and is now a big selling point for people buying a new car, “How safe is it?” would be a question a potential buyer may ask, also look at the advertising referring to the “Star” rating for safety a brand/model of car has.&lt;br /&gt;
&lt;br /&gt;
Unfortunately the software industry is not as evolved and hence people still buy software without paying any regard to the security aspect of the application.&lt;br /&gt;
&lt;br /&gt;
Every day more and more vulnerabilities are discovered in popular applications, which we all know and use and even use for private transactions over the web.&lt;br /&gt;
&lt;br /&gt;
I’m writing this document not from a puristic point of view. Not everything you may agree with but from experience it is rare that we can have the luxury of being a purist in the real world.&lt;br /&gt;
&lt;br /&gt;
Many forces in the business world do not see value in spending a proportion of the budget in security and factoring some security into the project timeline.&lt;br /&gt;
&lt;br /&gt;
The usual one liners we hear in the wilderness:&lt;br /&gt;
&lt;br /&gt;
  ''“We never get hacked (that I know of), we don’t need security” ''&lt;br /&gt;
&lt;br /&gt;
  ''“We never get hacked, we got a firewall”.''&lt;br /&gt;
&lt;br /&gt;
  ''Question: “How much does security cost”? Answer: “How much shall no security cost”?''&lt;br /&gt;
&lt;br /&gt;
  ''&amp;quot;Not to know is bad; not to wish to know is worse.&amp;quot;'' &lt;br /&gt;
&lt;br /&gt;
Code inspection is a fairly low-level approach to securing code but is very effective.&lt;br /&gt;
&lt;br /&gt;
==The Basics: What we know we don’t know and what we know we know. ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
''&amp;quot;...we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns -- the ones we don't know we don't know''.&amp;quot;&lt;br /&gt;
&amp;lt;br&amp;gt; - Donald Rumsfeld.&lt;br /&gt;
===What is Secure Code Review? ===&lt;br /&gt;
&lt;br /&gt;
Secure code review is the process of auditing code for an application on a line by line basis for its security quality. Code review is a way of ensuring that the application is developed in an appropriate fashion so as to be “self defending” in its given environment.&lt;br /&gt;
&lt;br /&gt;
Secure Code review is a method of assuring secure application developers are following secure development techniques. A general rule of thumb is that a pen test should not discover any additional application vulnerabilities relating to the developed code after the application has undergone a proper secure code review. &lt;br /&gt;
&lt;br /&gt;
Secure code review is a manual process. It is labour intensive and not very scalable but it is accurate if performed by humans (and not tools, so far).&lt;br /&gt;
&lt;br /&gt;
Tools can be used to perform this task but they always need human verification. Tools do not understand context, which is the keystone of secure code review. Tools are good at assessing large amounts of code and pointing out possible issues but a person needs to verify every single result and also figure out the false positives and worse again the false negatives.&lt;br /&gt;
&lt;br /&gt;
There are many source code review tool vendors. None have created a “silver bullet” at a reasonable cost. Vendor tools that are effective cost upwards around $60,000 USD per developer seat.&lt;br /&gt;
&lt;br /&gt;
Code review can be broken down into a number of discrete phases.&lt;br /&gt;
&lt;br /&gt;
# Discovery (Pre Transaction analysis).&lt;br /&gt;
# Transactional analysis.&lt;br /&gt;
# Post transaction analysis. &lt;br /&gt;
# Procedure peer review.&lt;br /&gt;
# Reporting &amp;amp; Presentation.&lt;br /&gt;
&lt;br /&gt;
===Laying the ground work ===&lt;br /&gt;
&lt;br /&gt;
(Ideally the reviewer should be involved in the design phase of the application, but this is not always possible so we assume the reviewer was not.)&lt;br /&gt;
&lt;br /&gt;
There are two scenarios to look at.&lt;br /&gt;
&lt;br /&gt;
# The security consultant was involved since project inception and has guided and helped integrate security into the SDLC.&lt;br /&gt;
# The security consultant is brought into the project near project end and is presented with a mountain of code, has no insight into the design, functionality or business requirements.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
So we’ve got 100K lines of code for secure code inspection, how do we handle this?&lt;br /&gt;
&lt;br /&gt;
The most important step is collaboration with developers. Obtaining information from the developers is the most time saving method for performing an accurate code review in a timely manner.&lt;br /&gt;
&lt;br /&gt;
Performing code review can feel like an audit, and everybody hates being audited. The way to approach this is to create an atmosphere of collaboration between the reviewer, the development team &amp;amp; vested interests. Portraying an image of an advisor and not a policeman is very important if you wish to get full co-operation from the development team.&lt;br /&gt;
&lt;br /&gt;
“''Help me help you''” is the approach and ideal that needs to be communicated.&lt;br /&gt;
&lt;br /&gt;
===Discovery: Gathering the information ===&lt;br /&gt;
&lt;br /&gt;
As mentioned above talking to developers is arguably the most accurate and definitely the quickest way of gaining insight into the application. &lt;br /&gt;
&lt;br /&gt;
A culture of collaboration between the security analyst and the development team is important to establish.&lt;br /&gt;
&lt;br /&gt;
Other artifacts required would be design documents, business requirements, functional specifications and any other relating information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Before we start:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The reviewer(s) need to be familiar with:&lt;br /&gt;
# '''Code''': The language used, the features and issues of that language from a security perspective. The issues one needs to look out for and best practices from a security and performance perspective.&lt;br /&gt;
# '''Context''': They need to be familiar with the application being reviewed. All security is in context of what we are trying to secure. Recommending military standard security mechanisms on an application that vends apples would be over-kill, and out of context. What type of data is being manipulated or processed and what would the damage to the company be if this data was compromised. Context is the “''Holy Grail''” of secure code inspection and risk assessment…we’ll see more later.&lt;br /&gt;
# '''Audience''': From 2 (above) we need to know the users of the application, is it externally facing or internal to “Trusted” users.  Does this application talk to other entities (machines/services)? Do humans use this application?&lt;br /&gt;
# '''Importance''': The availability of the application is also important. Shall the enterprise be affected in any great way if the application is “bounced” or shut down for a significant or insignificant amount of time?&lt;br /&gt;
&lt;br /&gt;
===Context, Context, Context ===&lt;br /&gt;
&lt;br /&gt;
The context in which the application is intended to operate is a very important issue in establishing potential risk. &lt;br /&gt;
&lt;br /&gt;
Defining context should provide us with the following information:&lt;br /&gt;
*Establish the importance of application to enterprise.&lt;br /&gt;
*Establish the boundaries of the application context.&lt;br /&gt;
*Establish the trust relationships between entities.&lt;br /&gt;
*Establish potential threats and possible countermeasures.&lt;br /&gt;
&lt;br /&gt;
So we can establish something akin to a threat model. Take into account where our application sits, what it's expected to do and who uses it.&lt;br /&gt;
&lt;br /&gt;
Simple questions like:&lt;br /&gt;
&lt;br /&gt;
“'''''What type/how sensitive is the data/asset contained in the application?'''''”:&lt;br /&gt;
&lt;br /&gt;
This is a keystone to security and assessing possible risk to the application. How desirable is the information? What effect would it have on the enterprise if the information were compromised in any way?&lt;br /&gt;
&lt;br /&gt;
“'''''Is the application internal or external facing?'''''”, “'''''Who uses the application; are they trusted users?'''”''&lt;br /&gt;
&lt;br /&gt;
This is a bit of a false sense of security as attacks take place by internal/trusted users more often than is acknowledged. It does give us context that the application ''should'' be limited to a finite number of identified users but its not a guarantee that these users shall all behave properly.&lt;br /&gt;
&lt;br /&gt;
''“'''Where does the application host sit'''?”''&lt;br /&gt;
&lt;br /&gt;
Users should not be allowed past the DMZ into the LAN without being authenticated. Internal users also need to be authenticated. No authentication = no accountability and a weak audit trail.&lt;br /&gt;
&lt;br /&gt;
If there are internal and external users, what are the differences from a security standpoint? How do we identify one from another. How does authorisation work?&lt;br /&gt;
&lt;br /&gt;
“'''''How important is this application to the enterprise?'''''”.&lt;br /&gt;
&lt;br /&gt;
Is the application of minor significance or a Tier A / Mission critical application, without which the enterprise would fail? Any good web application development policy would have additional requirements for different applications of differing importance to the enterprise. It would be the analyst’s job to ensure the policy was followed from a code perspective also.&lt;br /&gt;
&lt;br /&gt;
A useful approach is to present the team with a checklist, which asks the relevant, questions pertaining to any web application.&lt;br /&gt;
&lt;br /&gt;
===The Checklist ===&lt;br /&gt;
&lt;br /&gt;
Defining a generic checklist which can be filled out by the development team is of high value is the checklist asks the correct questions in order to give us context. The checklist should cover the “Usual Suspects” in application security such as:&lt;br /&gt;
&lt;br /&gt;
* Authentication&lt;br /&gt;
* Authorization&lt;br /&gt;
* Data Validation (a''nother “holy grail”'')&lt;br /&gt;
* Session management&lt;br /&gt;
* Logging&lt;br /&gt;
* Error handling&lt;br /&gt;
* Cryptography&lt;br /&gt;
* Topology (where is this app in the network context).&lt;br /&gt;
&lt;br /&gt;
An example can be found:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;http://www.nemozzang.com/pub/Guide%20Line/OWASP/designreviewchecklist.doc&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The checklist is a good barometer for the level of security the developers have attempted or thought of.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;/div&gt;</summary>
		<author><name>Jlaliberte</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Code_Review_Guide_Foreword&amp;diff=23543</id>
		<title>Code Review Guide Foreword</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Code_Review_Guide_Foreword&amp;diff=23543"/>
				<updated>2007-11-19T17:10:29Z</updated>
		
		<summary type="html">&lt;p&gt;Jlaliberte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Foreword by [[User:Jeff Williams|Jeff Williams]], OWASP Chair==&lt;br /&gt;
&lt;br /&gt;
Many organizations have realized that their code is not as secure as they may have thought. Now they're starting the difficult work of verifying the security of their applications. There are four basic techniques for analyzing code - automated scanning, manual penetration testing, static analysis, and manual code review.&lt;br /&gt;
&lt;br /&gt;
This OWASP Guide is focused on the last of these techniques. Of course, all of these techniques have their strengths, weaknesses, sweet spots, and blind spots.  Arguments about which technique is the best are like arguing whether a hammer or saw is more valuable when building a house. If you try to build a house with just a hammer, you'll do a terrible job.&lt;br /&gt;
&lt;br /&gt;
==Why Code Review?==&lt;br /&gt;
&lt;br /&gt;
Despite the many claims that code review is too expensive or time consuming, there is no question that it is the fastest and most accurate way to find and diagnose many security problems.  There are also dozens of security problems that simply can't be found any other way.&lt;br /&gt;
&lt;br /&gt;
Code review is also that only way to verify that security has been implemented correctly. By checking the code&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
==Getting Started==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
==OWASP Guides==&lt;br /&gt;
&lt;br /&gt;
The OWASP guides are intended to teach you how to use these techniques. But the fact that they are separate shouldn't be an indicator that they should be used alone. The [[Building Guide]] shows your project how to architect and build a secure application, this [[Code Review Guide]] tells you how to verify the security of your application's source code, and the [[Testing Guide]] shows you how to verify the security of your running application.&lt;br /&gt;
&lt;br /&gt;
Security moves too fast for traditional books to be of much use. But OWASP's collaborative environment allows us to keep up to date. There are hundreds of contributors to the OWASP Guides and we make over a thousand updates to our materials every month. We're committed to making high quality application security materials available to everyone. It's the only way we'll ever make any real progress on application security as a software community.&lt;br /&gt;
&lt;br /&gt;
==Call to Action==&lt;br /&gt;
&lt;br /&gt;
If you're building software, I strongly encourage you to get familiar with the security guidance in this document. If you find errors, please add a note to the discussion page or make the change yourself. You'll be helping thousands of others who use this guide.&lt;br /&gt;
&lt;br /&gt;
Please consider [[Membership|joining us]] as an individual or corporate member so that we can continue to produce materials like this code review guide and all the other great projects at OWASP.&lt;br /&gt;
&lt;br /&gt;
Thank you to all the past and future contributors to this guide, your work will help to make applications worldwide more secure.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jeff Williams|Jeff Williams]], OWASP Chair, October 17, 2007&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;/div&gt;</summary>
		<author><name>Jlaliberte</name></author>	</entry>

	</feed>