Security-Onion-Solutions / securityonion-capme

11 stars 9 forks source link

XSS - ETIME parameter #8

Closed w8mej closed 8 years ago

w8mej commented 8 years ago

Abstract:

Line 77 of securityonion-capme/capme/index.php sends unvalidated data to a web browser, which can result in the browser executing malicious code.

Explanation:

Cross-site scripting (XSS) vulnerabilities occur when:

  1. Data enters a web application through an untrusted source. In the case of Reflected XSS, the untrusted source is typically a web request, while in the case of Persisted (also known as Stored) XSS it is typically a database or other back-end datastore.
  2. The data is included in dynamic content that is sent to a web user without being validated.

In this case the data is sent at builtin_echo() in securityonion-capme/capme/index.php at line 77.

The malicious content sent to the web browser often takes the form of a segment of JavaScript, but may also include HTML, Flash or any other type of code that the browser may execute. The variety of attacks based on XSS is almost limitless, but they commonly include transmitting private data like cookies or other session information to the attacker, redirecting the victim to web content controlled by the attacker, or performing other malicious operations on the user's machine under the guise of the vulnerable site.

Example 1: The following PHP code segment reads an employee ID, eid, from an HTTP request and displays it to the user.

<?php $eid = $_GET['eid']; ... ?> ... <?php echo "Employee ID: $eid"; ?>

The code in this example operates correctly if eid contains only standard alphanumeric text. If eid has a value that includes meta-characters or source code, then the code will be executed by the web browser as it displays the HTTP response.

Initially this might not appear to be much of a vulnerability. After all, why would someone enter a URL that causes malicious code to run on their own computer? The real danger is that an attacker will create the malicious URL, then use e-mail or social engineering tricks to lure victims into visiting a link to the URL. When victims click the link, they unwittingly reflect the malicious content through the vulnerable web application back to their own computers. This mechanism of exploiting vulnerable web applications is known as Reflected XSS.

Example 2: The following PHP code segment queries a database for an employee with a given ID and prints the corresponding employee's name.

<?php... $con = mysql_connect($server,$user,$password); ... $result = mysql_query("select * from emp where id="+eid); $row = mysql_fetch_array($result) echo 'Employee name: ', mysql_result($row,0,'name'); ... ?>

As in Example 1, this code functions correctly when the values of name are well-behaved, but it does nothing to prevent exploits if they are not. Again, this code can appear less dangerous because the value of name is read from a database, whose contents are apparently managed by the application. However, if the value of name originates from user-supplied data, then the database can be a conduit for malicious content. Without proper input validation on all data stored in the database, an attacker can execute malicious commands in the user's web browser. This type of exploit, known as Persistent (or Stored) XSS, is particularly insidious because the indirection caused by the data store makes it more difficult to identify the threat and increases the possibility that the attack will affect multiple users. XSS got its start in this form with web sites that offered a "guestbook" to visitors. Attackers would include JavaScript in their guestbook entries, and all subsequent visitors to the guestbook page would execute the malicious code.

As the examples demonstrate, XSS vulnerabilities are caused by code that includes unvalidated data in an HTTP response. There are three vectors by which an XSS attack can reach a victim:

dougburks commented 8 years ago

Hi lordappsec,

I'll take a look and see what we need to do.

Thanks!

dougburks commented 8 years ago

Hi @lordappsec,

Please take a look at the updated file: https://github.com/Security-Onion-Solutions/securityonion-capme/blob/master/capme/index.php

Please let me know what you think.

Thanks!

w8mej commented 8 years ago

Looks adequate. Good luck!

dougburks commented 8 years ago

Published: http://blog.securityonion.net/2016/02/securityonion-capme-20121213_10.html