<?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=Michael+Monsivais</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=Michael+Monsivais"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Michael_Monsivais"/>
		<updated>2026-04-09T23:52:40Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Identify_application_entry_points_(OTG-INFO-006)&amp;diff=200906</id>
		<title>Identify application entry points (OTG-INFO-006)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Identify_application_entry_points_(OTG-INFO-006)&amp;diff=200906"/>
				<updated>2015-09-21T18:37:57Z</updated>
		
		<summary type="html">&lt;p&gt;Michael Monsivais: Removed residue left from a previous edit.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
Enumerating the application and its attack surface is a key precursor before any thorough testing can be undertaken, as it allows the tester to identify likely areas of weakness. This section aims to help identify and map out areas within the application that should be investigated once enumeration and mapping have been completed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Objectives ==&lt;br /&gt;
&lt;br /&gt;
Understand how requests are formed and typical responses from the application&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to Test == &lt;br /&gt;
&lt;br /&gt;
Before any testing begins, the tester should always get a good understanding of the application and how the user and browser communicates with it.  As the tester walks through the application, they should pay special attention to all HTTP requests (GET and POST Methods, also known as Verbs), as well as every parameter and form field that is passed to the application.  In addition, they should pay attention to when GET requests are used and when POST requests are used to pass parameters to the application.  It is very common that GET requests are used, but when sensitive information is passed, it is often done within the body of a POST request.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that to see the parameters sent in a POST request, the tester will need to use a tool such as an intercepting proxy (for example, OWASP: [[OWASP_Zed_Attack_Proxy_Project| Zed Attack Proxy (ZAP)]]) or a browser plug-in.  Within the POST request, the tester should also make special note of any hidden form fields that are being passed to the application, as these usually contain sensitive information, such as state information, quantity of items, the price of items, that the developer never intended for you to see or change.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the author's experience, it has been very useful to use an intercepting proxy and a spreadsheet for this stage of the testing.  The proxy will keep track of every request and response between the tester and the application as they walk through it.  Additionally, at this point, testers usually trap every request and response so that they can see exactly every header, parameter, etc. that is being passed to the application and what is being returned.  This can be quite tedious at times, especially on large interactive sites (think of a banking application). However, experience will show what to look for and this phase can be significantly reduced.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As the tester walks through the application, they should take note of any interesting parameters in the URL, custom headers, or body of the requests/responses, and save them in a spreadsheet.  The spreadsheet should include the page requested (it might be good to also add the request number from the proxy, for future reference), the interesting parameters, the type of request (POST/GET), if access is authenticated/unauthenticated, if SSL is used, if it's part of a multi-step process, and any other relevant notes.  Once they have every area of the application mapped out, then they can go through the application and test each of the areas that they have identified and make notes for what worked and what didn't work.  The rest of this guide will identify how to test each of these areas of interest, but this section must be undertaken before any of the actual testing can commence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Below are some points of interests for all requests and responses.  Within the requests section, focus on the GET and POST methods, as these appear the majority of the requests.  Note that other methods, such as PUT and DELETE, can be used. Often, these more rare requests, if allowed, can expose vulnerabilities.  There is a special section in this guide dedicated for testing these HTTP methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Requests:'''&lt;br /&gt;
* Identify where GETs are used and where POSTs are used.&lt;br /&gt;
* Identify all parameters used in a POST request (these are in the body of the request).&lt;br /&gt;
* Within the POST request, pay special attention to any hidden parameters.  When a POST is sent all the form fields (including hidden parameters) will be sent in the body of the HTTP message to the application.  These typically aren't seen unless a proxy or view the HTML source code is used.  In addition, the next page shown, its data, and the level of access can all be different depending on the value of the hidden parameter(s).&lt;br /&gt;
* Identify all parameters used in a GET request (i.e., URL), in particular the query string (usually after a ? mark).&lt;br /&gt;
* Identify all the parameters of the query string. These usually are in a pair format, such as foo=bar. Also note that many parameters can be in one query string such as separated by a &amp;amp;, ~, :, or any other special character or encoding.&lt;br /&gt;
* A special note when it comes to identifying multiple parameters in one string or within a POST request is that some or all of the parameters will be needed to execute the attacks.  The tester needs to identify all of the parameters (even if encoded or encrypted) and identify which ones are processed by the application.  Later sections of the guide will identify how to test these parameters. At this point, just make sure each one of them is identified.&lt;br /&gt;
* Also pay attention to any additional or custom type headers not typically seen (such as debug=False).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Responses:'''&lt;br /&gt;
*Identify where new cookies are set (Set-Cookie header), modified, or added to.&lt;br /&gt;
*Identify where there are any redirects (3xx HTTP status code), 400 status codes, in particular 403 Forbidden, and 500 internal server errors during normal responses (i.e., unmodified requests).&lt;br /&gt;
*Also note where any interesting headers are used. For example, &amp;quot;Server: BIG-IP&amp;quot; indicates that the site is load balanced. Thus, if a site is load balanced and one server is incorrectly configured, then the tester might have to make multiple requests to access the vulnerable server, depending on the type of load balancing used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Black Box Testing ===&lt;br /&gt;
'''Testing for application entry points:''' &amp;lt;br&amp;gt;&lt;br /&gt;
The following are two examples on how to check for application entry points.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====EXAMPLE 1====&lt;br /&gt;
This example shows a GET request that would purchase an item from an online shopping application.&lt;br /&gt;
&lt;br /&gt;
 GET https://x.x.x.x/shoppingApp/buyme.asp?CUSTOMERID=100&amp;amp;ITEM=z101a&amp;amp;PRICE=62.50&amp;amp;IP=x.x.x.x &lt;br /&gt;
 Host: x.x.x.x&lt;br /&gt;
 Cookie: SESSIONID=Z29vZCBqb2IgcGFkYXdhIG15IHVzZXJuYW1lIGlzIGZvbyBhbmQgcGFzc3dvcmQgaXMgYmFy&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Result Expected:'''&lt;br /&gt;
&lt;br /&gt;
Here the tester would note all the parameters of the request such as CUSTOMERID, ITEM, PRICE, IP, and the Cookie (which could just be encoded parameters or used for session state).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====EXAMPLE 2====&lt;br /&gt;
This example shows a POST request that would log you into an application.&lt;br /&gt;
&lt;br /&gt;
 POST https://x.x.x.x/KevinNotSoGoodApp/authenticate.asp?service=login&lt;br /&gt;
 Host: x.x.x.x&lt;br /&gt;
 Cookie: SESSIONID=dGhpcyBpcyBhIGJhZCBhcHAgdGhhdCBzZXRzIHByZWRpY3RhYmxlIGNvb2tpZXMgYW5kIG1pbmUgaXMgMTIzNA==&lt;br /&gt;
 CustomCookie=00my00trusted00ip00is00x.x.x.x00&lt;br /&gt;
&lt;br /&gt;
Body of the POST message:&lt;br /&gt;
&lt;br /&gt;
 user=admin&amp;amp;pass=pass123&amp;amp;debug=true&amp;amp;fromtrustIP=true&lt;br /&gt;
&lt;br /&gt;
'''Result Expected:'''&lt;br /&gt;
&lt;br /&gt;
In this example the tester would note all the parameters as they have before but notice that the parameters are passed in the body of the message and not in the URL.  Additionally, note that there is a custom cookie that is being used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Gray Box Testing === &lt;br /&gt;
&lt;br /&gt;
Testing for application entry points via a Gray Box methodology would consist of everything already identified above with one addition.  In cases where there are external sources from which the application receives data and processes it (such as SNMP traps, syslog messages, SMTP, or SOAP messages from other servers) a meeting with the application developers could identify any functions that would accept or expect user input and how they are formatted.  For example, the developer could help in understanding how to formulate a correct SOAP request that the application would accept and where the web service resides (if the web service or any other function hasn't already been identified during the black box testing).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
'''Intercepting Proxy:'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*OWASP: [[OWASP_Zed_Attack_Proxy_Project| Zed Attack Proxy (ZAP)]]&lt;br /&gt;
*OWASP: [[OWASP_WebScarab_Project| WebScarab]]&lt;br /&gt;
* [http://www.portswigger.net/burp/ Burp Suite]&lt;br /&gt;
* [http://www.contextis.com/research/tools/cat/ CAT]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Browser Plug-in:'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*[http://www.bayden.com/TamperIE/ TamperIE for Internet Explorer]&lt;br /&gt;
*[https://addons.mozilla.org/en-US/firefox/addon/966 Tamper Data for Firefox]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*RFC 2616 – Hypertext Transfer Protocol – HTTP 1.1 -&lt;br /&gt;
http://tools.ietf.org/html/rfc2616&lt;/div&gt;</summary>
		<author><name>Michael Monsivais</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Michael_Monsivais&amp;diff=181385</id>
		<title>User:Michael Monsivais</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Michael_Monsivais&amp;diff=181385"/>
				<updated>2014-08-29T00:51:14Z</updated>
		
		<summary type="html">&lt;p&gt;Michael Monsivais: Adding parenthetical commas.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Michael Monsivais currently works as a Computer Penetration Tester for a, largely PCI-focused, penetration testing firm.&lt;br /&gt;
&lt;br /&gt;
Previously, Michael has worked as a Web Application Developer and as a Systems Administrator.&lt;br /&gt;
&lt;br /&gt;
He enjoys FreeBSD, OpenBSD, Linux, Python, the Bourne shell, vim, participating in CTF competitions, and reading books by firelight.&lt;/div&gt;</summary>
		<author><name>Michael Monsivais</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Clickjacking&amp;diff=181262</id>
		<title>Clickjacking</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Clickjacking&amp;diff=181262"/>
				<updated>2014-08-28T00:18:12Z</updated>
		
		<summary type="html">&lt;p&gt;Michael Monsivais: Grammar Fix.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clickjacking, also known as a &amp;quot;UI redress attack&amp;quot;, is when an attacker uses multiple transparent or opaque layers to trick a user into clicking on a button or link on another page when they were intending to click on the the top level page. Thus, the attacker is &amp;quot;hijacking&amp;quot; clicks meant for their page and routing them to another page, most likely owned by another application, domain, or both.&lt;br /&gt;
&lt;br /&gt;
Using a similar technique, keystrokes can also be hijacked. With a carefully crafted combination of stylesheets, iframes, and text boxes, a user can be led to believe they are typing in the password to their email or bank account, but are instead typing into an invisible frame controlled by the attacker.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
For example, imagine an attacker who builds a web site that has a button on it that says &amp;quot;click here for a free iPod&amp;quot;.  However, on top of that web page, the attacker has loaded an iframe with your mail account, and lined up exactly the &amp;quot;delete all messages&amp;quot; button directly on top of the &amp;quot;free iPod&amp;quot; button.  The victim tries to click on the &amp;quot;free iPod&amp;quot; button but instead actually clicked on the invisible &amp;quot;delete all messages&amp;quot; button.  In essence, the attacker has &amp;quot;hijacked&amp;quot; the user's click, hence the name &amp;quot;Clickjacking&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
One of the most notorious examples of Clickjacking was an attack against the [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager06.html Adobe Flash plugin settings page]. By loading this page into an invisible iframe, an attacker could trick a user into altering the security settings of Flash, giving permission for any Flash animation to utilize the computer's microphone and camera.&lt;br /&gt;
&lt;br /&gt;
Clickjacking also made the news in the form of a [http://shiflett.org/blog/2009/feb/twitter-dont-click-exploit Twitter worm]. This clickjacking attack convinced users to click on a button which caused them to re-tweet the location of the malicious page, and propagated massively.&lt;br /&gt;
&lt;br /&gt;
There have also been clickjacking attacks abusing Facebook's &amp;quot;Like&amp;quot; functionality. [http://threatpost.com/en_us/blogs/facebook-jacking-scams-expand-060310 Attackers can trick logged-in Facebook users to arbitrarily like fan pages, links, groups, etc]&lt;br /&gt;
&lt;br /&gt;
= Defending against Clickjacking =&lt;br /&gt;
There are two main ways to prevent clickjacking:&lt;br /&gt;
# Sending the proper X-Frame-Options HTTP response headers that instruct the browser to not allow framing from other domains&lt;br /&gt;
# Employing defensive code in the UI to ensure that the current frame is the most top level window&lt;br /&gt;
&lt;br /&gt;
For more information on Clickjacking defense, please see the the [[Clickjacking Defense Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
* https://developer.mozilla.org/en-US/docs/The_X-FRAME-OPTIONS_response_header&lt;br /&gt;
: Mozilla developer resource on The X-Frame-Options response header.&lt;br /&gt;
&lt;br /&gt;
* [http://w2spconf.com/2010/papers/p27.pdf Busting Frame Busting: A study of clickjacking vulnerabilites on top sites]&lt;br /&gt;
: A study by the Stanford Web Security Group outlining problems with deployed frame busting code.&lt;br /&gt;
&lt;br /&gt;
* [http://www.sectheory.com/clickjacking.htm Clickjacking, Sec Theory]&lt;br /&gt;
: A paper by Robert Hansen defining the term, its implications against Flash at the time of writing, and a disclosure timeline.&lt;br /&gt;
&lt;br /&gt;
* [https://www.codemagi.com/blog/post/194 https://www.codemagi.com/blog/post/194] &lt;br /&gt;
: Framebreaking defense for legacy browsers that do not support X-Frame-Option headers.&lt;br /&gt;
&lt;br /&gt;
* [[ClickjackFilter_for_Java_EE|Anti-clickjacking J2EE filter]]&lt;br /&gt;
: A simple J2EE servlet filter that sends anti-framing headers to the browser.&lt;/div&gt;</summary>
		<author><name>Michael Monsivais</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Command_Injection&amp;diff=181196</id>
		<title>Command Injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Command_Injection&amp;diff=181196"/>
				<updated>2014-08-26T22:43:37Z</updated>
		
		<summary type="html">&lt;p&gt;Michael Monsivais: Correcting grammar.&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;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}'''&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
Command injection is an attack in which the goal is execution of arbitrary commands on the host operating system via a vulnerable application. Command injection attacks are possible when an application passes unsafe user supplied data (forms, cookies, HTTP headers etc.) to a system shell. In this attack, the attacker-supplied operating system commands are usually executed with the privileges of the vulnerable application. Command injection attacks are possible largely due to insufficient input validation.&lt;br /&gt;
&lt;br /&gt;
This attack differs from [[Code Injection]], in that code injection allows the attacker to add his own code that is then executed by the application. In [[Code Injection]], the attacker extends the default functionality of the application without the necessity of executing system commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--==Risk Factors==&lt;br /&gt;
TBD&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
==Examples ==&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
&lt;br /&gt;
The following code is a wrapper around the UNIX command ''cat'' which prints the contents of a file to standard output. It is also injectable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv) {&lt;br /&gt;
 char cat[] = &amp;quot;cat &amp;quot;;&lt;br /&gt;
 char *command;&lt;br /&gt;
 size_t commandLength;&lt;br /&gt;
&lt;br /&gt;
 commandLength = strlen(cat) + strlen(argv[1]) + 1;&lt;br /&gt;
 command = (char *) malloc(commandLength);&lt;br /&gt;
 strncpy(command, cat, commandLength);&lt;br /&gt;
 strncat(command, argv[1], (commandLength - strlen(cat)) );&lt;br /&gt;
&lt;br /&gt;
 system(command);&lt;br /&gt;
 return (0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used normally, the output is simply the contents of the file requested:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$ ./catWrapper Story.txt&lt;br /&gt;
When last we left our heroes...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
However, if we add a semicolon and another command to the end of this line, the command is executed by catWrapper with no complaint:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./catWrapper &amp;quot;Story.txt; ls&amp;quot;&lt;br /&gt;
When last we left our heroes...&lt;br /&gt;
Story.txt               doubFree.c              nullpointer.c&lt;br /&gt;
unstosig.c              www*                    a.out*&lt;br /&gt;
format.c                strlen.c                useFree*&lt;br /&gt;
catWrapper*             misnull.c               strlength.c             useFree.c&lt;br /&gt;
commandinjection.c      nodefault.c             trunc.c                 writeWhatWhere.c&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If catWrapper had been set to have a higher privilege level than the standard user, arbitrary commands could be executed with that higher privilege.&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
&lt;br /&gt;
The following simple program accepts a filename as a command line argument, and displays the contents of the file back to the user. The program is installed setuid root because it is intended for use as a learning tool to allow system administrators in-training to inspect privileged system files without giving them the ability to modify them or damage the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       int main(char* argc, char** argv) {&lt;br /&gt;
               char cmd[CMD_MAX] = &amp;quot;/usr/bin/cat &amp;quot;;&lt;br /&gt;
               strcat(cmd, argv[1]);&lt;br /&gt;
               system(cmd);&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because the program runs with root privileges, the call to system() also executes with root privileges. If a user specifies a standard filename, the call works as expected. However, if an attacker passes a string of the form &amp;quot;;rm -rf /&amp;quot;, then the call to system() fails to execute cat due to a lack of arguments and then plows on to recursively delete the contents of the root partition.&lt;br /&gt;
&lt;br /&gt;
===Example 3===&lt;br /&gt;
&lt;br /&gt;
The following code from a privileged program uses the environment variable $APPHOME to determine the application's installation directory, and then executes an initialization script in that directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       ...&lt;br /&gt;
       char* home=getenv(&amp;quot;APPHOME&amp;quot;);&lt;br /&gt;
       char* cmd=(char*)malloc(strlen(home)+strlen(INITCMD));&lt;br /&gt;
       if (cmd) {&lt;br /&gt;
               strcpy(cmd,home);&lt;br /&gt;
               strcat(cmd,INITCMD);&lt;br /&gt;
               execl(cmd, NULL);&lt;br /&gt;
       }&lt;br /&gt;
       ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As in Example 2, the code in this example allows an attacker to execute arbitrary commands with the elevated privilege of the application. In this example, the attacker can modify the environment variable $APPHOME to specify a different path containing a malicious version of INITCMD. Because the program does not validate the value read from the environment, by controlling the environment variable, the attacker can fool the application into running malicious code.&lt;br /&gt;
&lt;br /&gt;
The attacker is using the environment variable to control the command that the program invokes, so the effect of the environment is explicit in this example. We will now turn our attention to what can happen when the attacker changes the way the command is interpreted.&lt;br /&gt;
&lt;br /&gt;
===Example 4===&lt;br /&gt;
&lt;br /&gt;
The code below is from a web-based CGI utility that allows users to change their passwords. The password update process under NIS includes running ''make'' in the /var/yp directory. Note that since the program updates password records, it has been installed setuid root.&lt;br /&gt;
&lt;br /&gt;
The program invokes make as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
       system(&amp;quot;cd /var/yp &amp;amp;&amp;amp; make &amp;amp;&amp;gt; /dev/null&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unlike the previous examples, the command in this example is hardcoded, so an attacker cannot control the argument passed to system(). However, since the program does not specify an absolute path for make, and does not scrub any environment variables prior to invoking the command, the attacker can modify their $PATH variable to point to a malicious binary named make and execute the CGI script from a shell prompt. And since the program has been installed setuid root, the attacker's version of make now runs with root privileges.&lt;br /&gt;
&lt;br /&gt;
The environment plays a powerful role in the execution of system commands within programs. Functions like system() and exec() use the environment of the program that calls them, and therefore attackers have a potential opportunity to influence the behavior of these calls.&lt;br /&gt;
&lt;br /&gt;
There are many sites that will tell you that Java's Runtime.exec is exactly the same as C's system function. This is not true. Both allow you to invoke a new program/process. However, C's system function passes its arguments to the shell (/bin/sh) to be parsed, whereas Runtime.exec tries to split the string into an array of words, then executes the first word in the array with the rest of the words as parameters. Runtime.exec does NOT try to invoke the shell at any point. The key difference is that much of the functionality provided by the shell that could be used for mischief (chaining commands using &amp;quot;&amp;amp;&amp;quot;, &amp;quot;&amp;amp;&amp;amp;&amp;quot;, &amp;quot;|&amp;quot;, &amp;quot;||&amp;quot;, etc, redirecting input and output) would simply end up as a parameter being passed to the first command, and likely causing a syntax error, or being thrown out as an invalid parameter.&lt;br /&gt;
&lt;br /&gt;
===Example 5===&lt;br /&gt;
The following trivial code snippets are vulnerable to OS command injection on the Unix/Linux platform:&lt;br /&gt;
&lt;br /&gt;
:* C:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;string.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int main(int argc, char **argv)&lt;br /&gt;
 {&lt;br /&gt;
      char command[256];&lt;br /&gt;
 &lt;br /&gt;
      if(argc != 2) {&lt;br /&gt;
           printf(&amp;quot;Error: Please enter a program to time!\n&amp;quot;);&lt;br /&gt;
           return -1;&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
      memset(&amp;amp;command, 0, sizeof(command));&lt;br /&gt;
 &lt;br /&gt;
      strcat(command, &amp;quot;time ./&amp;quot;);&lt;br /&gt;
      strcat(command, argv[1]);&lt;br /&gt;
 &lt;br /&gt;
      system(command);&lt;br /&gt;
      return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
:* If this were a suid binary, consider the case when an attacker enters the following: 'ls; cat /etc/shadow'. In the Unix environment, shell commands are separated by a semi-colon. We now can execute system commands at will!&lt;br /&gt;
&lt;br /&gt;
:* Java:&lt;br /&gt;
&lt;br /&gt;
'''There are many sites that will tell you that Java's Runtime.exec is exactly the same as C's system function. This is not true. Both allow you to invoke a new program/process. However, C's system function passes its arguments to the shell (/bin/sh) to be parsed, whereas Runtime.exec tries to split the string into an array of words, then executes the first word in the array with the rest of the words as parameters. Runtime.exec does NOT try to invoke the shell at any point. The key difference is that much of the functionality provided by the shell that could be used for mischief (chaining commands using &amp;quot;&amp;amp;&amp;quot;, &amp;quot;&amp;amp;&amp;amp;&amp;quot;, &amp;quot;|&amp;quot;, &amp;quot;||&amp;quot;, etc, redirecting input and output) would simply end up as a parameter being passed to the first command, and likely causing a syntax error, or being thrown out as an invalid parameter.'''&lt;br /&gt;
&lt;br /&gt;
===Example 6===&lt;br /&gt;
The following PHP code snippet is vulnerable to a command injection attack:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
print(&amp;quot;Please specify the name of the file to delete&amp;quot;);&lt;br /&gt;
print(&amp;quot;&amp;lt;p&amp;gt;&amp;quot;);&lt;br /&gt;
$file=$_GET['filename'];&lt;br /&gt;
system(&amp;quot;rm $file&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following request and response is an example of a successful attack:&lt;br /&gt;
&lt;br /&gt;
Request&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://127.0.0.1/delete.php?filename=bob.txt;id&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Please specify the name of the file to delete&lt;br /&gt;
&lt;br /&gt;
uid=33(www-data) gid=33(www-data) groups=33(www-data) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--==Related [[Threat Agents]]==&lt;br /&gt;
TBD&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
==Related [[Attacks]]==&lt;br /&gt;
* [[Code Injection]]&lt;br /&gt;
* [[Blind SQL Injection]]&lt;br /&gt;
* [[Blind XPath Injection]]&lt;br /&gt;
* [[LDAP injection]]&lt;br /&gt;
* [[Relative Path Traversal]]&lt;br /&gt;
* [[Absolute Path Traversal]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--==Related [[Vulnerabilities]]==&lt;br /&gt;
TBD&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
==Related [[Controls]]==&lt;br /&gt;
* [[:Category:Input Validation]]&lt;br /&gt;
&lt;br /&gt;
Ideally, a developer should use existing API for their language. For example (Java): Rather than use Runtime.exec() to issue a 'mail' command, use the available Java API located at javax.mail.*&lt;br /&gt;
&lt;br /&gt;
If no such available API exists, the developer should scrub all input for malicious characters. Implementing a positive security model would be most efficient. Typically, it is much easier to define the legal characters than the illegal characters.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
* [http://cwe.mitre.org/data/definitions/77.html CWE-77: Command Injection]&lt;br /&gt;
* [http://cwe.mitre.org/data/definitions/78.html CWE-78: OS Command Injection]&lt;br /&gt;
* http://blog.php-security.org/archives/76-Holes-in-most-preg_match-filters.html&lt;br /&gt;
&lt;br /&gt;
[[Category:Injection Attack]]&lt;br /&gt;
[[Category:Injection]]&lt;br /&gt;
[[Category:Attack]]&lt;br /&gt;
[[Category:Externally Linked Page]]&lt;/div&gt;</summary>
		<author><name>Michael Monsivais</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Clickjacking&amp;diff=181195</id>
		<title>Clickjacking</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Clickjacking&amp;diff=181195"/>
				<updated>2014-08-26T22:40:12Z</updated>
		
		<summary type="html">&lt;p&gt;Michael Monsivais: Removing previous editing artifact.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clickjacking, also known as a &amp;quot;UI redress attack&amp;quot;, is when an attacker uses multiple transparent or opaque layers to trick a user into clicking on a button or link on another page when they were intending to click on the the top level page. Thus, the attacker is &amp;quot;hijacking&amp;quot; clicks meant for their page and routing them to another page, most likely owned by another application, domain, or both.&lt;br /&gt;
&lt;br /&gt;
Using a similar technique, keystrokes can also be hijacked. With a carefully crafted combination of stylesheets, iframes, and text boxes, a user can be led to believe they are typing in the password to their email or bank account, but are instead typing into an invisible frame controlled by the attacker.&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&lt;br /&gt;
For example, imagine an attacker who builds a web site that has a button on it that says &amp;quot;click here for a free iPod&amp;quot;.  However, on top of that web page, the attacker has loaded an iframe with your mail account, and lined up exactly the &amp;quot;delete all messages&amp;quot; button directly on top of the &amp;quot;free iPod&amp;quot; button.  The victim tries to click on the &amp;quot;free iPod&amp;quot; button but instead actually clicked on the invisible &amp;quot;delete all messages&amp;quot; button.  In essence, the attacker has &amp;quot;hijacked&amp;quot; the user's click, hence the name &amp;quot;Clickjacking&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
One of the most notorious examples of Clickjacking was an attack against the [http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager06.html Adobe Flash plugin settings page]. By loading this page into an invisible iframe, an attacker could trick a user into altering the security settings of Flash, giving permission for any Flash animation to utilize the computer's microphone and camera.&lt;br /&gt;
&lt;br /&gt;
Clickjacking also made the news in the form of a [http://shiflett.org/blog/2009/feb/twitter-dont-click-exploit Twitter worm]. This clickjacking attack convinced users to click on a button which caused them to re-tweet the location of the malicious page, and propagated massively.&lt;br /&gt;
&lt;br /&gt;
There has also been clickjacking attacks abusing Facebook's &amp;quot;Like&amp;quot; functionality. [http://threatpost.com/en_us/blogs/facebook-jacking-scams-expand-060310 Attackers can trick logged-in Facebook users to arbitrarily like fan pages, links, groups, etc]&lt;br /&gt;
&lt;br /&gt;
= Defending against Clickjacking =&lt;br /&gt;
There are two main ways to prevent clickjacking:&lt;br /&gt;
# Sending the proper X-Frame-Options HTTP response headers that instruct the browser to not allow framing from other domains&lt;br /&gt;
# Employing defensive code in the UI to ensure that the current frame is the most top level window&lt;br /&gt;
&lt;br /&gt;
For more information on Clickjacking defense, please see the the [[Clickjacking Defense Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
* https://developer.mozilla.org/en-US/docs/The_X-FRAME-OPTIONS_response_header&lt;br /&gt;
: Mozilla developer resource on The X-Frame-Options response header.&lt;br /&gt;
&lt;br /&gt;
* [http://w2spconf.com/2010/papers/p27.pdf Busting Frame Busting: A study of clickjacking vulnerabilites on top sites]&lt;br /&gt;
: A study by the Stanford Web Security Group outlining problems with deployed frame busting code.&lt;br /&gt;
&lt;br /&gt;
* [http://www.sectheory.com/clickjacking.htm Clickjacking, Sec Theory]&lt;br /&gt;
: A paper by Robert Hansen defining the term, its implications against Flash at the time of writing, and a disclosure timeline.&lt;br /&gt;
&lt;br /&gt;
* [https://www.codemagi.com/blog/post/194 https://www.codemagi.com/blog/post/194] &lt;br /&gt;
: Framebreaking defense for legacy browsers that do not support X-Frame-Option headers.&lt;br /&gt;
&lt;br /&gt;
* [[ClickjackFilter_for_Java_EE|Anti-clickjacking J2EE filter]]&lt;br /&gt;
: A simple J2EE servlet filter that sends anti-framing headers to the browser.&lt;/div&gt;</summary>
		<author><name>Michael Monsivais</name></author>	</entry>

	</feed>