<?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=Jkurucar</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=Jkurucar"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Jkurucar"/>
		<updated>2026-04-25T08:17:19Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Access_Control_Cheat_Sheet&amp;diff=196478</id>
		<title>Access Control Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Access_Control_Cheat_Sheet&amp;diff=196478"/>
				<updated>2015-06-22T16:40:48Z</updated>
		
		<summary type="html">&lt;p&gt;Jkurucar: /* Discretionary Access Control (DAC)' */&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 is focused on providing clear, simple, actionable guidance for providing Access Control security in your applications.&lt;br /&gt;
&lt;br /&gt;
==What is Access Control / Authorization?==&lt;br /&gt;
&lt;br /&gt;
Authorization 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 - as these terms and their definitions are frequently confused.  Authentication is providing and validating identity.  In a system that uses a simple username and password scheme, the authentication process collects the username and validates the identity using the password.  Authorization is the execution of access control properties, ensuring the proper allocation of access rights once authentication is successful.&lt;br /&gt;
&lt;br /&gt;
Access Control is the method or mechanism of authorization to enforce that requests to a system resource or functionality should be granted.&lt;br /&gt;
&lt;br /&gt;
== Role Based Access Control (RBAC) ==&lt;br /&gt;
In Role-Based Access Control (RBAC), access decisions are based on an individual's roles and responsibilities within the organization or user base. The process of defining roles is usually based on analyzing the fundamental goals and structure of an organization and is usually linked to the security policy. For instance, in a medical organization, the different roles of users may include those such as doctor, nurse, attendant, nurse, patients, etc. Obviously, these members require different levels of access in order to perform their functions, but also the types of web transactions and their allowed context vary greatly depending on the security policy and any relevant regulations (HIPAA, Gramm-Leach-Bliley, etc.). &lt;br /&gt;
&lt;br /&gt;
An RBAC access control framework should provide web application security administrators with the ability to determine who can perform what actions, when, from where, in what order, and in some cases under what relational circumstances. http://csrc.nist.gov/rbac/ provides some great resources for RBAC implementation. The following aspects exhibit RBAC attributes to an access control model.&lt;br /&gt;
*Roles are assigned based on organizational structure with emphasis on the organizational security policy&lt;br /&gt;
*Roles are assigned by the administrator based on relative relationships within the organization or user base. For instance, a manager would have certain authorized transactions over his employees. An administrator would have certain authorized transactions over his specific realm of duties (backup, account creation, etc.) &lt;br /&gt;
*Each role is designated a profile that includes all authorized commands, transactions, and allowable information access.&lt;br /&gt;
*Roles are granted permissions based on the principle of least privilege.&lt;br /&gt;
*Roles are determined with a separation of duties in mind so that a developer Role should not overlap a QA tester Role.&lt;br /&gt;
*Roles are activated statically and dynamically as appropriate to certain relational triggers (help desk queue, security alert, initiation of a new project, etc.) &lt;br /&gt;
*Roles can be only be transferred or delegated using strict sign-offs and procedures.&lt;br /&gt;
*Roles are managed centrally by a security administrator or project leader&lt;br /&gt;
&lt;br /&gt;
OWASP has a role based access control implementation project, [[OWASP_PHPRBAC_Project|OWASP RBAC Project]].&lt;br /&gt;
&lt;br /&gt;
== Discretionary Access Control (DAC) ==&lt;br /&gt;
&lt;br /&gt;
Discretionary Access Control (DAC) is a means of restricting access to information based on the identity of users and/or membership in certain groups. Access decisions are typically based on the authorizations granted to a user based on the credentials he presented at the time of authentication (user name, password, hardware/software token, etc.). In most typical DAC models, the owner of information or any resource is able to change its permissions at his discretion (thus the name). DAC has the drawback of the administrators not being able to centrally manage these permissions on files/information stored on the web server. A DAC access control model often exhibits one or more of the following attributes.&lt;br /&gt;
*Data Owners can transfer ownership of information to other users &lt;br /&gt;
*Data Owners can determine the type of access given to other users (read, write, copy, etc.) &lt;br /&gt;
*Repetitive authorization failures to access the same resource or object generates an alarm and/or restricts the user's access&lt;br /&gt;
*Special add-on or plug-in software required to apply to an HTTP client to prevent indiscriminate copying by users (&amp;quot;cutting and pasting&amp;quot; of information) &lt;br /&gt;
*Users who do not have access to information should not be able to determine its characteristics (file size, file name, directory path, etc.) &lt;br /&gt;
*Access to information is determined based on authorizations to access control lists based on user identifier and group membership.&lt;br /&gt;
&lt;br /&gt;
== Mandatory Access Control (MAC) ==&lt;br /&gt;
&lt;br /&gt;
Mandatory Access Control (MAC) ensures that the enforcement of organizational security policy does not rely on voluntary web application user compliance. MAC secures information by assigning sensitivity labels on information and comparing this to the level of sensitivity a user is operating at. In general, MAC access control mechanisms are more secure than DAC yet have trade offs in performance and convenience to users. MAC mechanisms assign a security level to all information, assign a security clearance to each user, and ensure that all users only have access to that data for which they have a clearance. MAC is usually appropriate for extremely secure systems including multilevel secure military applications or mission critical data applications. A MAC access control model often exhibits one or more of the following attributes.&lt;br /&gt;
*Only administrators, not data owners, make changes to a resource's security label. &lt;br /&gt;
*All data is assigned security level that reflects its relative sensitivity, confidentiality, and protection value.&lt;br /&gt;
*All users can read from a lower classification than the one they are granted (A &amp;quot;secret&amp;quot; user can read an unclassified document).&lt;br /&gt;
*All users can write to a higher classification (A &amp;quot;secret&amp;quot; user can post information to a Top Secret resource). &lt;br /&gt;
*All users are given read/write access to objects only of the same classification (a &amp;quot;secret&amp;quot; user can only read/write to a secret document).&lt;br /&gt;
*Access is authorized or restricted to objects based on the time of day depending on the labeling on the resource and the user's credentials (driven by policy). &lt;br /&gt;
*Access is authorized or restricted to objects based on the security characteristics of the HTTP client (e.g. SSL bit length, version information, originating IP address or domain, etc.)&lt;br /&gt;
&lt;br /&gt;
== Attribute Based Access Control (ABAC) ==&lt;br /&gt;
&lt;br /&gt;
[http://csrc.nist.gov/publications/drafts/800-162/sp800_162_draft.pdf NIST Special Publication (SP) 800-162 (Draft)]&lt;br /&gt;
&lt;br /&gt;
=Attacks on Access Control=&lt;br /&gt;
&lt;br /&gt;
Vertical Access Control Attacks - A standard user accessing administration functionality&lt;br /&gt;
&lt;br /&gt;
Horizontal Access Control attacks - Same role, but accessing another user's private data&lt;br /&gt;
&lt;br /&gt;
Business Logic Access Control Attacks - Abuse of one or more linked activities that collectively realize a business objective&lt;br /&gt;
&lt;br /&gt;
=Access Control Issues=&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;
&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;
	&lt;br /&gt;
*Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
&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;
	&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;
==Hard Coded Roles==&lt;br /&gt;
&lt;br /&gt;
  if (user.isManager() ||&lt;br /&gt;
      user.isAdministrator() ||&lt;br /&gt;
      user.isEditor() ||&lt;br /&gt;
      user.isUser()) {&lt;br /&gt;
      //execute action&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
'''Hard Codes Roles can create several issues including:'''&lt;br /&gt;
&lt;br /&gt;
*Making the policy of an application difficult to &amp;quot;prove&amp;quot; for audit or Q/A purposes &lt;br /&gt;
*Causing new code to be pushed each time an access control policy needs to be changed. &lt;br /&gt;
*They are fragile and easy to make mistakes&lt;br /&gt;
&lt;br /&gt;
==Order Specific Operations==&lt;br /&gt;
&lt;br /&gt;
Imagine the following parameters&lt;br /&gt;
&lt;br /&gt;
  http://example.com/buy?action=chooseDataPackage&lt;br /&gt;
  http://example.com/buy?action=customizePackage&lt;br /&gt;
  http://example.com/buy?action=makePayment&lt;br /&gt;
  http://example.com/buy?action=downloadData&lt;br /&gt;
&lt;br /&gt;
'''Can an attacker control the sequence?'''&lt;br /&gt;
&lt;br /&gt;
'''Can an attacker abuse this with concurrency?'''&lt;br /&gt;
&lt;br /&gt;
==Never Depend on Untrusted Data==&lt;br /&gt;
&lt;br /&gt;
*Never trust user data for access control decisions&lt;br /&gt;
*Never make access control decisions in JavaScript&lt;br /&gt;
*Never depend on the order of values sent from the client&lt;br /&gt;
*Never make authorization decisions based solely on&lt;br /&gt;
**hidden fields&lt;br /&gt;
**cookie values&lt;br /&gt;
**form parameters&lt;br /&gt;
**URL parameters&lt;br /&gt;
**anything else from the request&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=Attacking Access Controls=&lt;br /&gt;
&lt;br /&gt;
*Elevation of privileges&lt;br /&gt;
*Disclosure of confidential data - Compromising admin-level accounts often result in access to a user's confidential data&lt;br /&gt;
*Data tampering - Privilege levels do not distinguish users who can only view data and users permitted to modify data&lt;br /&gt;
&lt;br /&gt;
=Testing for Broken Access Control=&lt;br /&gt;
&lt;br /&gt;
*Attempt to access administrative components or functions as an anonymous or regular user&lt;br /&gt;
**Scour HTML source for “interesting” hidden form fields&lt;br /&gt;
**Test web accessible directory structure for names like admin, administrator, manager, etc (i.e. attempt to directly browse to “restricted” areas)&lt;br /&gt;
*Determine how administrators are authenticated. Ensure that adequate authentication is used and enforced&lt;br /&gt;
*For each user role, ensure that only the appropriate pages or components are accessible for that role.&lt;br /&gt;
*Login as a low-level user, browse history for a higher level user’s cache, load the page to see if the original authorization is passed to a previous session.&lt;br /&gt;
*If able to compromise administrator-level account, test for all other common web application vulnerabilities (poor input validation, privileged database access, etc)&lt;br /&gt;
&lt;br /&gt;
=Defenses Against Access Control Attacks=&lt;br /&gt;
&lt;br /&gt;
*Implement role based access control to assign permissions to application users for vertical access control requirements&lt;br /&gt;
*Implement data-contextual access control to assign permissions to application users in the context of specific data items for horizontal access control requirements&lt;br /&gt;
*Avoid assigning permissions on a per-user basis&lt;br /&gt;
*Perform consistent authorization checking routines on all application pages&lt;br /&gt;
*Where applicable, apply DENY privileges last, issue ALLOW privileges on a case-by-case basis&lt;br /&gt;
*Where possible restrict administrator access to machines located on the local area network (i.e. it’s best to avoid remote administrator access from public facing access points)&lt;br /&gt;
*Log all failed access authorization requests to a secure location for review by administrators&lt;br /&gt;
*Perform reviews of failed login attempts on a periodic basis&lt;br /&gt;
*Utilize the strengths and functionality provided by the SSO solution you chose&lt;br /&gt;
&lt;br /&gt;
'''Java'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ( authenticated ) {&lt;br /&gt;
&lt;br /&gt;
	request.getSession(true).setValue(“AUTHLEVEL”) = X_USER;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''.NET (C#)'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ( authenticated ) {&lt;br /&gt;
&lt;br /&gt;
	Session[“AUTHLEVEL”] = X_USER;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''PHP'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ( authenticated ) {&lt;br /&gt;
&lt;br /&gt;
	$_SESSION[‘authlevel’] = X_USER; 	// X_USER is defined elsewhere as meaning, the user is authorized&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Best Practices=&lt;br /&gt;
&lt;br /&gt;
==Best Practice: Code to the Activity==&lt;br /&gt;
&lt;br /&gt;
   if (AC.hasAccess(ARTICLE_EDIT)) {&lt;br /&gt;
       //execute activity&lt;br /&gt;
   }&lt;br /&gt;
*Code it once, never needs to change again&lt;br /&gt;
*Implies policy is persisted/centralized in some way&lt;br /&gt;
*Avoid assigning permissions on a per-user basis&lt;br /&gt;
*Requires more design/work up front to get right&lt;br /&gt;
&lt;br /&gt;
==Best Practice: Centralized ACL Controller==&lt;br /&gt;
&lt;br /&gt;
*Define a centralized access controller&lt;br /&gt;
      ACLService.isAuthorized(ACTION_CONSTANT)&lt;br /&gt;
      ACLService.assertAuthorized(ACTION_CONSTANT)&lt;br /&gt;
*Access control decisions go through these simple API’s&lt;br /&gt;
*Centralized logic to drive policy behavior and persistence&lt;br /&gt;
*May contain data-driven access control policy information&lt;br /&gt;
*Policy language needs to support ability to express both access rights and prohibitions&lt;br /&gt;
&lt;br /&gt;
==Best Practice: Using a Centralized Access Controller==&lt;br /&gt;
&lt;br /&gt;
*In Presentation Layer&lt;br /&gt;
&lt;br /&gt;
       if (isAuthorized(VIEW_LOG_PANEL))&lt;br /&gt;
       {&lt;br /&gt;
          Here are the logs&lt;br /&gt;
          &amp;lt;%=getLogs();%/&amp;gt;&lt;br /&gt;
       }&lt;br /&gt;
	&lt;br /&gt;
*In Controller&lt;br /&gt;
&lt;br /&gt;
       try (assertAuthorized(DELETE_USER))&lt;br /&gt;
       {&lt;br /&gt;
          deleteUser();&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
==Best Practice: Verifying policy server-side==&lt;br /&gt;
&lt;br /&gt;
*Keep user identity verification in session&lt;br /&gt;
*Load entitlements server side from trusted sources&lt;br /&gt;
*Force authorization checks on ALL requests&lt;br /&gt;
**JS file, image, AJAX and FLASH requests as well!&lt;br /&gt;
**Force this check using a filter if possible&lt;br /&gt;
&lt;br /&gt;
=SQL Integrated Access Control=&lt;br /&gt;
&lt;br /&gt;
'''Example Feature'''&lt;br /&gt;
&lt;br /&gt;
    http://mail.example.com/viewMessage?msgid=2356342&lt;br /&gt;
&lt;br /&gt;
'''This SQL would be vulnerable to tampering'''&lt;br /&gt;
&lt;br /&gt;
  select * from messages where messageid = 2356342&lt;br /&gt;
&lt;br /&gt;
'''Ensure the owner is referenced in the query!'''&lt;br /&gt;
&lt;br /&gt;
  select * from messages where messageid = 2356342 AND messages.message_owner = &lt;br /&gt;
&lt;br /&gt;
=Access Control Positive Patterns=&lt;br /&gt;
&lt;br /&gt;
*Code to the activity, not the role&lt;br /&gt;
*Centralize access control logic&lt;br /&gt;
*Design access control as a filter&lt;br /&gt;
*Deny by default, fail securely&lt;br /&gt;
*Build centralized access control mechanism&lt;br /&gt;
*Apply same core logic to presentation and server-side access control decisions&lt;br /&gt;
*Determine access control through Server-side trusted data&lt;br /&gt;
&lt;br /&gt;
=Data Contextual Access Control=&lt;br /&gt;
&lt;br /&gt;
'''Data Contextual / Horizontal Access Control API examples'''&lt;br /&gt;
&lt;br /&gt;
    ACLService.isAuthorized(EDIT_ORG, 142)&lt;br /&gt;
    ACLService.assertAuthorized(VIEW_ORG, 900)&lt;br /&gt;
&lt;br /&gt;
Long Form&lt;br /&gt;
&lt;br /&gt;
    isAuthorized(user, EDIT_ORG, Organization.class, 14)&lt;br /&gt;
	&lt;br /&gt;
*Essentially checking if the user has the right role in the context of a specific object&lt;br /&gt;
*Centralize access control logic&lt;br /&gt;
*Protecting data at the lowest level!&lt;br /&gt;
&lt;br /&gt;
=Authors and Primary Editors=&lt;br /&gt;
&lt;br /&gt;
Jim Manico - jim [at] owasp dot org&amp;lt;br/&amp;gt;&lt;br /&gt;
Fred Donovan - fred.donovan [at] owasp dot org&amp;lt;br/&amp;gt;&lt;br /&gt;
Mennouchi Islam Azeddine - azeddine.mennouchi [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>Jkurucar</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Access_Control_Cheat_Sheet&amp;diff=196477</id>
		<title>Access Control Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Access_Control_Cheat_Sheet&amp;diff=196477"/>
				<updated>2015-06-22T16:39:03Z</updated>
		
		<summary type="html">&lt;p&gt;Jkurucar: /* What is Access Control / Authorization? */&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 is focused on providing clear, simple, actionable guidance for providing Access Control security in your applications.&lt;br /&gt;
&lt;br /&gt;
==What is Access Control / Authorization?==&lt;br /&gt;
&lt;br /&gt;
Authorization 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 - as these terms and their definitions are frequently confused.  Authentication is providing and validating identity.  In a system that uses a simple username and password scheme, the authentication process collects the username and validates the identity using the password.  Authorization is the execution of access control properties, ensuring the proper allocation of access rights once authentication is successful.&lt;br /&gt;
&lt;br /&gt;
Access Control is the method or mechanism of authorization to enforce that requests to a system resource or functionality should be granted.&lt;br /&gt;
&lt;br /&gt;
== Role Based Access Control (RBAC) ==&lt;br /&gt;
In Role-Based Access Control (RBAC), access decisions are based on an individual's roles and responsibilities within the organization or user base. The process of defining roles is usually based on analyzing the fundamental goals and structure of an organization and is usually linked to the security policy. For instance, in a medical organization, the different roles of users may include those such as doctor, nurse, attendant, nurse, patients, etc. Obviously, these members require different levels of access in order to perform their functions, but also the types of web transactions and their allowed context vary greatly depending on the security policy and any relevant regulations (HIPAA, Gramm-Leach-Bliley, etc.). &lt;br /&gt;
&lt;br /&gt;
An RBAC access control framework should provide web application security administrators with the ability to determine who can perform what actions, when, from where, in what order, and in some cases under what relational circumstances. http://csrc.nist.gov/rbac/ provides some great resources for RBAC implementation. The following aspects exhibit RBAC attributes to an access control model.&lt;br /&gt;
*Roles are assigned based on organizational structure with emphasis on the organizational security policy&lt;br /&gt;
*Roles are assigned by the administrator based on relative relationships within the organization or user base. For instance, a manager would have certain authorized transactions over his employees. An administrator would have certain authorized transactions over his specific realm of duties (backup, account creation, etc.) &lt;br /&gt;
*Each role is designated a profile that includes all authorized commands, transactions, and allowable information access.&lt;br /&gt;
*Roles are granted permissions based on the principle of least privilege.&lt;br /&gt;
*Roles are determined with a separation of duties in mind so that a developer Role should not overlap a QA tester Role.&lt;br /&gt;
*Roles are activated statically and dynamically as appropriate to certain relational triggers (help desk queue, security alert, initiation of a new project, etc.) &lt;br /&gt;
*Roles can be only be transferred or delegated using strict sign-offs and procedures.&lt;br /&gt;
*Roles are managed centrally by a security administrator or project leader&lt;br /&gt;
&lt;br /&gt;
OWASP has a role based access control implementation project, [[OWASP_PHPRBAC_Project|OWASP RBAC Project]].&lt;br /&gt;
&lt;br /&gt;
== Discretionary Access Control (DAC)' ==&lt;br /&gt;
&lt;br /&gt;
Discretionary Access Control (DAC) is a means of restricting access to information based on the identity of users and/or membership in certain groups. Access decisions are typically based on the authorizations granted to a user based on the credentials he presented at the time of authentication (user name, password, hardware/software token, etc.). In most typical DAC models, the owner of information or any resource is able to change its permissions at his discretion (thus the name). DAC has the drawback of the administrators not being able to centrally manage these permissions on files/information stored on the web server. A DAC access control model often exhibits one or more of the following attributes.&lt;br /&gt;
*Data Owners can transfer ownership of information to other users &lt;br /&gt;
*Data Owners can determine the type of access given to other users (read, write, copy, etc.) &lt;br /&gt;
*Repetitive authorization failures to access the same resource or object generates an alarm and/or restricts the user's access&lt;br /&gt;
*Special add-on or plug-in software required to apply to an HTTP client to prevent indiscriminate copying by users (&amp;quot;cutting and pasting&amp;quot; of information) &lt;br /&gt;
*Users who do not have access to information should not be able to determine its characteristics (file size, file name, directory path, etc.) &lt;br /&gt;
*Access to information is determined based on authorizations to access control lists based on user identifier and group membership.&lt;br /&gt;
&lt;br /&gt;
== Mandatory Access Control (MAC) ==&lt;br /&gt;
&lt;br /&gt;
Mandatory Access Control (MAC) ensures that the enforcement of organizational security policy does not rely on voluntary web application user compliance. MAC secures information by assigning sensitivity labels on information and comparing this to the level of sensitivity a user is operating at. In general, MAC access control mechanisms are more secure than DAC yet have trade offs in performance and convenience to users. MAC mechanisms assign a security level to all information, assign a security clearance to each user, and ensure that all users only have access to that data for which they have a clearance. MAC is usually appropriate for extremely secure systems including multilevel secure military applications or mission critical data applications. A MAC access control model often exhibits one or more of the following attributes.&lt;br /&gt;
*Only administrators, not data owners, make changes to a resource's security label. &lt;br /&gt;
*All data is assigned security level that reflects its relative sensitivity, confidentiality, and protection value.&lt;br /&gt;
*All users can read from a lower classification than the one they are granted (A &amp;quot;secret&amp;quot; user can read an unclassified document).&lt;br /&gt;
*All users can write to a higher classification (A &amp;quot;secret&amp;quot; user can post information to a Top Secret resource). &lt;br /&gt;
*All users are given read/write access to objects only of the same classification (a &amp;quot;secret&amp;quot; user can only read/write to a secret document).&lt;br /&gt;
*Access is authorized or restricted to objects based on the time of day depending on the labeling on the resource and the user's credentials (driven by policy). &lt;br /&gt;
*Access is authorized or restricted to objects based on the security characteristics of the HTTP client (e.g. SSL bit length, version information, originating IP address or domain, etc.)&lt;br /&gt;
&lt;br /&gt;
== Attribute Based Access Control (ABAC) ==&lt;br /&gt;
&lt;br /&gt;
[http://csrc.nist.gov/publications/drafts/800-162/sp800_162_draft.pdf NIST Special Publication (SP) 800-162 (Draft)]&lt;br /&gt;
&lt;br /&gt;
=Attacks on Access Control=&lt;br /&gt;
&lt;br /&gt;
Vertical Access Control Attacks - A standard user accessing administration functionality&lt;br /&gt;
&lt;br /&gt;
Horizontal Access Control attacks - Same role, but accessing another user's private data&lt;br /&gt;
&lt;br /&gt;
Business Logic Access Control Attacks - Abuse of one or more linked activities that collectively realize a business objective&lt;br /&gt;
&lt;br /&gt;
=Access Control Issues=&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;
&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;
	&lt;br /&gt;
*Applications with multiple permission levels/roles often increases the possibility of conflicting permission sets resulting in unanticipated privileges&lt;br /&gt;
&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;
	&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;
==Hard Coded Roles==&lt;br /&gt;
&lt;br /&gt;
  if (user.isManager() ||&lt;br /&gt;
      user.isAdministrator() ||&lt;br /&gt;
      user.isEditor() ||&lt;br /&gt;
      user.isUser()) {&lt;br /&gt;
      //execute action&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
'''Hard Codes Roles can create several issues including:'''&lt;br /&gt;
&lt;br /&gt;
*Making the policy of an application difficult to &amp;quot;prove&amp;quot; for audit or Q/A purposes &lt;br /&gt;
*Causing new code to be pushed each time an access control policy needs to be changed. &lt;br /&gt;
*They are fragile and easy to make mistakes&lt;br /&gt;
&lt;br /&gt;
==Order Specific Operations==&lt;br /&gt;
&lt;br /&gt;
Imagine the following parameters&lt;br /&gt;
&lt;br /&gt;
  http://example.com/buy?action=chooseDataPackage&lt;br /&gt;
  http://example.com/buy?action=customizePackage&lt;br /&gt;
  http://example.com/buy?action=makePayment&lt;br /&gt;
  http://example.com/buy?action=downloadData&lt;br /&gt;
&lt;br /&gt;
'''Can an attacker control the sequence?'''&lt;br /&gt;
&lt;br /&gt;
'''Can an attacker abuse this with concurrency?'''&lt;br /&gt;
&lt;br /&gt;
==Never Depend on Untrusted Data==&lt;br /&gt;
&lt;br /&gt;
*Never trust user data for access control decisions&lt;br /&gt;
*Never make access control decisions in JavaScript&lt;br /&gt;
*Never depend on the order of values sent from the client&lt;br /&gt;
*Never make authorization decisions based solely on&lt;br /&gt;
**hidden fields&lt;br /&gt;
**cookie values&lt;br /&gt;
**form parameters&lt;br /&gt;
**URL parameters&lt;br /&gt;
**anything else from the request&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=Attacking Access Controls=&lt;br /&gt;
&lt;br /&gt;
*Elevation of privileges&lt;br /&gt;
*Disclosure of confidential data - Compromising admin-level accounts often result in access to a user's confidential data&lt;br /&gt;
*Data tampering - Privilege levels do not distinguish users who can only view data and users permitted to modify data&lt;br /&gt;
&lt;br /&gt;
=Testing for Broken Access Control=&lt;br /&gt;
&lt;br /&gt;
*Attempt to access administrative components or functions as an anonymous or regular user&lt;br /&gt;
**Scour HTML source for “interesting” hidden form fields&lt;br /&gt;
**Test web accessible directory structure for names like admin, administrator, manager, etc (i.e. attempt to directly browse to “restricted” areas)&lt;br /&gt;
*Determine how administrators are authenticated. Ensure that adequate authentication is used and enforced&lt;br /&gt;
*For each user role, ensure that only the appropriate pages or components are accessible for that role.&lt;br /&gt;
*Login as a low-level user, browse history for a higher level user’s cache, load the page to see if the original authorization is passed to a previous session.&lt;br /&gt;
*If able to compromise administrator-level account, test for all other common web application vulnerabilities (poor input validation, privileged database access, etc)&lt;br /&gt;
&lt;br /&gt;
=Defenses Against Access Control Attacks=&lt;br /&gt;
&lt;br /&gt;
*Implement role based access control to assign permissions to application users for vertical access control requirements&lt;br /&gt;
*Implement data-contextual access control to assign permissions to application users in the context of specific data items for horizontal access control requirements&lt;br /&gt;
*Avoid assigning permissions on a per-user basis&lt;br /&gt;
*Perform consistent authorization checking routines on all application pages&lt;br /&gt;
*Where applicable, apply DENY privileges last, issue ALLOW privileges on a case-by-case basis&lt;br /&gt;
*Where possible restrict administrator access to machines located on the local area network (i.e. it’s best to avoid remote administrator access from public facing access points)&lt;br /&gt;
*Log all failed access authorization requests to a secure location for review by administrators&lt;br /&gt;
*Perform reviews of failed login attempts on a periodic basis&lt;br /&gt;
*Utilize the strengths and functionality provided by the SSO solution you chose&lt;br /&gt;
&lt;br /&gt;
'''Java'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ( authenticated ) {&lt;br /&gt;
&lt;br /&gt;
	request.getSession(true).setValue(“AUTHLEVEL”) = X_USER;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''.NET (C#)'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ( authenticated ) {&lt;br /&gt;
&lt;br /&gt;
	Session[“AUTHLEVEL”] = X_USER;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''PHP'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ( authenticated ) {&lt;br /&gt;
&lt;br /&gt;
	$_SESSION[‘authlevel’] = X_USER; 	// X_USER is defined elsewhere as meaning, the user is authorized&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Best Practices=&lt;br /&gt;
&lt;br /&gt;
==Best Practice: Code to the Activity==&lt;br /&gt;
&lt;br /&gt;
   if (AC.hasAccess(ARTICLE_EDIT)) {&lt;br /&gt;
       //execute activity&lt;br /&gt;
   }&lt;br /&gt;
*Code it once, never needs to change again&lt;br /&gt;
*Implies policy is persisted/centralized in some way&lt;br /&gt;
*Avoid assigning permissions on a per-user basis&lt;br /&gt;
*Requires more design/work up front to get right&lt;br /&gt;
&lt;br /&gt;
==Best Practice: Centralized ACL Controller==&lt;br /&gt;
&lt;br /&gt;
*Define a centralized access controller&lt;br /&gt;
      ACLService.isAuthorized(ACTION_CONSTANT)&lt;br /&gt;
      ACLService.assertAuthorized(ACTION_CONSTANT)&lt;br /&gt;
*Access control decisions go through these simple API’s&lt;br /&gt;
*Centralized logic to drive policy behavior and persistence&lt;br /&gt;
*May contain data-driven access control policy information&lt;br /&gt;
*Policy language needs to support ability to express both access rights and prohibitions&lt;br /&gt;
&lt;br /&gt;
==Best Practice: Using a Centralized Access Controller==&lt;br /&gt;
&lt;br /&gt;
*In Presentation Layer&lt;br /&gt;
&lt;br /&gt;
       if (isAuthorized(VIEW_LOG_PANEL))&lt;br /&gt;
       {&lt;br /&gt;
          Here are the logs&lt;br /&gt;
          &amp;lt;%=getLogs();%/&amp;gt;&lt;br /&gt;
       }&lt;br /&gt;
	&lt;br /&gt;
*In Controller&lt;br /&gt;
&lt;br /&gt;
       try (assertAuthorized(DELETE_USER))&lt;br /&gt;
       {&lt;br /&gt;
          deleteUser();&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
==Best Practice: Verifying policy server-side==&lt;br /&gt;
&lt;br /&gt;
*Keep user identity verification in session&lt;br /&gt;
*Load entitlements server side from trusted sources&lt;br /&gt;
*Force authorization checks on ALL requests&lt;br /&gt;
**JS file, image, AJAX and FLASH requests as well!&lt;br /&gt;
**Force this check using a filter if possible&lt;br /&gt;
&lt;br /&gt;
=SQL Integrated Access Control=&lt;br /&gt;
&lt;br /&gt;
'''Example Feature'''&lt;br /&gt;
&lt;br /&gt;
    http://mail.example.com/viewMessage?msgid=2356342&lt;br /&gt;
&lt;br /&gt;
'''This SQL would be vulnerable to tampering'''&lt;br /&gt;
&lt;br /&gt;
  select * from messages where messageid = 2356342&lt;br /&gt;
&lt;br /&gt;
'''Ensure the owner is referenced in the query!'''&lt;br /&gt;
&lt;br /&gt;
  select * from messages where messageid = 2356342 AND messages.message_owner = &lt;br /&gt;
&lt;br /&gt;
=Access Control Positive Patterns=&lt;br /&gt;
&lt;br /&gt;
*Code to the activity, not the role&lt;br /&gt;
*Centralize access control logic&lt;br /&gt;
*Design access control as a filter&lt;br /&gt;
*Deny by default, fail securely&lt;br /&gt;
*Build centralized access control mechanism&lt;br /&gt;
*Apply same core logic to presentation and server-side access control decisions&lt;br /&gt;
*Determine access control through Server-side trusted data&lt;br /&gt;
&lt;br /&gt;
=Data Contextual Access Control=&lt;br /&gt;
&lt;br /&gt;
'''Data Contextual / Horizontal Access Control API examples'''&lt;br /&gt;
&lt;br /&gt;
    ACLService.isAuthorized(EDIT_ORG, 142)&lt;br /&gt;
    ACLService.assertAuthorized(VIEW_ORG, 900)&lt;br /&gt;
&lt;br /&gt;
Long Form&lt;br /&gt;
&lt;br /&gt;
    isAuthorized(user, EDIT_ORG, Organization.class, 14)&lt;br /&gt;
	&lt;br /&gt;
*Essentially checking if the user has the right role in the context of a specific object&lt;br /&gt;
*Centralize access control logic&lt;br /&gt;
*Protecting data at the lowest level!&lt;br /&gt;
&lt;br /&gt;
=Authors and Primary Editors=&lt;br /&gt;
&lt;br /&gt;
Jim Manico - jim [at] owasp dot org&amp;lt;br/&amp;gt;&lt;br /&gt;
Fred Donovan - fred.donovan [at] owasp dot org&amp;lt;br/&amp;gt;&lt;br /&gt;
Mennouchi Islam Azeddine - azeddine.mennouchi [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>Jkurucar</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Intrusion_Detection&amp;diff=196414</id>
		<title>Intrusion Detection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Intrusion_Detection&amp;diff=196414"/>
				<updated>2015-06-20T23:59:42Z</updated>
		
		<summary type="html">&lt;p&gt;Jkurucar: /* Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Control}}&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
Within the past few years, the line between Intrusion Detection and Intrusion Prevention systems (IDS and IPS respectively) has become increasingly blurred.  However, these two controls are distinguished primarily by how they respond to detected attacks.  While an Intrusion Detection system passively monitors for attacks and provides notification services, an Intrusion Prevention system actively stops the threat.  For example, a Network Intrusion Detection system (NIDS) will monitor network traffic and alert security personnel upon discovery of an attack.  A Network Intrusion Prevention system (NIPS) functions more like a stateful firewall and will automatically drop packets upon discovery of an attack.&lt;br /&gt;
&lt;br /&gt;
There are two primary reasons why many organizations favor the use of IDSs over IPSs.  The first is that, in the event of a false positive (normal activity mistakenly identified as an attack), an IPS will actively stop the normal activity which is likely to negatively impact business functions.  An IDS, on the other hand, will only notify on the false positive and will not impact business functions while the security professional verifies the validity of the alert.  The second reason is that IPSs can become a serious bottleneck.  While IPSs must be placed in-line in order to actively stop attacks, and IDS may be placed on a mirrored port, thus preventing a potential bottle neck.&lt;br /&gt;
&lt;br /&gt;
Intrusion detection is an important countermeasure for most applications, especially client-server applications like web applications and web services. Many newer technologies are beginning to include integrated services such as a single device that incorporates a firewall, IDS, and limited IPS functionality.  [[Logging]] is an important aspect of intrusion detection, but is best viewed as a way to record intrusion-related activity, not to determine what is an intrusion in the first place. The vast majority of applications do not detect attacks, but instead try their best to fulfill the attackers' requests.&lt;br /&gt;
&lt;br /&gt;
Lack of intrusion detection allows an attacker to attempt attacks until a successful one is identified. Intrusion detection allows the attack to be identified long before a successful attack is likely. It is not very difficult for a web application to identify some attack traffic. A simple rule-of-thumb is that if the traffic could not have reasonably been generated by a legitimate user of the application, it is almost certainly an attack. Once alerted by the IDS and the attacks are identified, then the security professional can respond appropriately. Typically, this means logging off the user, invalidating their account, potentially recording information for the authorities, or patching the root cause vulnerability.&lt;br /&gt;
&lt;br /&gt;
There are three types of requests that an application might receive:&lt;br /&gt;
* Almost certainly an attack&lt;br /&gt;
* Not sure whether it an attack or not&lt;br /&gt;
* Almost certainly legitimate input&lt;br /&gt;
&lt;br /&gt;
The question for application developers is how to deal with these three categories. The safest rule is to assume that everything except legitimate traffic is an attack. However, this will probably create a lot of false alarms for users. So perhaps it is best to accept the requests that you are not sure about and log some extra information so that you can investigate it later. This is a policy decision that you should make during the requirements phase of the lifecycle.&lt;br /&gt;
&lt;br /&gt;
In terms of the accuracy of an IDS, there are four possible states for each activity observed.  A true positive state is when the IDS identifies an activity as an attack and the activity is actually an attack.  A true positive is a successful identification of an attack.  A true negative state is similar.  This is when the IDS identifies an activity as acceptable behavior and the activity is actually acceptable.  A true negative is successfully ignoring acceptable behavior.  Neither of these states are harmful as the IDS is performing as expected.  A '''false positive''' state is when the IDS identifies an activity as an attack but the activity is acceptable behavior.  A false positive is a false alarm.  A '''false negative''' state is the most serious and dangerous state.  This is when the IDS identifies an activity as acceptable when the activity is actually an attack.  That is, a false negative is when the IDS fails to catch an attack.  This is the most dangerous state since the security professional has no idea that an attack took place.  False positives, on the other hand, are an inconvenience at best and can cause significant issues.  However, with the right amount of overhead, false positives can be successfully adjudicated; false negatives cannot.&lt;br /&gt;
&lt;br /&gt;
There are different types of Intrusion Detection systems based on different approaches.  The two main divisions exist between signature based IDSs and behavioral IDSs.  There are multiple subcategories depending on the specific implementation.  Signature based IDSs, like Snort, function like anti-virus software.  They have known attack lists against which they check new activity for attacks.  If the new activity matches a known attack signature, the system will generate an alert.  Behavioral based IDSs work differently.  They learn, through a number of methods (the most popular of which is statistical analysis), what constitutes normal behavior.  Once the system has a profile of normal behavior, it aims to detect abnormal behavior, which generates alerts.  Currently, signature based systems are more common since they are more reliable (less false negatives), provide less false positives, and allow for easier false positive resolution.  Behavioral based IDSs tend to be less accurate (more false negatives), produce an extremely large number of false positives, and false positives are more difficult to adjudicate.  That being said, it is possible for a behavioral IDS to identify novel attacks like zero day exploits, given that the novel attack varies from normal behavior.  A signature based IDS cannot ever identify novel attacks like zero day exploits since it identifies attacks based on known attack signatures.&lt;br /&gt;
&lt;br /&gt;
In addition, there are different types of Intrusion Detection systems based on the goal of the system.  While the market on the following types of IDSs is become more and more fractured, the primary types by goal are '''Network based IDSs (NIDS)''' and '''Host based IDSs (HIDS)'''.  There are some extensions of this dichotomy to include distributed IDSs and comprehensive host based security systems.  However, the main distinction is the goal and placement of the IDS.  A NIDS monitors network traffic, usually on a mirrored port or in-line and can be placed in a variety of locations on the network.  NIDS work by inspecting network traffic and can be signature based or behavioral based.  HIDS monitors system logs, application logs, and other activities on a host system such as a server or user workstation.  HIDS work primarily by monitory system logs and behavior and can be signature based (include rule sets that enforce tailored security policies) or behavioral based.  Most organizations use both types of IDSs.  They use HIDSs to secure critical host systems and NIDSs to secure their network(s).&lt;br /&gt;
&lt;br /&gt;
Best practices for the placements of NIDS is a future topic.&lt;br /&gt;
&lt;br /&gt;
==Related Countermeasures==&lt;br /&gt;
* [[Input Validation]]&lt;br /&gt;
* [[Error Handling]]&lt;br /&gt;
* [[Logging]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Control]]&lt;/div&gt;</summary>
		<author><name>Jkurucar</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Jkurucar&amp;diff=195784</id>
		<title>User:Jkurucar</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Jkurucar&amp;diff=195784"/>
				<updated>2015-06-04T15:18:09Z</updated>
		
		<summary type="html">&lt;p&gt;Jkurucar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;More than five years of experience in the IT/IS profession.  Job titles include project officer, quality assurance manager, developer, and administrator.  I have numerous certifications to include CISSP, Compita Security+, A+, Network+, CASQ (Certified Associate in Software Quality), CSQA (Certified Software Quality Analyst).  I plan on adding CISM and CEH in the near future.&lt;/div&gt;</summary>
		<author><name>Jkurucar</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Denial_of_Service&amp;diff=188944</id>
		<title>Denial of Service</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Denial_of_Service&amp;diff=188944"/>
				<updated>2015-02-03T05:42:37Z</updated>
		
		<summary type="html">&lt;p&gt;Jkurucar: /* Risk Factors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Attack}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[Category:OWASP ASDR Project]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
The Denial of Service (DoS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed. There are many ways to make a service unavailable for legitimate users by manipulating network packets, programming, logical, or resources handling vulnerabilities, among others.&lt;br /&gt;
If a service receives a very large number of requests, it may cease to be available to legitimate users. In the same way, a service may stop if a programming vulnerability is exploited, or the way the service handles resources it uses.&lt;br /&gt;
&lt;br /&gt;
Sometimes the attacker can inject and execute arbitrary code while performing a DoS attack in order to access critical information or execute commands on the server.&lt;br /&gt;
Denial-of-service attacks significantly degrade the service quality experienced by legitimate users. These attacks introduce large response delays, excessive losses, and service interruptions, resulting in direct impact on availability.&lt;br /&gt;
&lt;br /&gt;
==Risk Factors==&lt;br /&gt;
Risk factors can break down into multiple categories.  Two principle sources of risk include inadequate resources and non-technical threat motivators.&lt;br /&gt;
&lt;br /&gt;
The first example of a risk factor, inadequate resources, requires attention if system architecture was not designed to meet traffic demand overflows.  This risk reduces the difficulty of successfully executing a DoS attack and can, left unchecked, result in DoS symptoms absent an actual attack.&lt;br /&gt;
&lt;br /&gt;
The second example and perhaps the largest risk factor is not technical and is in the domain of public relations or strategic communications.  An organization should avoid taking action that can make them a target of a DoS attack unless the benefits of doing so outweigh the potential costs or mitigating controls are in place.&lt;br /&gt;
&lt;br /&gt;
Other risk factors may also exist depending on the specific environment.&lt;br /&gt;
[[Category:FIXME|need content]]&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
The following DoS techniques and examples were extracted from OWASP Testing Guide v2.&lt;br /&gt;
&lt;br /&gt;
===DoS User Specified Object Allocation===&lt;br /&gt;
&lt;br /&gt;
If users can supply, directly or indirectly, a value that will specify how many of an object to create on the application server, and if the server does not enforce a hard upper limit on that value, it is possible to cause the environment to run out of available memory. The server may begin to allocate the required number of objects specified, but if this is an extremely large number, it can cause serious issues on the server, possibly filling its whole available memory and corrupting its performance. &lt;br /&gt;
&lt;br /&gt;
The following is a simple example of vulnerable code in Java: &lt;br /&gt;
&lt;br /&gt;
 String TotalObjects = request.getParameter(“numberofobjects”);&lt;br /&gt;
 int NumOfObjects = Integer.parseInt(TotalObjects);&lt;br /&gt;
 ComplexObject[] anArray = new ComplexObject[NumOfObjects];  // wrong!&lt;br /&gt;
&lt;br /&gt;
===DoS User Input as a Loop Counter===&lt;br /&gt;
&lt;br /&gt;
Similar to the previous problem of User Specified Object Allocation, if the user can directly or indirectly assign a value that will be used as a counter in a loop function, this can cause performance problems on the server. &lt;br /&gt;
&lt;br /&gt;
The following is an example of vulnerable code in Java: &lt;br /&gt;
&lt;br /&gt;
 public class MyServlet extends ActionServlet {&lt;br /&gt;
    public void doPost(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;
           throws ServletException, IOException {&lt;br /&gt;
           . . . &lt;br /&gt;
           String [] values = request.getParameterValues(&amp;quot;CheckboxField&amp;quot;);&lt;br /&gt;
       // Process the data without length check for reasonable range – wrong!&lt;br /&gt;
           for ( int i=0; i&amp;lt;values.length; i++) {&lt;br /&gt;
                 // lots of logic to process the request&lt;br /&gt;
          }&lt;br /&gt;
          . . . &lt;br /&gt;
    }&lt;br /&gt;
     . . . &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
As we can see in this simple example, the user has control over the loop counter. If the code inside the loop is very demanding in terms of resources, and an attacker forces it to be executed a very high number of times, this might decrease the performance of the server in handling other requests, causing a DoS condition. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DoS Failure to Release Resources===&lt;br /&gt;
&lt;br /&gt;
If an error occurs in the application that prevents the release of an in-use resource, it can become unavailable for further use. Possible examples include: &lt;br /&gt;
* An application locks a file for writing, and then an exception occurs but does not explicitly close and unlock the file &lt;br /&gt;
* Memory leaking in languages where the developer is responsible for memory management such as C &amp;amp; C++. In the case where an error causes normal logic flow to be circumvented, the allocated memory may not be removed and may be left in such a state that the garbage collector does not know it should be reclaimed &lt;br /&gt;
* Use of DB connection objects where the objects are not being freed if an exception is thrown. A number of such repeated requests can cause the application to consume all the DB connections, as the code will still hold the open DB object, never releasing the resource. &lt;br /&gt;
The following is an example of vulnerable code in Java. In the example, both the Connection and the CallableStatement should be closed in a finally block. &lt;br /&gt;
 public class AccountDAO {&lt;br /&gt;
     … …&lt;br /&gt;
     public void createAccount(AccountInfo acct)  &lt;br /&gt;
                  throws AcctCreationException {&lt;br /&gt;
        … …&lt;br /&gt;
            try {&lt;br /&gt;
             Connection conn = DAOFactory.getConnection();&lt;br /&gt;
             CallableStatement  calStmt = conn.prepareCall(…);&lt;br /&gt;
           …  …	&lt;br /&gt;
            calStmt.executeUpdate();&lt;br /&gt;
            calStmt.close();&lt;br /&gt;
           conn.close();&lt;br /&gt;
        }  catch (java.sql.SQLException e) {&lt;br /&gt;
             throw AcctCreationException (...);&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===DoS Buffer Overflows===&lt;br /&gt;
&lt;br /&gt;
Any language where the developer has direct responsibility for managing memory allocation, most notably C &amp;amp; C++, has the potential for a [[Buffer Overflow]]. While the most serious risk related to a buffer overflow is the ability to execute arbitrary code on the server, the first risk comes from the denial of service that can happen if the application crashes. &lt;br /&gt;
&lt;br /&gt;
The following is a simplified example of vulnerable code in C: &lt;br /&gt;
 void overflow (char *str) {&lt;br /&gt;
    char buffer[10];&lt;br /&gt;
    strcpy(buffer, str); // Dangerous!&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main () {&lt;br /&gt;
   char *str = &amp;quot;This is a string that is larger than the buffer of 10&amp;quot;;&lt;br /&gt;
   overflow(str);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If this code example were executed, it would cause a segmentation fault and dump core. The reason is that strcpy would try to copy 53 characters into an array of 10 elements only, overwriting adjacent memory locations. While this example above is an extremely simple case, the reality is that in a web based application there may be places where the user input is not adequately checked for its length, making this kind of attack possible.&lt;br /&gt;
&lt;br /&gt;
===DoS Storing too Much Data in Session===&lt;br /&gt;
&lt;br /&gt;
Care must be taken not to store too much data in a user session object. Storing too much information in the session, such as large quantities of data retrieved from the database, can cause denial of service issues. This problem is exacerbated if session data is also tracked prior to a login, as a user can launch the attack without the need of an account.&lt;br /&gt;
&lt;br /&gt;
===DoS Locking Customer Accounts===&lt;br /&gt;
&lt;br /&gt;
The first DoS case to consider involves the authentication system of the target application. A common defense to prevent brute-force discovery of user passwords is to lock an account from use after between three to five failed attempts to login. This means that even if a legitimate user were to provide their valid password, they would be unable to login to the system until their account has been unlocked. This defense mechanism can be turned into a DoS attack against an application if there is a way to predict valid login accounts. &lt;br /&gt;
&lt;br /&gt;
Note, there is a business vs. security balance that must be reached based on the specific circumstances surrounding a given application. There are pros and cons to locking accounts, to customers being able to choose their own account names, to using systems such as CAPTCHA, and the like. Each enterprise will need to balance these risks and benefits, but not all of the details of those decisions are covered here. &lt;br /&gt;
&lt;br /&gt;
==Related [[Threat Agents]]==&lt;br /&gt;
* [[:Category:Logical Attacks]]&lt;br /&gt;
[[Category:FIXME|not a threat agent]]&lt;br /&gt;
&lt;br /&gt;
==Related [[Attacks]]==&lt;br /&gt;
* [[Resource Injection]]&lt;br /&gt;
* [[Setting Manipulation]]&lt;br /&gt;
* [[Regular expression Denial of Service - ReDoS]]&lt;br /&gt;
* [[Cash Overflow]]&lt;br /&gt;
&lt;br /&gt;
==Related [[Vulnerabilities]]==&lt;br /&gt;
* [[:Category: Input Validation Vulnerability]]&lt;br /&gt;
* [[:Category: API Abuse]]&lt;br /&gt;
&lt;br /&gt;
==Related [[Controls]]==&lt;br /&gt;
* [[Blocking Brute Force Attacks]]&lt;br /&gt;
* [[Memory Management]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
* http://capec.mitre.org/data/index.html - Denial of Service through Resource Depletion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Spoofing]]&lt;br /&gt;
[[Category: Probabilistic Techniques]]&lt;br /&gt;
[[Category: Resource Depletion]]&lt;br /&gt;
[[Category:Attack]]&lt;/div&gt;</summary>
		<author><name>Jkurucar</name></author>	</entry>

	</feed>