This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org
Difference between revisions of "Crawling Code"
(→HTTP Request Strings) |
|||
Line 26: | Line 26: | ||
Requests from external sources are obviously a key area of a security code review. We need to ensure that all HTTP requests received are data validated for composition, max and min length, and if the data falls with the realms of the parameter white-list. Bottom-line is this is a key area to look at and ensure security is enabled. | Requests from external sources are obviously a key area of a security code review. We need to ensure that all HTTP requests received are data validated for composition, max and min length, and if the data falls with the realms of the parameter white-list. Bottom-line is this is a key area to look at and ensure security is enabled. | ||
− | + | request.accepttypes<br> | |
− | request.browser | + | request.browser<br> |
− | request.files | + | request.files<br> |
− | request.headers | + | request.headers<br> |
− | request.httpmethod | + | request.httpmethod<br> |
− | request.item | + | request.item<br> |
− | request.querystring | + | request.querystring<br> |
− | request.form | + | request.form <br> |
− | request.cookies | + | request.cookies<br> |
− | request.certificate | + | request.certificate<br> |
− | request.rawurl | + | request.rawurl<br> |
− | request.servervariables | + | request.servervariables<br> |
− | request.url | + | request.url<br> |
− | request.urlreferrer | + | request.urlreferrer<br> |
− | request.useragent | + | request.useragent<br> |
− | request.userlanguages | + | request.userlanguages<br> |
− | request.IsSecureConnection | + | request.IsSecureConnection<br> |
− | request.TotalBytes | + | request.TotalBytes<br> |
− | request.BinaryRead | + | request.BinaryRead<br> |
− | InputStream | + | InputStream<br> |
− | HiddenField.Value | + | HiddenField.Value<br> |
− | TextBox.Text | + | TextBox.Text<br> |
− | recordSet | + | recordSet<br> |
[[Category:OWASP Code Review Project]] | [[Category:OWASP Code Review Project]] |
Revision as of 13:20, 10 January 2009
OWASP Code Review Guide Table of ContentsCrawling code is the practice of scanning a code base of the review target in question. It is, in effect, looking for key pointers wherein a possible security vulnerability might reside. Certain APIs are related to interfacing to the external world or file IO or user management which are key areas for an attacker to focus on. In crawling code we look for API relating to these areas. We also need to look for business logic areas which may cause security issues, but generally these are bespoke methods which have bespoke names and can not be detected directly, even though we may touch on certain methods due to their relationship with a certain key API.
Also we need to look for common issues relating to a specific language; issues that may not be *security* related but which may affect the stability/availability of the application in the case of extraordinary circumstances. Other issues when performing a code review are areas such a simple copyright notice in order to protect one’s intellectual property.
Crawling code can be done manually or in an automated fashion using automated tools. Tools as simple as grep or wingrep can be used. Other tools are available which would search for key words relating to a specific programming language.
The following sections shall cover the function of crawing code for Java/J2EE, .NET and Classic ASP. This section is best used in conjunction with the transactional analysis section also detailed in this guide.
Searching for Key Indicators
The basis of the code review is to locate and analyse areas of code which may have application security implications. Assuming the code reviewer has a thorough understanding of the code, what it is intended to do, and the context in which it is to be used, firstly one needs to sweep the code base for areas of interest.
This can be done by performing a text search on the code base looking for keywords relating to APIs and functions. Below is a guide for .NET framework 1.1 & 2.0
Searching for Code in .NET
Firstly one needs to be familiar with the tools one can use in order to perform text searching, following this one neesd to know what to look for.
In this section we will assume you have a copy of Visual Studio (VS) .NET at hand. VS has two types of search "Find in Files" and a cmd line tool called Findstr.
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. To start off, one should scan thorough the code looking for common patterns or keywords such as "User", "Password", "Pswd", "Key", "Http", etc... This can be done using the "Find in Files" tool in VS or using findstring as follows:
findstr /s /m /i /d:c:\projects\codebase\sec "http" *.*
HTTP Request Strings
Requests from external sources are obviously a key area of a security code review. We need to ensure that all HTTP requests received are data validated for composition, max and min length, and if the data falls with the realms of the parameter white-list. Bottom-line is this is a key area to look at and ensure security is enabled.
request.accepttypes
request.browser
request.files
request.headers
request.httpmethod
request.item
request.querystring
request.form
request.cookies
request.certificate
request.rawurl
request.servervariables
request.url
request.urlreferrer
request.useragent
request.userlanguages
request.IsSecureConnection
request.TotalBytes
request.BinaryRead
InputStream
HiddenField.Value
TextBox.Text
recordSet