<?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=Cwells</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=Cwells"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Cwells"/>
		<updated>2026-05-22T03:36:40Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Cwells&amp;diff=78274</id>
		<title>User:Cwells</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Cwells&amp;diff=78274"/>
				<updated>2010-02-11T20:24:37Z</updated>
		
		<summary type="html">&lt;p&gt;Cwells: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Chris Wells wants to elevate the awareness of application security issues by teaching and encouraging developers to build applications that can defend themselves against the serious types of threats that exist on the Internet today.  &lt;br /&gt;
&lt;br /&gt;
Over his career, Chris has deployed security solutions for major healthcare, telecommunication, and financial industries, and is currently employed as an Information Security Architect for a major manufacturing company.  He is an accomplished application security architect with over 10 years of application security experience.  &lt;br /&gt;
&lt;br /&gt;
Chris holds multiple security certifications including a Certified Information Security Systems Professional (CISSP), and holds a Bachelor degree from the University of Minnesota.&lt;/div&gt;</summary>
		<author><name>Cwells</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=19699</id>
		<title>Searching for Code in J2EE/Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=19699"/>
				<updated>2007-07-10T15:26:10Z</updated>
		
		<summary type="html">&lt;p&gt;Cwells: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Searching for key indicators ==&lt;br /&gt;
The basis of the code review is to locate and analyse areas of code which may have application security implications.&lt;br /&gt;
Assuming the code reviewer has a thorough understanding of the code, what it is intended to do and the context upon which it is to be used, firstly one needs to sweep the code base for areas of interest.&lt;br /&gt;
&lt;br /&gt;
This can be done by performing a text search on the code base looking for keywords relating to API's and functions.&lt;br /&gt;
Below is a guide for .NET framework 1.1 &amp;amp; 2.0&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in .NET ===&lt;br /&gt;
&lt;br /&gt;
Firstly one needs to be familiar with the tools one can use in order to perform text searching following on from this one need to know what to look for.&lt;br /&gt;
 &lt;br /&gt;
In this section we will assume you have a copy of Visual Studio (VS) .NET at hand. VS has two types of search &amp;quot;'''Find in Files'''&amp;quot; and a cmd line tool called '''Findstr'''&lt;br /&gt;
  &lt;br /&gt;
The test search tools in XP is not great in my experience and if one has to use this make sure SP2 in installed as it works better.&lt;br /&gt;
To start off one should scan thorough the code looking for common patterns or keywords such as &amp;quot;User&amp;quot;, &amp;quot;Password&amp;quot;, &amp;quot;Pswd&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Http&amp;quot;, etc...&lt;br /&gt;
This can be done using the &amp;quot;Find in Files&amp;quot; tool in VS or using findstring as follows:&lt;br /&gt;
 &lt;br /&gt;
[Find In Files HERE]&lt;br /&gt;
&lt;br /&gt;
 '''findstr /s /m /i /d:c:\projects\codebase\sec &amp;quot;http&amp;quot; *.*'''&lt;br /&gt;
&lt;br /&gt;
====Architectural Analysis====&lt;br /&gt;
If we can identify major architectural components within that application (right away) it can help narrow our search, and we can then look for known vulnerabilities in those components and frameworks:&lt;br /&gt;
&lt;br /&gt;
 ### Ajax&lt;br /&gt;
 XMLHTTP&lt;br /&gt;
 ### Struts&lt;br /&gt;
 org.apache.struts&lt;br /&gt;
 ### Spring&lt;br /&gt;
 org.springframework&lt;br /&gt;
 ### Java Server Faces (JSF)&lt;br /&gt;
 import javax.faces&lt;br /&gt;
 ### Hibernate&lt;br /&gt;
 import org.hibernate&lt;br /&gt;
 ### Castor&lt;br /&gt;
 org.exolab.castor&lt;br /&gt;
 ### JAXB&lt;br /&gt;
 javax.xml&lt;br /&gt;
 ### JMS&lt;br /&gt;
 JMS&lt;br /&gt;
 &lt;br /&gt;
====Http Request Strings====&lt;br /&gt;
Requests from external sources are onviously a key area of a secure code review. We need to ensure that all HTTP requests received are datavalidated for composition, max and min length and if the data falls with the relms of the parameter whitelist.&lt;br /&gt;
Bottom-line is this is a key area to look at and ensure security is enabled.&lt;br /&gt;
&lt;br /&gt;
 request.querystring&lt;br /&gt;
 request.form &lt;br /&gt;
 request.cookies&lt;br /&gt;
 request.certificate&lt;br /&gt;
 request.servervariables&lt;br /&gt;
 request.IsSecureConnection&lt;br /&gt;
 request.TotalBytes&lt;br /&gt;
 request.BinaryRead&lt;br /&gt;
&lt;br /&gt;
====HTML Output====&lt;br /&gt;
Here we are looking for responses to the client. Responses which go unvalidated or which echo external input without data validation are key areas to examine. Many client side attacks result from poor response validation. XSS relies on this somewhat.&lt;br /&gt;
&lt;br /&gt;
 response.write&lt;br /&gt;
 &amp;lt;% =&lt;br /&gt;
 HttpUtility&lt;br /&gt;
 HtmlEncode&lt;br /&gt;
 UrlEncode&lt;br /&gt;
 innerText&lt;br /&gt;
 innerHTML&lt;br /&gt;
&lt;br /&gt;
====Ajax and JavaScript====&lt;br /&gt;
Look for Ajax usage, and possible JavaScript issues:&lt;br /&gt;
&lt;br /&gt;
 document.write&lt;br /&gt;
 eval(&lt;br /&gt;
 document.cookie&lt;br /&gt;
 window.location&lt;br /&gt;
 document.URL&lt;br /&gt;
 XMLHTTP&lt;br /&gt;
 window.createRequest&lt;br /&gt;
&lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Locating where a database may be involved in the code is an important aspect of the code review. Looking at the database code will help determine if the application is vulnerable to SQL injection. One aspect of this is to verify that the code uses either ''SqlParameter'', ''OleDbParameter'', or ''OdbcParameter''(System.Data.SqlClient). These are typed and treats parameters as the literal value and not executable code in the database. &lt;br /&gt;
&lt;br /&gt;
 exec sp_executesql&lt;br /&gt;
 execute sp_executesql&lt;br /&gt;
 select from&lt;br /&gt;
 Insert&lt;br /&gt;
 update&lt;br /&gt;
 delete from where&lt;br /&gt;
 delete&lt;br /&gt;
 exec sp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec xp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec @&lt;br /&gt;
 execute @&lt;br /&gt;
 executestatement&lt;br /&gt;
 executeSQL&lt;br /&gt;
 setfilter&lt;br /&gt;
 executeQuery&lt;br /&gt;
 GetQueryResultInXML&lt;br /&gt;
 adodb&lt;br /&gt;
 sqloledb&lt;br /&gt;
 sql server&lt;br /&gt;
 driver&lt;br /&gt;
 Server.CreateObject&lt;br /&gt;
 .Provider&lt;br /&gt;
 .Open&lt;br /&gt;
 ADODB.recordset&lt;br /&gt;
 New OleDbConnection&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 DataSource&lt;br /&gt;
 SqlCommand&lt;br /&gt;
 Microsoft.Jet&lt;br /&gt;
 SqlDataReader&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 GetString&lt;br /&gt;
 SqlDataAdapter &lt;br /&gt;
 CommandType&lt;br /&gt;
 StoredProcedure&lt;br /&gt;
 System.Data.sql&lt;br /&gt;
&lt;br /&gt;
====Cookies====&lt;br /&gt;
Cookie manipulation can be key to various application security exploits such as session hijacking/fixation and parameter manipulation. One should examine any code relating to cookie functionality as this would have a bearing on session security.&lt;br /&gt;
 System.Net.Cookie &lt;br /&gt;
 HttpOnly&lt;br /&gt;
 document.cookie&lt;br /&gt;
&lt;br /&gt;
==== HTML Tags====&lt;br /&gt;
Many of the HTML tags below can be used for client side attacks such as cross site scritping. It is important to examine the context in which these tags are used and to examine any relevant data validation associated with the display and use of such tags withing a web application.&lt;br /&gt;
&lt;br /&gt;
 HtmlEncode &lt;br /&gt;
 URLEncode&lt;br /&gt;
 &amp;lt;applet&amp;gt; &lt;br /&gt;
 &amp;lt;frameset&amp;gt; &lt;br /&gt;
 &amp;lt;embed&amp;gt; &lt;br /&gt;
 &amp;lt;frame&amp;gt; &lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;iframe&amp;gt; &lt;br /&gt;
 &amp;lt;img&amp;gt; &lt;br /&gt;
 &amp;lt;style&amp;gt; &lt;br /&gt;
 &amp;lt;layer&amp;gt; &lt;br /&gt;
 &amp;lt;ilayer&amp;gt; &lt;br /&gt;
 &amp;lt;meta&amp;gt; &lt;br /&gt;
 &amp;lt;object&amp;gt; &lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &amp;lt;frame security&lt;br /&gt;
 &amp;lt;iframe security&lt;br /&gt;
&lt;br /&gt;
====Input Controls====&lt;br /&gt;
The input controls below are server classes used to produce and display web application form fields. Looking for such references helps locate entry points into the application.&lt;br /&gt;
&lt;br /&gt;
 system.web.ui.htmlcontrols.htmlinputhidden&lt;br /&gt;
 system.web.ui.webcontrols.textbox&lt;br /&gt;
 system.web.ui.webcontrols.listbox&lt;br /&gt;
 system.web.ui.webcontrols.checkboxlist&lt;br /&gt;
 system.web.ui.webcontrols.dropdownlist&lt;br /&gt;
&lt;br /&gt;
====web.config====&lt;br /&gt;
The .NET Framework relies on .config files to define configuration settings. The .config files are text-based XML files. Many .config files can, and typically do, exist on a single system. Web applications refer to a web.config file located in the application’s root directory. For ASP.NET applications, web.config contains information about most aspects of the application’s operation.&lt;br /&gt;
&lt;br /&gt;
 requestEncoding&lt;br /&gt;
 responseEncoding&lt;br /&gt;
 trace&lt;br /&gt;
 authorization&lt;br /&gt;
 CustomErrors&lt;br /&gt;
 httpRuntime &lt;br /&gt;
 maxRequestLength&lt;br /&gt;
 debug&lt;br /&gt;
 forms protection&lt;br /&gt;
 appSettings&lt;br /&gt;
 ConfigurationSettings&lt;br /&gt;
 authentication mode&lt;br /&gt;
 allow&lt;br /&gt;
 deny&lt;br /&gt;
 credentials&lt;br /&gt;
 identity impersonate&lt;br /&gt;
 timeout&lt;br /&gt;
&lt;br /&gt;
====global.asax====&lt;br /&gt;
Each application has its own Global.asax if one is required. Global.asax sets the event code and values for an application using scripts. One must ensure that application variables do not contain sensitive information, as they are accessible to the whole application and to all users within it.&lt;br /&gt;
&lt;br /&gt;
 Application_OnAuthenticateRequest&lt;br /&gt;
 Application_OnAuthorizeRequest&lt;br /&gt;
 Session_OnStart&lt;br /&gt;
 Session_OnEnd&lt;br /&gt;
&lt;br /&gt;
====logging====&lt;br /&gt;
Logging can be a source of information leakage. It is important to examing all calls to the logging subsystem and to determine if any sensitive information is being logged. Common mistakes are logging userID in conjunction with passwords within the authentication functionality or logging database requests which may contains sensitive data.&lt;br /&gt;
&lt;br /&gt;
 log4net&lt;br /&gt;
 Console.WriteLine&lt;br /&gt;
 System.Diagnostics.Debug&lt;br /&gt;
 System.Diagnostics.Trace&lt;br /&gt;
&lt;br /&gt;
====Machine.config====&lt;br /&gt;
Its important that many variables in machine.config can be overridden in the web.config file for a particular application.&lt;br /&gt;
 validateRequest&lt;br /&gt;
 enableViewState&lt;br /&gt;
 enableViewStateMac&lt;br /&gt;
&lt;br /&gt;
====Threads and Concurrancy====&lt;br /&gt;
Locating code that contains multithreaded functions. Concurrancy issues can result in race conditions which may result in security vulnerabilities. The Thread keyword is where new threads objects are created. Code that uses static global variables which hold sensitive security information may cause session issues. Code that uses static constructors may also cause issues between threads. Not synchronizing the Dispose method may cause issues if a number of threads call Dispose at the same time, this may cause resource release issues.&lt;br /&gt;
&lt;br /&gt;
 Thread&lt;br /&gt;
 Dispose&lt;br /&gt;
&lt;br /&gt;
====Class Design====&lt;br /&gt;
Public and Sealed relate to the design at class level. Classes whicch are not intended to be derived from should be sealed. Make sure all class fields are Public for a reason. Dont expose anything you dont need to.&lt;br /&gt;
&lt;br /&gt;
 Public&lt;br /&gt;
 Sealed&lt;br /&gt;
&lt;br /&gt;
====Reflection, Serialization====&lt;br /&gt;
Code may be generated dynamically at runtime. Code that is generated dynamically as a function of external input may give rise to issues. If your code contains sensitive data does it need to be serialized. &lt;br /&gt;
&lt;br /&gt;
 Serializable &lt;br /&gt;
 AllowPartiallyTrustedCallersAttribute&lt;br /&gt;
 GetObjectData &lt;br /&gt;
 StrongNameIdentityPermission&lt;br /&gt;
 StrongNameIdentity&lt;br /&gt;
 System.Reflection&lt;br /&gt;
&lt;br /&gt;
====Exceptions &amp;amp; Errors====&lt;br /&gt;
Ensure that the catch blocks do not leak information to the user in the case of an exception. Ensure when dealing with resources that the finally block is used. Having trace enabled is not great from an information leakage perspective. Ensure custonised errors are properly implemented.&lt;br /&gt;
&lt;br /&gt;
 catch{&lt;br /&gt;
 Finally&lt;br /&gt;
 trace enabled&lt;br /&gt;
 customErrors mode&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
If cryptography is used then is a strong enough cipher used i.e. AES or 3DES. What size key is used, the larger the better. Where is hashing performed. Are passwords that are being persisted hashed, they should be.&lt;br /&gt;
How are random numbers generated? Is the PRNG &amp;quot;random enough&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
 RNGCryptoServiceProvider&lt;br /&gt;
 SHA&lt;br /&gt;
 MD5&lt;br /&gt;
 base64&lt;br /&gt;
 xor&lt;br /&gt;
 DES&lt;br /&gt;
 RC2&lt;br /&gt;
 System.Random&lt;br /&gt;
 Random&lt;br /&gt;
 System.Security.Cryptography&lt;br /&gt;
&lt;br /&gt;
====Storage====&lt;br /&gt;
If storing sensitive data in memory recommend one uses the following. &lt;br /&gt;
 SecureString&lt;br /&gt;
 ProtectedMemory&lt;br /&gt;
&lt;br /&gt;
====Authorization, Assert &amp;amp; Revert====&lt;br /&gt;
Bypassing the code access security permission? Not a good idea. Also below is a list of potentially dangerous permissions such as calling unmanaged code, outside the CLR.&lt;br /&gt;
&lt;br /&gt;
 .RequestMinimum&lt;br /&gt;
 .RequestOptional&lt;br /&gt;
 Assert&lt;br /&gt;
 Debug.Assert&lt;br /&gt;
 CodeAccessPermission&lt;br /&gt;
 ReflectionPermission.MemberAccess&lt;br /&gt;
 SecurityPermission.ControlAppDomain&lt;br /&gt;
 SecurityPermission.UnmanagedCode&lt;br /&gt;
 SecurityPermission.SkipVerification&lt;br /&gt;
 SecurityPermission.ControlEvidence&lt;br /&gt;
 SecurityPermission.SerializationFormatter&lt;br /&gt;
 SecurityPermission.ControlPrincipal&lt;br /&gt;
 SecurityPermission.ControlDomainPolicy&lt;br /&gt;
 SecurityPermission.ControlPolicy&lt;br /&gt;
&lt;br /&gt;
====Leagcy methods====&lt;br /&gt;
 printf&lt;br /&gt;
 strcpy&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in J2EE/Java ===&lt;br /&gt;
&lt;br /&gt;
====Input Streams====&lt;br /&gt;
 Java.io&lt;br /&gt;
 FileInputStream&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 FilterInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 SequenceInputStream&lt;br /&gt;
 StringBufferInputStream&lt;br /&gt;
 BufferedReader&lt;br /&gt;
 ByteArrayInputStream&lt;br /&gt;
 CharArrayReader&lt;br /&gt;
 File&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 StreamTokenizer&lt;br /&gt;
 getResourceAsStream&lt;br /&gt;
&lt;br /&gt;
====Servlets====&lt;br /&gt;
 javax.servlet.&lt;br /&gt;
 getParameterNames&lt;br /&gt;
 getParameterValues&lt;br /&gt;
 getAttribute&lt;br /&gt;
 getAttributeNames&lt;br /&gt;
 isSecure&lt;br /&gt;
 HttpServletRequest&lt;br /&gt;
 getQueryString&lt;br /&gt;
 getHeader&lt;br /&gt;
 getPrincipal&lt;br /&gt;
 isUserInRole&lt;br /&gt;
 getOutputStream&lt;br /&gt;
 getWriter&lt;br /&gt;
 addCookie&lt;br /&gt;
 addHeader&lt;br /&gt;
 setHeader&lt;br /&gt;
 &lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Searching for Java Database related code this list should help you pinpoint classes/methods which are involved in the persistance layer of the application being reviewed.&lt;br /&gt;
 jdbc&lt;br /&gt;
 executeQuery&lt;br /&gt;
 select&lt;br /&gt;
 insert&lt;br /&gt;
 update&lt;br /&gt;
 delete&lt;br /&gt;
 execute&lt;br /&gt;
 executestatement&lt;br /&gt;
====SSL====&lt;br /&gt;
 com.sun.net.ssl&lt;br /&gt;
 SSLContext&lt;br /&gt;
 SSLSocketFactory&lt;br /&gt;
 TrustManagerFactory&lt;br /&gt;
 HttpsURLConnection&lt;br /&gt;
 KeyManagerFactory&lt;br /&gt;
&lt;br /&gt;
====Session Management====&lt;br /&gt;
 getSession&lt;br /&gt;
 invalidate&lt;br /&gt;
 getId &lt;br /&gt;
&lt;br /&gt;
====Data Validation====&lt;br /&gt;
&lt;br /&gt;
====Legacy Interaction====&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
&lt;br /&gt;
====Security Manager====&lt;br /&gt;
&lt;br /&gt;
====System====&lt;br /&gt;
&lt;br /&gt;
====Logging====&lt;br /&gt;
&lt;br /&gt;
====Other====&lt;br /&gt;
Developers say the darnedest things in their source code.  Look for the following keywords as pointers to possible software vulnerabilities:&lt;br /&gt;
&lt;br /&gt;
 Hack&lt;br /&gt;
 Kludge&lt;br /&gt;
 Bypass&lt;br /&gt;
 Steal&lt;br /&gt;
 Stolen&lt;br /&gt;
 Divert&lt;br /&gt;
 Broke&lt;br /&gt;
 Trick&lt;br /&gt;
 Fix&lt;br /&gt;
 ToDo&lt;/div&gt;</summary>
		<author><name>Cwells</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=19698</id>
		<title>Searching for Code in J2EE/Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=19698"/>
				<updated>2007-07-10T15:06:11Z</updated>
		
		<summary type="html">&lt;p&gt;Cwells: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Searching for key indicators ==&lt;br /&gt;
The basis of the code review is to locate and analyse areas of code which may have application security implications.&lt;br /&gt;
Assuming the code reviewer has a thorough understanding of the code, what it is intended to do and the context upon which it is to be used, firstly one needs to sweep the code base for areas of interest.&lt;br /&gt;
&lt;br /&gt;
This can be done by performing a text search on the code base looking for keywords relating to API's and functions.&lt;br /&gt;
Below is a guide for .NET framework 1.1 &amp;amp; 2.0&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in .NET ===&lt;br /&gt;
&lt;br /&gt;
Firstly one needs to be familiar with the tools one can use in order to perform text searching following on from this one need to know what to look for.&lt;br /&gt;
 &lt;br /&gt;
In this section we will assume you have a copy of Visual Studio (VS) .NET at hand. VS has two types of search &amp;quot;'''Find in Files'''&amp;quot; and a cmd line tool called '''Findstr'''&lt;br /&gt;
  &lt;br /&gt;
The test search tools in XP is not great in my experience and if one has to use this make sure SP2 in installed as it works better.&lt;br /&gt;
To start off one should scan thorough the code looking for common patterns or keywords such as &amp;quot;User&amp;quot;, &amp;quot;Password&amp;quot;, &amp;quot;Pswd&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Http&amp;quot;, etc...&lt;br /&gt;
This can be done using the &amp;quot;Find in Files&amp;quot; tool in VS or using findstring as follows:&lt;br /&gt;
 &lt;br /&gt;
[Find In Files HERE]&lt;br /&gt;
&lt;br /&gt;
 '''findstr /s /m /i /d:c:\projects\codebase\sec &amp;quot;http&amp;quot; *.*'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Http Request Strings====&lt;br /&gt;
Requests from external sources are onviously a key area of a secure code review. We need to ensure that all HTTP requests received are datavalidated for composition, max and min length and if the data falls with the relms of the parameter whitelist.&lt;br /&gt;
Bottom-line is this is a key area to look at and ensure security is enabled.&lt;br /&gt;
&lt;br /&gt;
 request.querystring&lt;br /&gt;
 request.form &lt;br /&gt;
 request.cookies&lt;br /&gt;
 request.certificate&lt;br /&gt;
 request.servervariables&lt;br /&gt;
 request.IsSecureConnection&lt;br /&gt;
 request.TotalBytes&lt;br /&gt;
 request.BinaryRead&lt;br /&gt;
&lt;br /&gt;
====HTML Output====&lt;br /&gt;
Here we are looking for responses to the client. Responses which go unvalidated or which echo external input without data validation are key areas to examine. Many client side attacks result from poor response validation. XSS relies on this somewhat.&lt;br /&gt;
&lt;br /&gt;
 response.write&lt;br /&gt;
 &amp;lt;% =&lt;br /&gt;
 HttpUtility&lt;br /&gt;
 HtmlEncode&lt;br /&gt;
 UrlEncode&lt;br /&gt;
 innerText&lt;br /&gt;
 innerHTML&lt;br /&gt;
&lt;br /&gt;
====Ajax and JavaScript====&lt;br /&gt;
Look for Ajax usage, and possible JavaScript issues:&lt;br /&gt;
&lt;br /&gt;
 document.write&lt;br /&gt;
 eval(&lt;br /&gt;
 document.cookie&lt;br /&gt;
 window.location&lt;br /&gt;
 document.URL&lt;br /&gt;
 XMLHTTP&lt;br /&gt;
 window.createRequest&lt;br /&gt;
&lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Locating where a database may be involved in the code is an important aspect of the code review. Looking at the database code will help determine if the application is vulnerable to SQL injection. One aspect of this is to verify that the code uses either ''SqlParameter'', ''OleDbParameter'', or ''OdbcParameter''(System.Data.SqlClient). These are typed and treats parameters as the literal value and not executable code in the database. &lt;br /&gt;
&lt;br /&gt;
 exec sp_executesql&lt;br /&gt;
 execute sp_executesql&lt;br /&gt;
 select from&lt;br /&gt;
 Insert&lt;br /&gt;
 update&lt;br /&gt;
 delete from where&lt;br /&gt;
 delete&lt;br /&gt;
 exec sp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec xp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec @&lt;br /&gt;
 execute @&lt;br /&gt;
 executestatement&lt;br /&gt;
 executeSQL&lt;br /&gt;
 setfilter&lt;br /&gt;
 executeQuery&lt;br /&gt;
 GetQueryResultInXML&lt;br /&gt;
 adodb&lt;br /&gt;
 sqloledb&lt;br /&gt;
 sql server&lt;br /&gt;
 driver&lt;br /&gt;
 Server.CreateObject&lt;br /&gt;
 .Provider&lt;br /&gt;
 .Open&lt;br /&gt;
 ADODB.recordset&lt;br /&gt;
 New OleDbConnection&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 DataSource&lt;br /&gt;
 SqlCommand&lt;br /&gt;
 Microsoft.Jet&lt;br /&gt;
 SqlDataReader&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 GetString&lt;br /&gt;
 SqlDataAdapter &lt;br /&gt;
 CommandType&lt;br /&gt;
 StoredProcedure&lt;br /&gt;
 System.Data.sql&lt;br /&gt;
&lt;br /&gt;
====Cookies====&lt;br /&gt;
Cookie manipulation can be key to various application security exploits such as session hijacking/fixation and parameter manipulation. One should examine any code relating to cookie functionality as this would have a bearing on session security.&lt;br /&gt;
 System.Net.Cookie &lt;br /&gt;
 HttpOnly&lt;br /&gt;
 document.cookie&lt;br /&gt;
&lt;br /&gt;
==== HTML Tags====&lt;br /&gt;
Many of the HTML tags below can be used for client side attacks such as cross site scritping. It is important to examine the context in which these tags are used and to examine any relevant data validation associated with the display and use of such tags withing a web application.&lt;br /&gt;
&lt;br /&gt;
 HtmlEncode &lt;br /&gt;
 URLEncode&lt;br /&gt;
 &amp;lt;applet&amp;gt; &lt;br /&gt;
 &amp;lt;frameset&amp;gt; &lt;br /&gt;
 &amp;lt;embed&amp;gt; &lt;br /&gt;
 &amp;lt;frame&amp;gt; &lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;iframe&amp;gt; &lt;br /&gt;
 &amp;lt;img&amp;gt; &lt;br /&gt;
 &amp;lt;style&amp;gt; &lt;br /&gt;
 &amp;lt;layer&amp;gt; &lt;br /&gt;
 &amp;lt;ilayer&amp;gt; &lt;br /&gt;
 &amp;lt;meta&amp;gt; &lt;br /&gt;
 &amp;lt;object&amp;gt; &lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &amp;lt;frame security&lt;br /&gt;
 &amp;lt;iframe security&lt;br /&gt;
&lt;br /&gt;
====Input Controls====&lt;br /&gt;
The input controls below are server classes used to produce and display web application form fields. Looking for such references helps locate entry points into the application.&lt;br /&gt;
&lt;br /&gt;
 system.web.ui.htmlcontrols.htmlinputhidden&lt;br /&gt;
 system.web.ui.webcontrols.textbox&lt;br /&gt;
 system.web.ui.webcontrols.listbox&lt;br /&gt;
 system.web.ui.webcontrols.checkboxlist&lt;br /&gt;
 system.web.ui.webcontrols.dropdownlist&lt;br /&gt;
&lt;br /&gt;
====web.config====&lt;br /&gt;
The .NET Framework relies on .config files to define configuration settings. The .config files are text-based XML files. Many .config files can, and typically do, exist on a single system. Web applications refer to a web.config file located in the application’s root directory. For ASP.NET applications, web.config contains information about most aspects of the application’s operation.&lt;br /&gt;
&lt;br /&gt;
 requestEncoding&lt;br /&gt;
 responseEncoding&lt;br /&gt;
 trace&lt;br /&gt;
 authorization&lt;br /&gt;
 CustomErrors&lt;br /&gt;
 httpRuntime &lt;br /&gt;
 maxRequestLength&lt;br /&gt;
 debug&lt;br /&gt;
 forms protection&lt;br /&gt;
 appSettings&lt;br /&gt;
 ConfigurationSettings&lt;br /&gt;
 authentication mode&lt;br /&gt;
 allow&lt;br /&gt;
 deny&lt;br /&gt;
 credentials&lt;br /&gt;
 identity impersonate&lt;br /&gt;
 timeout&lt;br /&gt;
&lt;br /&gt;
====global.asax====&lt;br /&gt;
Each application has its own Global.asax if one is required. Global.asax sets the event code and values for an application using scripts. One must ensure that application variables do not contain sensitive information, as they are accessible to the whole application and to all users within it.&lt;br /&gt;
&lt;br /&gt;
 Application_OnAuthenticateRequest&lt;br /&gt;
 Application_OnAuthorizeRequest&lt;br /&gt;
 Session_OnStart&lt;br /&gt;
 Session_OnEnd&lt;br /&gt;
&lt;br /&gt;
====logging====&lt;br /&gt;
Logging can be a source of information leakage. It is important to examing all calls to the logging subsystem and to determine if any sensitive information is being logged. Common mistakes are logging userID in conjunction with passwords within the authentication functionality or logging database requests which may contains sensitive data.&lt;br /&gt;
&lt;br /&gt;
 log4net&lt;br /&gt;
 Console.WriteLine&lt;br /&gt;
 System.Diagnostics.Debug&lt;br /&gt;
 System.Diagnostics.Trace&lt;br /&gt;
&lt;br /&gt;
====Machine.config====&lt;br /&gt;
Its important that many variables in machine.config can be overridden in the web.config file for a particular application.&lt;br /&gt;
 validateRequest&lt;br /&gt;
 enableViewState&lt;br /&gt;
 enableViewStateMac&lt;br /&gt;
&lt;br /&gt;
====Threads and Concurrancy====&lt;br /&gt;
Locating code that contains multithreaded functions. Concurrancy issues can result in race conditions which may result in security vulnerabilities. The Thread keyword is where new threads objects are created. Code that uses static global variables which hold sensitive security information may cause session issues. Code that uses static constructors may also cause issues between threads. Not synchronizing the Dispose method may cause issues if a number of threads call Dispose at the same time, this may cause resource release issues.&lt;br /&gt;
&lt;br /&gt;
 Thread&lt;br /&gt;
 Dispose&lt;br /&gt;
&lt;br /&gt;
====Class Design====&lt;br /&gt;
Public and Sealed relate to the design at class level. Classes whicch are not intended to be derived from should be sealed. Make sure all class fields are Public for a reason. Dont expose anything you dont need to.&lt;br /&gt;
&lt;br /&gt;
 Public&lt;br /&gt;
 Sealed&lt;br /&gt;
&lt;br /&gt;
====Reflection, Serialization====&lt;br /&gt;
Code may be generated dynamically at runtime. Code that is generated dynamically as a function of external input may give rise to issues. If your code contains sensitive data does it need to be serialized. &lt;br /&gt;
&lt;br /&gt;
 Serializable &lt;br /&gt;
 AllowPartiallyTrustedCallersAttribute&lt;br /&gt;
 GetObjectData &lt;br /&gt;
 StrongNameIdentityPermission&lt;br /&gt;
 StrongNameIdentity&lt;br /&gt;
 System.Reflection&lt;br /&gt;
&lt;br /&gt;
====Exceptions &amp;amp; Errors====&lt;br /&gt;
Ensure that the catch blocks do not leak information to the user in the case of an exception. Ensure when dealing with resources that the finally block is used. Having trace enabled is not great from an information leakage perspective. Ensure custonised errors are properly implemented.&lt;br /&gt;
&lt;br /&gt;
 catch{&lt;br /&gt;
 Finally&lt;br /&gt;
 trace enabled&lt;br /&gt;
 customErrors mode&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
If cryptography is used then is a strong enough cipher used i.e. AES or 3DES. What size key is used, the larger the better. Where is hashing performed. Are passwords that are being persisted hashed, they should be.&lt;br /&gt;
How are random numbers generated? Is the PRNG &amp;quot;random enough&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
 RNGCryptoServiceProvider&lt;br /&gt;
 SHA&lt;br /&gt;
 MD5&lt;br /&gt;
 base64&lt;br /&gt;
 xor&lt;br /&gt;
 DES&lt;br /&gt;
 RC2&lt;br /&gt;
 System.Random&lt;br /&gt;
 Random&lt;br /&gt;
 System.Security.Cryptography&lt;br /&gt;
&lt;br /&gt;
====Storage====&lt;br /&gt;
If storing sensitive data in memory recommend one uses the following. &lt;br /&gt;
 SecureString&lt;br /&gt;
 ProtectedMemory&lt;br /&gt;
&lt;br /&gt;
====Authorization, Assert &amp;amp; Revert====&lt;br /&gt;
Bypassing the code access security permission? Not a good idea. Also below is a list of potentially dangerous permissions such as calling unmanaged code, outside the CLR.&lt;br /&gt;
&lt;br /&gt;
 .RequestMinimum&lt;br /&gt;
 .RequestOptional&lt;br /&gt;
 Assert&lt;br /&gt;
 Debug.Assert&lt;br /&gt;
 CodeAccessPermission&lt;br /&gt;
 ReflectionPermission.MemberAccess&lt;br /&gt;
 SecurityPermission.ControlAppDomain&lt;br /&gt;
 SecurityPermission.UnmanagedCode&lt;br /&gt;
 SecurityPermission.SkipVerification&lt;br /&gt;
 SecurityPermission.ControlEvidence&lt;br /&gt;
 SecurityPermission.SerializationFormatter&lt;br /&gt;
 SecurityPermission.ControlPrincipal&lt;br /&gt;
 SecurityPermission.ControlDomainPolicy&lt;br /&gt;
 SecurityPermission.ControlPolicy&lt;br /&gt;
&lt;br /&gt;
====Leagcy methods====&lt;br /&gt;
 printf&lt;br /&gt;
 strcpy&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in J2EE/Java ===&lt;br /&gt;
&lt;br /&gt;
====Input Streams====&lt;br /&gt;
 Java.io&lt;br /&gt;
 FileInputStream&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 FilterInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 SequenceInputStream&lt;br /&gt;
 StringBufferInputStream&lt;br /&gt;
 BufferedReader&lt;br /&gt;
 ByteArrayInputStream&lt;br /&gt;
 CharArrayReader&lt;br /&gt;
 File&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 StreamTokenizer&lt;br /&gt;
 getResourceAsStream&lt;br /&gt;
&lt;br /&gt;
====Servlets====&lt;br /&gt;
 javax.servlet.&lt;br /&gt;
 getParameterNames&lt;br /&gt;
 getParameterValues&lt;br /&gt;
 getAttribute&lt;br /&gt;
 getAttributeNames&lt;br /&gt;
 isSecure&lt;br /&gt;
 HttpServletRequest&lt;br /&gt;
 getQueryString&lt;br /&gt;
 getHeader&lt;br /&gt;
 getPrincipal&lt;br /&gt;
 isUserInRole&lt;br /&gt;
 getOutputStream&lt;br /&gt;
 getWriter&lt;br /&gt;
 addCookie&lt;br /&gt;
 addHeader&lt;br /&gt;
 setHeader&lt;br /&gt;
 &lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Searching for Java Database related code this list should help you pinpoint classes/methods which are involved in the persistance layer of the application being reviewed.&lt;br /&gt;
 jdbc&lt;br /&gt;
 executeQuery&lt;br /&gt;
 select&lt;br /&gt;
 insert&lt;br /&gt;
 update&lt;br /&gt;
 delete&lt;br /&gt;
 execute&lt;br /&gt;
 executestatement&lt;br /&gt;
====SSL====&lt;br /&gt;
 com.sun.net.ssl&lt;br /&gt;
 SSLContext&lt;br /&gt;
 SSLSocketFactory&lt;br /&gt;
 TrustManagerFactory&lt;br /&gt;
 HttpsURLConnection&lt;br /&gt;
 KeyManagerFactory&lt;br /&gt;
&lt;br /&gt;
====Session Management====&lt;br /&gt;
 getSession&lt;br /&gt;
 invalidate&lt;br /&gt;
 getId &lt;br /&gt;
&lt;br /&gt;
====Data Validation====&lt;br /&gt;
&lt;br /&gt;
====Legacy Interaction====&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
&lt;br /&gt;
====Security Manager====&lt;br /&gt;
&lt;br /&gt;
====System====&lt;br /&gt;
&lt;br /&gt;
====Logging====&lt;br /&gt;
&lt;br /&gt;
====Other====&lt;br /&gt;
Developers say the darnedest things in their source code.  Look for the following keywords as pointers to possible software vulnerabilities:&lt;br /&gt;
&lt;br /&gt;
 Hack&lt;br /&gt;
 Kludge&lt;br /&gt;
 Bypass&lt;br /&gt;
 Steal&lt;br /&gt;
 Stolen&lt;br /&gt;
 Divert&lt;br /&gt;
 Broke&lt;br /&gt;
 Trick&lt;br /&gt;
 Fix&lt;br /&gt;
 ToDo&lt;/div&gt;</summary>
		<author><name>Cwells</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=19697</id>
		<title>Searching for Code in J2EE/Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Searching_for_Code_in_J2EE/Java&amp;diff=19697"/>
				<updated>2007-07-10T14:56:46Z</updated>
		
		<summary type="html">&lt;p&gt;Cwells: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Searching for key indicators ==&lt;br /&gt;
The basis of the code review is to locate and analyse areas of code which may have application security implications.&lt;br /&gt;
Assuming the code reviewer has a thorough understanding of the code, what it is intended to do and the context upon which it is to be used, firstly one needs to sweep the code base for areas of interest.&lt;br /&gt;
&lt;br /&gt;
This can be done by performing a text search on the code base looking for keywords relating to API's and functions.&lt;br /&gt;
Below is a guide for .NET framework 1.1 &amp;amp; 2.0&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in .NET ===&lt;br /&gt;
&lt;br /&gt;
Firstly one needs to be familiar with the tools one can use in order to perform text searching following on from this one need to know what to look for.&lt;br /&gt;
 &lt;br /&gt;
In this section we will assume you have a copy of Visual Studio (VS) .NET at hand. VS has two types of search &amp;quot;'''Find in Files'''&amp;quot; and a cmd line tool called '''Findstr'''&lt;br /&gt;
  &lt;br /&gt;
The test search tools in XP is not great in my experience and if one has to use this make sure SP2 in installed as it works better.&lt;br /&gt;
To start off one should scan thorough the code looking for common patterns or keywords such as &amp;quot;User&amp;quot;, &amp;quot;Password&amp;quot;, &amp;quot;Pswd&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Http&amp;quot;, etc...&lt;br /&gt;
This can be done using the &amp;quot;Find in Files&amp;quot; tool in VS or using findstring as follows:&lt;br /&gt;
 &lt;br /&gt;
[Find In Files HERE]&lt;br /&gt;
&lt;br /&gt;
 '''findstr /s /m /i /d:c:\projects\codebase\sec &amp;quot;http&amp;quot; *.*'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Http Request Strings====&lt;br /&gt;
Requests from external sources are onviously a key area of a secure code review. We need to ensure that all HTTP requests received are datavalidated for composition, max and min length and if the data falls with the relms of the parameter whitelist.&lt;br /&gt;
Bottom-line is this is a key area to look at and ensure security is enabled.&lt;br /&gt;
&lt;br /&gt;
 request.querystring&lt;br /&gt;
 request.form &lt;br /&gt;
 request.cookies&lt;br /&gt;
 request.certificate&lt;br /&gt;
 request.servervariables&lt;br /&gt;
 request.IsSecureConnection&lt;br /&gt;
 request.TotalBytes&lt;br /&gt;
 request.BinaryRead&lt;br /&gt;
&lt;br /&gt;
====HTML Output====&lt;br /&gt;
Here we are looking for responses to the client. Responses which go unvalidated or which echo external input without data validation are key areas to examine. Many client side attacks result from poor response validation. XSS relies on this somewhat.&lt;br /&gt;
&lt;br /&gt;
 response.write&lt;br /&gt;
 &amp;lt;% =&lt;br /&gt;
 HttpUtility&lt;br /&gt;
 HtmlEncode&lt;br /&gt;
 UrlEncode&lt;br /&gt;
 innerText&lt;br /&gt;
 innerHTML&lt;br /&gt;
&lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Locating where a database may be involved in the code is an important aspect of the code review. Looking at the database code will help determine if the application is vulnerable to SQL injection. One aspect of this is to verify that the code uses either ''SqlParameter'', ''OleDbParameter'', or ''OdbcParameter''(System.Data.SqlClient). These are typed and treats parameters as the literal value and not executable code in the database. &lt;br /&gt;
&lt;br /&gt;
 exec sp_executesql&lt;br /&gt;
 execute sp_executesql&lt;br /&gt;
 select from&lt;br /&gt;
 Insert&lt;br /&gt;
 update&lt;br /&gt;
 delete from where&lt;br /&gt;
 delete&lt;br /&gt;
 exec sp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec xp_&lt;br /&gt;
 execute sp_&lt;br /&gt;
 exec @&lt;br /&gt;
 execute @&lt;br /&gt;
 executestatement&lt;br /&gt;
 executeSQL&lt;br /&gt;
 setfilter&lt;br /&gt;
 executeQuery&lt;br /&gt;
 GetQueryResultInXML&lt;br /&gt;
 adodb&lt;br /&gt;
 sqloledb&lt;br /&gt;
 sql server&lt;br /&gt;
 driver&lt;br /&gt;
 Server.CreateObject&lt;br /&gt;
 .Provider&lt;br /&gt;
 .Open&lt;br /&gt;
 ADODB.recordset&lt;br /&gt;
 New OleDbConnection&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 DataSource&lt;br /&gt;
 SqlCommand&lt;br /&gt;
 Microsoft.Jet&lt;br /&gt;
 SqlDataReader&lt;br /&gt;
 ExecuteReader&lt;br /&gt;
 GetString&lt;br /&gt;
 SqlDataAdapter &lt;br /&gt;
 CommandType&lt;br /&gt;
 StoredProcedure&lt;br /&gt;
 System.Data.sql&lt;br /&gt;
&lt;br /&gt;
====Cookies====&lt;br /&gt;
Cookie manipulation can be key to various application security exploits such as session hijacking/fixation and parameter manipulation. One should examine any code relating to cookie functionality as this would have a bearing on session security.&lt;br /&gt;
 System.Net.Cookie &lt;br /&gt;
 HttpOnly&lt;br /&gt;
 document.cookie&lt;br /&gt;
&lt;br /&gt;
==== HTML Tags====&lt;br /&gt;
Many of the HTML tags below can be used for client side attacks such as cross site scritping. It is important to examine the context in which these tags are used and to examine any relevant data validation associated with the display and use of such tags withing a web application.&lt;br /&gt;
&lt;br /&gt;
 HtmlEncode &lt;br /&gt;
 URLEncode&lt;br /&gt;
 &amp;lt;applet&amp;gt; &lt;br /&gt;
 &amp;lt;frameset&amp;gt; &lt;br /&gt;
 &amp;lt;embed&amp;gt; &lt;br /&gt;
 &amp;lt;frame&amp;gt; &lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;iframe&amp;gt; &lt;br /&gt;
 &amp;lt;img&amp;gt; &lt;br /&gt;
 &amp;lt;style&amp;gt; &lt;br /&gt;
 &amp;lt;layer&amp;gt; &lt;br /&gt;
 &amp;lt;ilayer&amp;gt; &lt;br /&gt;
 &amp;lt;meta&amp;gt; &lt;br /&gt;
 &amp;lt;object&amp;gt; &lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &amp;lt;frame security&lt;br /&gt;
 &amp;lt;iframe security&lt;br /&gt;
&lt;br /&gt;
====Input Controls====&lt;br /&gt;
The input controls below are server classes used to produce and display web application form fields. Looking for such references helps locate entry points into the application.&lt;br /&gt;
&lt;br /&gt;
 system.web.ui.htmlcontrols.htmlinputhidden&lt;br /&gt;
 system.web.ui.webcontrols.textbox&lt;br /&gt;
 system.web.ui.webcontrols.listbox&lt;br /&gt;
 system.web.ui.webcontrols.checkboxlist&lt;br /&gt;
 system.web.ui.webcontrols.dropdownlist&lt;br /&gt;
&lt;br /&gt;
====web.config====&lt;br /&gt;
The .NET Framework relies on .config files to define configuration settings. The .config files are text-based XML files. Many .config files can, and typically do, exist on a single system. Web applications refer to a web.config file located in the application’s root directory. For ASP.NET applications, web.config contains information about most aspects of the application’s operation.&lt;br /&gt;
&lt;br /&gt;
 requestEncoding&lt;br /&gt;
 responseEncoding&lt;br /&gt;
 trace&lt;br /&gt;
 authorization&lt;br /&gt;
 CustomErrors&lt;br /&gt;
 httpRuntime &lt;br /&gt;
 maxRequestLength&lt;br /&gt;
 debug&lt;br /&gt;
 forms protection&lt;br /&gt;
 appSettings&lt;br /&gt;
 ConfigurationSettings&lt;br /&gt;
 authentication mode&lt;br /&gt;
 allow&lt;br /&gt;
 deny&lt;br /&gt;
 credentials&lt;br /&gt;
 identity impersonate&lt;br /&gt;
 timeout&lt;br /&gt;
&lt;br /&gt;
====global.asax====&lt;br /&gt;
Each application has its own Global.asax if one is required. Global.asax sets the event code and values for an application using scripts. One must ensure that application variables do not contain sensitive information, as they are accessible to the whole application and to all users within it.&lt;br /&gt;
&lt;br /&gt;
 Application_OnAuthenticateRequest&lt;br /&gt;
 Application_OnAuthorizeRequest&lt;br /&gt;
 Session_OnStart&lt;br /&gt;
 Session_OnEnd&lt;br /&gt;
&lt;br /&gt;
====logging====&lt;br /&gt;
Logging can be a source of information leakage. It is important to examing all calls to the logging subsystem and to determine if any sensitive information is being logged. Common mistakes are logging userID in conjunction with passwords within the authentication functionality or logging database requests which may contains sensitive data.&lt;br /&gt;
&lt;br /&gt;
 log4net&lt;br /&gt;
 Console.WriteLine&lt;br /&gt;
 System.Diagnostics.Debug&lt;br /&gt;
 System.Diagnostics.Trace&lt;br /&gt;
&lt;br /&gt;
====Machine.config====&lt;br /&gt;
Its important that many variables in machine.config can be overridden in the web.config file for a particular application.&lt;br /&gt;
 validateRequest&lt;br /&gt;
 enableViewState&lt;br /&gt;
 enableViewStateMac&lt;br /&gt;
&lt;br /&gt;
====Threads and Concurrancy====&lt;br /&gt;
Locating code that contains multithreaded functions. Concurrancy issues can result in race conditions which may result in security vulnerabilities. The Thread keyword is where new threads objects are created. Code that uses static global variables which hold sensitive security information may cause session issues. Code that uses static constructors may also cause issues between threads. Not synchronizing the Dispose method may cause issues if a number of threads call Dispose at the same time, this may cause resource release issues.&lt;br /&gt;
&lt;br /&gt;
 Thread&lt;br /&gt;
 Dispose&lt;br /&gt;
&lt;br /&gt;
====Class Design====&lt;br /&gt;
Public and Sealed relate to the design at class level. Classes whicch are not intended to be derived from should be sealed. Make sure all class fields are Public for a reason. Dont expose anything you dont need to.&lt;br /&gt;
&lt;br /&gt;
 Public&lt;br /&gt;
 Sealed&lt;br /&gt;
&lt;br /&gt;
====Reflection, Serialization====&lt;br /&gt;
Code may be generated dynamically at runtime. Code that is generated dynamically as a function of external input may give rise to issues. If your code contains sensitive data does it need to be serialized. &lt;br /&gt;
&lt;br /&gt;
 Serializable &lt;br /&gt;
 AllowPartiallyTrustedCallersAttribute&lt;br /&gt;
 GetObjectData &lt;br /&gt;
 StrongNameIdentityPermission&lt;br /&gt;
 StrongNameIdentity&lt;br /&gt;
 System.Reflection&lt;br /&gt;
&lt;br /&gt;
====Exceptions &amp;amp; Errors====&lt;br /&gt;
Ensure that the catch blocks do not leak information to the user in the case of an exception. Ensure when dealing with resources that the finally block is used. Having trace enabled is not great from an information leakage perspective. Ensure custonised errors are properly implemented.&lt;br /&gt;
&lt;br /&gt;
 catch{&lt;br /&gt;
 Finally&lt;br /&gt;
 trace enabled&lt;br /&gt;
 customErrors mode&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
If cryptography is used then is a strong enough cipher used i.e. AES or 3DES. What size key is used, the larger the better. Where is hashing performed. Are passwords that are being persisted hashed, they should be.&lt;br /&gt;
How are random numbers generated? Is the PRNG &amp;quot;random enough&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
 RNGCryptoServiceProvider&lt;br /&gt;
 SHA&lt;br /&gt;
 MD5&lt;br /&gt;
 base64&lt;br /&gt;
 xor&lt;br /&gt;
 DES&lt;br /&gt;
 RC2&lt;br /&gt;
 System.Random&lt;br /&gt;
 Random&lt;br /&gt;
 System.Security.Cryptography&lt;br /&gt;
&lt;br /&gt;
====Storage====&lt;br /&gt;
If storing sensitive data in memory recommend one uses the following. &lt;br /&gt;
 SecureString&lt;br /&gt;
 ProtectedMemory&lt;br /&gt;
&lt;br /&gt;
====Authorization, Assert &amp;amp; Revert====&lt;br /&gt;
Bypassing the code access security permission? Not a good idea. Also below is a list of potentially dangerous permissions such as calling unmanaged code, outside the CLR.&lt;br /&gt;
&lt;br /&gt;
 .RequestMinimum&lt;br /&gt;
 .RequestOptional&lt;br /&gt;
 Assert&lt;br /&gt;
 Debug.Assert&lt;br /&gt;
 CodeAccessPermission&lt;br /&gt;
 ReflectionPermission.MemberAccess&lt;br /&gt;
 SecurityPermission.ControlAppDomain&lt;br /&gt;
 SecurityPermission.UnmanagedCode&lt;br /&gt;
 SecurityPermission.SkipVerification&lt;br /&gt;
 SecurityPermission.ControlEvidence&lt;br /&gt;
 SecurityPermission.SerializationFormatter&lt;br /&gt;
 SecurityPermission.ControlPrincipal&lt;br /&gt;
 SecurityPermission.ControlDomainPolicy&lt;br /&gt;
 SecurityPermission.ControlPolicy&lt;br /&gt;
&lt;br /&gt;
====Leagcy methods====&lt;br /&gt;
 printf&lt;br /&gt;
 strcpy&lt;br /&gt;
&lt;br /&gt;
=== Searching for code in J2EE/Java ===&lt;br /&gt;
&lt;br /&gt;
====Input Streams====&lt;br /&gt;
 Java.io&lt;br /&gt;
 FileInputStream&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 FilterInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 SequenceInputStream&lt;br /&gt;
 StringBufferInputStream&lt;br /&gt;
 BufferedReader&lt;br /&gt;
 ByteArrayInputStream&lt;br /&gt;
 CharArrayReader&lt;br /&gt;
 File&lt;br /&gt;
 ObjectInputStream&lt;br /&gt;
 PipedInputStream&lt;br /&gt;
 StreamTokenizer&lt;br /&gt;
 getResourceAsStream&lt;br /&gt;
&lt;br /&gt;
====Servlets====&lt;br /&gt;
 javax.servlet.&lt;br /&gt;
 getParameterNames&lt;br /&gt;
 getParameterValues&lt;br /&gt;
 getAttribute&lt;br /&gt;
 getAttributeNames&lt;br /&gt;
 isSecure&lt;br /&gt;
 HttpServletRequest&lt;br /&gt;
 getQueryString&lt;br /&gt;
 getHeader&lt;br /&gt;
 getPrincipal&lt;br /&gt;
 isUserInRole&lt;br /&gt;
 getOutputStream&lt;br /&gt;
 getWriter&lt;br /&gt;
 addCookie&lt;br /&gt;
 addHeader&lt;br /&gt;
 setHeader&lt;br /&gt;
 &lt;br /&gt;
====SQL &amp;amp; Database====&lt;br /&gt;
Searching for Java Database related code this list should help you pinpoint classes/methods which are involved in the persistance layer of the application being reviewed.&lt;br /&gt;
 jdbc&lt;br /&gt;
 executeQuery&lt;br /&gt;
 select&lt;br /&gt;
 insert&lt;br /&gt;
 update&lt;br /&gt;
 delete&lt;br /&gt;
 execute&lt;br /&gt;
 executestatement&lt;br /&gt;
====SSL====&lt;br /&gt;
 com.sun.net.ssl&lt;br /&gt;
 SSLContext&lt;br /&gt;
 SSLSocketFactory&lt;br /&gt;
 TrustManagerFactory&lt;br /&gt;
 HttpsURLConnection&lt;br /&gt;
 KeyManagerFactory&lt;br /&gt;
&lt;br /&gt;
====Session Management====&lt;br /&gt;
 getSession&lt;br /&gt;
 invalidate&lt;br /&gt;
 getId &lt;br /&gt;
&lt;br /&gt;
====Data Validation====&lt;br /&gt;
&lt;br /&gt;
====Legacy Interaction====&lt;br /&gt;
&lt;br /&gt;
====Crypto====&lt;br /&gt;
&lt;br /&gt;
====Security Manager====&lt;br /&gt;
&lt;br /&gt;
====System====&lt;br /&gt;
&lt;br /&gt;
====Logging====&lt;br /&gt;
&lt;br /&gt;
====Other====&lt;br /&gt;
Developers say the darnedest things in their source code.  Look for the following keywords as pointers to possible software vulnerabilities:&lt;br /&gt;
&lt;br /&gt;
 Hack&lt;br /&gt;
 Kludge&lt;br /&gt;
 Bypass&lt;br /&gt;
 Steal&lt;br /&gt;
 Stolen&lt;br /&gt;
 Divert&lt;br /&gt;
 Broke&lt;br /&gt;
 Trick&lt;br /&gt;
 Fix&lt;br /&gt;
 ToDo&lt;/div&gt;</summary>
		<author><name>Cwells</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Cwells&amp;diff=6143</id>
		<title>User:Cwells</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Cwells&amp;diff=6143"/>
				<updated>2006-06-13T13:32:54Z</updated>
		
		<summary type="html">&lt;p&gt;Cwells: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Chris Wells wants to elevate the awareness of application security issues by teaching and encouraging developers to build applications that can defend themselves against the serious types of threats that exist on the Internet today.  &lt;br /&gt;
&lt;br /&gt;
Over his career, Chris has deployed security solutions for major healthcare, telecommunication, and financial industries, and is currently employed as an Information Security Consultant for a major financial institution.  He is an accomplished application security architect with over 10 years of application security experience.  &lt;br /&gt;
&lt;br /&gt;
Chris holds multiple security certifications including a Certified Information Security Systems Professional (CISSP), and holds a Bachelor degree from the University of Minnesota.&lt;/div&gt;</summary>
		<author><name>Cwells</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Code_Review_Introduction&amp;diff=6142</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=6142"/>
				<updated>2006-06-13T13:27:30Z</updated>
		
		<summary type="html">&lt;p&gt;Cwells: /* The Checklist */&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 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;
This is what OWASP are trying to do; to bring security in web application development into the mainstream, to make it a selling point. 30% to 35% of Microsoft’s budget for “Longhorn” is earmarked for security, a sign of the times. &amp;lt;u&amp;gt;http://news.bbc.co.uk/2/hi/business/4516269.stm&amp;lt;/u&amp;gt;&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 purest point of view. Not everything you may agree with but from experience it is rare that we can have the luxury of being a purest 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;
  ''	- I love proverbs as you can see.''&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;
&lt;br /&gt;
==The Basics: What we know we don’t know and what we know we know. ==&lt;br /&gt;
&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 out there but I have yet to see the “Silver bullet” which does not cost the price of a small island off the west coast of Ireland.&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 artefacts 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 form 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 its 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, which the enterprise would fail without. 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;
&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.owasp.org/docroot/owasp/misc/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>Cwells</name></author>	</entry>

	</feed>