CVE-2015-10006 (published 2023-01-01T17:15Z)

A vulnerability, which was classified as problematic, has been found in admont28 Ingnovarq. Affected by this issue is some unknown functionality of the file app/controller/insertarSliderAjax.php. The manipulation of the argument imagetitle leads to cross site scripting. The attack may be launched remotely. The name of the patch is 9d18a39944d79dfedacd754a742df38f99d3c0e2. It is recommended to apply a patch to fix this issue. The identifier of this vulnerability is VDB-217172.

CVSS v3 base score: 6.1, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/admont28/ingnovarq
commit_details: repo_url: https://github.com/admont28/ingnovarq
author: Andrés David Montoya Aguirre
author_date: 2015-02-04 14:31:01-05:00
msg: - Cliente, Slider, Imagen, Nav, Botones

- Cliente: se añade la funcionalidad de agregar y eliminar clientes por
medio de peticiones ajax.

- Slider: se elimina código innecesario relacionado con agregar imagen
slider, se evita ataques XSS en el titulo de la imagen del slider.

- Nav: se elimina código innecesario.

- Botones: se añaden acciones para el botón de agregar cliente, agregar
slider.
repository: repo_url: https://github.com/admont28/ingnovarq
repo_name: admont28/ingnovarq
description: Repositorio que contendrá el código fuente de ingnovarq.
repo_language: PHP
owner: admont28
file_changes: filename: clientModel.php
change_type: ModificationType.MODIFY
diff: @@ -83,5 +83,22 @@
 				return $cliente = $response[0];
 			return null;
 		}
+
+		/*
+		 * Función para obtener el ultimo cliente insertado
+		 */
+		function view_db_last_client(){
+
+			$sentencia = $this->_db->prepare("SELECT * FROM Cliente ORDER BY idCliente DESC LIMIT 1");
+			$sentencia->execute();
+
+			$response = array();
+			while ($fila = $sentencia->fetch()) {
+				$response[] = $fila;
+			}
+			if(sizeof($response) != 0)
+				return $cliente = $response[0];
+			return null;
+		}
 	}
 ?>
\ No newline at end of file

programming_language: PHP
filename: eliminarClienteAjax.php
change_type: ModificationType.MODIFY
diff: @@ -23,7 +23,7 @@
             }
             $resultado = $clientModel->delete_db_client($idCliente);
             if($resultado){
-                $mensaje =  get_success_delete_client($idCliente); // envio el mensaje alojado en notificaciones
+                $mensaje =  get_success_delete_client($existente['nombreCliente']); // envio el mensaje alojado en notificaciones
             }
         }
     }

programming_language: PHP
filename: imagenModel.php
change_type: ModificationType.MODIFY
diff: @@ -40,7 +40,7 @@
 		}
 
 		/*
-		 * Función para insertar imagenes de un proyecto
+		 * Función para insertar imagenes de un servicio
 		 */
 		function insert_image_service($ruta, $titulo, $idServicio){
 
@@ -58,21 +58,16 @@
 		}
 
 		/*
-		 * Función para insertar imagenes de un proyecto
+		 * Función para insertar imagenes de un cliente
 		 */
-		function insert_images($ruta, $titulo, $idCliente){
+		function insert_image_client($ruta, $titulo, $idCliente){
 
 			$sentencia = $this->_db->prepare("INSERT INTO Imagen (rutaImagen, tituloImagen, sliderImagen, Cliente_idCliente) VALUES (:ruta, :titulo, false, :idCliente)");
 			$sentencia->bindParam(':ruta', $ruta);
-			$sentencia->bindParam(':tituloImagen', $titulo);
-			$sentencia->bindParam(':idProyecto', $idCliente);
+			$sentencia->bindParam(':titulo', $titulo);
+			$sentencia->bindParam(':idCliente', $idCliente);
 			//Ejecución de la consulta
-			$sentencia->execute();
-			$response = array();
-			while ($fila = $sentencia->fetch()) {
-				$response[] = $fila;
-			}
-			return $response;
+			return $sentencia->execute();
 		}
 
 		function delete_db_images_service($idServicio){

programming_language: PHP
filename: insertarClienteAjax.php
change_type: ModificationType.ADD
diff: @@ -0,0 +1,42 @@
+<?php 
+    session_start();
+    if(!isset($_SESSION['idUsuario'],$_SESSION['nombreUsuario'], $_SESSION['apellidoUsuario'], $_SESSION['superAdminUsuario'])){
+            header('location: error');
+    }
+    require_once ("notificaciones.php");
+    $mensaje = get_error_insert_client();
+    print_r($_POST);
+    print_r($_FILES);
+    if(sizeof($_POST) == 1 && isset($_POST['nombreCliente'], $_FILES['myfile'])){
+        
+        $directorioDeGuardado = "../../images/clientes/";
+        $nombreArchivo = $_FILES['myfile']['name'];
+        $fullPath = $directorioDeGuardado.$nombreArchivo; // construyo la ruta completa donde se guardará el archivo.
+        if (! file_exists($fullPath)){ //verifico que no exista la imagen anterior
+            require_once ("clientModel.php");
+            require_once ("userModel.php");
+            $clientModel = new ClientModel();
+            $userModel = new UserModel();
+            $usuario = $userModel->view_db_user($_SESSION['idUsuario']);
+            $nombreCliente = htmlspecialchars($_POST['nombreCliente'], ENT_NOQUOTES); //evito ataques XSS
+            $resultado = $clientModel->insert_db_client($nombreCliente, $usuario['idUsuario']);
+            if($resultado){
+                $ultimoCliente = $clientModel->view_db_last_client();
+                print_r($ultimoCliente);
+                if($ultimoCliente != null){
+
+                    require_once ("imagenModel.php");
+                    $imagenModel = new ImagenModel();
+                    $resultado = $imagenModel->insert_image_client($fullPath, $nombreCliente, $ultimoCliente['idCliente']);
+                    if($resultado){
+                        move_uploaded_file($_FILES["myfile"]["tmp_name"], $fullPath); //muevo el archivo cargado
+                        $mensaje = get_success_insert_client($nombreCliente); // obtengo el mensaje de que todo ha salido bien.
+                    }
+                }
+                else
+                    print("ultimoCliente null");
+            }
+        }
+    }
+echo $mensaje; 
+?>
\ No newline at end of file

programming_language: PHP
filename: insertarSliderAjax.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
         if (! file_exists($fullPath)){ //verifico que no exista la imagen anterior
             $sliderModel = new SliderModel();
             $tituloImagen = $_POST['tituloImagen'];
+            $tituloImagen = htmlspecialchars($tituloImagen, ENT_NOQUOTES); //evito ataques XSS
             move_uploaded_file($_FILES["myfile"]["tmp_name"], $fullPath); //muevo el archivo cargado
             $resultado = $sliderModel->insert_db_image_slider($tituloImagen, $fullPath);
             if($resultado){

programming_language: PHP
filename: notificaciones.php
change_type: ModificationType.MODIFY
diff: @@ -720,4 +720,51 @@
         return $mensaje;
     }
 
+    function get_success_insert_client($nombreCliente){
+       $mensaje = "<script type='text/javascript'>
+                        $(function(){
+                            new PNotify({
+                                title: 'Acción Exitosa',
+                                text: 'El cliente: ".$nombreCliente." ha sido agregado con éxito.<br>Si desea agregar un nuev cliente presione el botón Agregar.',
+                                type: 'success',
+                                animation: 'show',
+                                confirm: {
+                                    confirm: true,
+                                    buttons: [{
+                                            text: 'Agregar',
+                                            addClass: 'btn btn-success',
+                                            click: function(notice) {
+                                                notice.remove();
+                                                document.location='agregarCliente';
+                                            }
+                                        }, {
+                                            text: 'Volver',
+                                            click: function(notice) {
+                                                notice.remove();
+                                                document.location='perfil';
+                                            }
+                                        }]
+                                }   
+                            });
+                        });
+                    </script>";
+        return $mensaje;
+    }
+
+    function get_error_insert_client(){
+        $mensaje = "<script type='text/javascript'>
+                        $(function(){
+                            new PNotify({
+                                title: 'Acción No Exitosa :(',
+                                text: 'No se ha podido agregar el cliente con éxito, por favor revisa todos los datos e inténtelo de nuevo.',
+                                type: 'error',
+                                delay: 6000,
+                                animation: 'show',
+                            });
+                        });
+                        
+                    </script>";
+        return $mensaje;
+    }
+
 ?>
\ No newline at end of file

programming_language: HTML
filename: agregarCliente.php
change_type: ModificationType.ADD
diff: @@ -0,0 +1,65 @@
+<?php 
+	session_start();
+	if(!isset($_SESSION['idUsuario'],$_SESSION['nombreUsuario'], $_SESSION['apellidoUsuario'], $_SESSION['superAdminUsuario'])){
+		header('location: error');
+	}
+			include_once ("imports.php");
+			include_once ("header.php");
+			include_once ("nav.php");
+			include_once ("footer.php"); 
+			getImportsUp();
+			?>
+			<body id="body">
+				<div class="con" id="con">
+					<div class="container" id="main">
+							<?php 
+								getHeader();
+								if($_SESSION['superAdminUsuario'] == 1){
+									getNavSuperAdmin();
+								}
+								else
+								getNavAdmin();
+							?>
+					</div>
+					<div class="contenido">
+						<div class="row">
+							<br>
+							<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-8 col-md-offset-2">
+								<div class="panel panel-default empresa">
+									<div class="panel-heading">
+										Crear cliente
+									</div>
+									<div class="panel-body">
+										<div id="mensaje"></div>
+										<h2 style="color: #019831; text-align: center;">Formulario para agregar un nuevo cliente de Ingnovarq S.A.S</h2>
+										<br>								
+										<div class="form-horizontal">
+										     <div class="form-group">
+										         <label for="name" class="control-label col-xs-2">Nombre:</label>
+										         <div class="col-xs-10">
+										            <input type="name" id="nombreCliente" name="nombreCliente" class="form-control" placeholder="Nombre">
+										         </div>
+										     </div>
+										     <div class="form-group">
+										     	 <label class="control-label col-xs-2">Imagen:</label>
+										         <div class="col-xs-10" id="cargador">
+										            <div id="fileuploader">Cargar imagen</div>
+										         </div>
+										     </div>    
+										     <div class="form-group">
+										        <div class="col-xs-offset-2 col-xs-8">
+										            <div id="btn-agregar-cliente-ajax" class="btn btn-success">
+										            	<span class="glyphicon glyphicon-ok" aria-hidden="true"></span> Crear nuevo cliente</div> 
+										        </div>
+										     </div>
+										</div>
+									</div>
+								</div>
+							</div>
+						</div>
+					</div>
+				</div>
+				<?php
+					getFooter(); 
+					getImportsDown();
+?>
\ No newline at end of file

programming_language: PHP
filename: agregarImagenSlider.php
change_type: ModificationType.MODIFY
diff: @@ -7,10 +7,7 @@
 			include_once ("header.php");
 			include_once ("nav.php");
 			include_once ("footer.php"); 
-			require_once "../controller/sliderModel.php";
-
 			getImportsUp();
-			$sliderModel = new sliderModel();
 			?>
 
 			<body id="body">
@@ -22,8 +19,7 @@
 									getNavSuperAdmin();
 								}
 								else
-								getNavAdmin();
-								//$direccion = "../controlador/cargarImagenesProductos?idproducto=".$_GET['idproducto'];
+									getNavAdmin();
 							?>
 					</div>
 					<div class="contenido">
@@ -39,7 +35,6 @@
 										<h2 style="color: #019831; text-align: center;">Formulario para agregar una imagen al slider</h2>
 										<br>								
 										<div class="form-horizontal">
-								      		 <input type="hidden" name="idImagen" id="idImagen" readonly="readonly">
 										     <div class="form-group">
 										         <label for="inputName" class="control-label col-xs-2">Titulo:</label>
 										         <div class="col-xs-10">
@@ -50,8 +45,6 @@
 										     	 <label class="control-label col-xs-2">Imagen:</label>
 										         <div class="col-xs-10" id="cargador">
 										            <div id="fileuploader">Cargar imagen</div>
-										            <p id="nota" class="col-xs-12 text-info">Nota: Si no selecciona ninguna imagen y guarda los cambios, se conservará la imagen actual.
-										            </p>
 										         </div>
 										     </div>    
 										     <div class="form-group">

programming_language: PHP
filename: listarClientes.php
change_type: ModificationType.MODIFY
diff: @@ -71,7 +71,7 @@
 													</a>	
 												</td>	
 												<td>
-													<a href="#sinAccion" onclick="eliminarCliente(<?php echo $fila['idCliente'] ?>, '<?php echo $fila['nombreCliente'] ?>');">
+													<a href="#sinAccion" onclick="eliminarCliente(<?php echo $fila['idCliente'] ?>, '<?php echo htmlspecialchars($fila['nombreCliente'], ENT_NOQUOTES); ?>');">
 														<div><img style="width: 50px;" class="img-responsive" src="../../images/administrador/delete.png" title="Eliminar cliente"/></div>
 													</a>
 												</td>						

programming_language: PHP
filename: nav.php
change_type: ModificationType.MODIFY
diff: @@ -72,9 +72,7 @@
 					}?>">Crear imagen del slider</a>
 				</li>
 				<li class="cuadrado" >
-					<a href="../controller/logout" id="<?php if(strstr($_SERVER['REQUEST_URI'], 'agregarCliente')){
-						echo 'seleccionado';
-					}?>">Cerrar Sesión</a>
+					<a href="../controller/logout">Cerrar Sesión</a>
 				</li>	
 			</ul>
 			<a href="#" id="pull">Menú</a>
@@ -114,9 +112,7 @@
 					}?>">Crear imagen del slider</a>
 				</li>
 				<li class="cuadrado" >
-					<a href="../controller/logout" id="<?php if(strstr($_SERVER['REQUEST_URI'], 'agregarCliente')){
-						echo 'seleccionado';
-					}?>">Cerrar Sesión</a>
+					<a href="../controller/logout">Cerrar Sesión</a>
 				</li>	
 			</ul>
 			<a href="#" id="pull">Menú</a>

programming_language: PHP
filename: perfil.php
change_type: ModificationType.MODIFY
diff: @@ -84,7 +84,7 @@
 							</div>
 							<div class="panel-body col-xs-12 col-sm-12 col-md-12 color-content-admin">
 								<div class="col-md-6 col-xs-6 col-sm-6">
-									<a href="inicio">
+									<a href="agregarCliente">
 										<img src="../../images/administrador/add.png" class="img-responsive">
 									</a>
 								</div>

programming_language: PHP
filename: botones.js
change_type: ModificationType.MODIFY
diff: @@ -254,12 +254,38 @@ $(document).ready(function() {
                 return data; //debo retornar data para poder que se envien junto con las imagenes.
             }
         });
+        alert("Actualicé plugin slider");
+    } else if($('#btn-agregar-cliente-ajax').length){ 
+        // Si existe este botón, el usuario estará agregando un cliente
+        // Ejecutar si existe el elemento
+        uploadObj.update({
+            url: "../controller/insertarClienteAjax",
+            maxFileSize: 2097152, // 2MB escritos en bytes
+            dynamicFormData:function()
+            {
+                var nombre =  $("#nombreCliente").val(); //capturo el nombre del cliente cargado en el input.
+                // los datos que se van a enviar
+                var data = {
+                  nombreCliente: nombre //nombre del cliente
+                };
+                return data;
+            }
+        });
+        alert("Actualicé plugin cliente");
     }
 
+
     // al dar clic en crear imagen slider cambios al momento de crear una imagen del slider
     // ejecuto el plugin uploadFile.
     $('#btn-agregar-slider-ajax').click(function(){
         uploadObj.startUpload();
     });
 
+    
+
+    // al dar clic en agregar cliente ajax ejecuto el plugin uploadFile.
+    $('#btn-agregar-cliente-ajax').click(function(){
+        uploadObj.startUpload();
+    });
+
 });
\ No newline at end of file

programming_language: JavaScript