CVE-2011-10004: Unrestricted Upload of File with Dangerous Type (CWE-434)
value: A vulnerability was found in reciply Plugin up to 1.1.7 on WordPress. It has been rated as critical. This issue affects some unknown processing of the file uploadImage.php. The manipulation leads to unrestricted upload. The attack may be initiated remotely. Upgrading to version 1.1.8 is able to address this issue. The identifier of the patch is e3ff616dc08d3aadff9253f1085e13f677d0c676. It is recommended to upgrade the affected component. The identifier VDB-242189 was assigned to this vulnerability.
CWE description: The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.
CVSS v3 base score: 9.8
Published: 2023-10-17T00:15Z
Repository: https://github.com/wp-plugins/reciply
Language: PHP
Files changed: editor_plugin.js, index.php, uploadImage.php
Commit date: 2011-08-24 19:21:32 +0000
Commit message: Fixed upload vulnerability

git-svn-id: https://plugins.svn.wordpress.org/reciply/trunk@428303 b8457f37-d9ea-0310-8a92-e5e31aec5664

Diff: diff --git a/editor_plugin.js b/editor_plugin.js
index 912a471..1f57bd0 100644
--- a/editor_plugin.js
+++ b/editor_plugin.js
@@ -35,11 +35,11 @@ function reciply() {
             return {
                 longname : 'Reciply plugin',
                 author : 'The Recip.ly Integration team',
                 authorurl : 'http://integration.recip.ly',
                 infourl : '',
-                version : "1.1.7"
+                version : "1.1.8"
             };
         }
     });
 
     tinymce.PluginManager.add('reciply', tinymce.plugins.reciply);
diff --git a/index.php b/index.php
index c3d3eea..d3de7fc 100644
--- a/index.php
+++ b/index.php
@@ -2,11 +2,11 @@
 /*
 Plugin Name: Recip.ly Plugin
 Plugin URI: 
 Description: The recip.ly plugin allows you to easily add the recip.ly checkout process to your recipes.
 Author: The Recip.ly Integration team
-Version: 1.1.7
+Version: 1.1.8
 Author URI: http://integration.recip.ly
 */
 
 function reciply_addbuttons() 
 {
diff --git a/uploadImage.php b/uploadImage.php
index 4b7e278..ac6ce68 100644
--- a/uploadImage.php
+++ b/uploadImage.php
@@ -1,41 +1,58 @@
 <?php
+//add_action('plugins_loaded','pluginInit');
 
-// File version 1.1.7
-$ref = $_SERVER['HTTP_REFERER'];
-
-// Taille maximum 
-$MAX_FILE_SIZE = 400000;
-
-// Dossier de destination du fichier
-$serverpath = "images/";// Path to where images should be uploaded to on the server.
-
-foreach ($_FILES as $file) {
-$allowed_types = array("image/bmp", "image/gif", "image/pjpeg", "image/jpeg", "image/jpg", "image/png");
-$fname = $file['name'];
-$ftype = $file['type'];
-$fsize = $file['size'];
-$ftmp =$file['tmp_name'];
-$path = "$serverpath$fname";
+if ( !function_exists( 'add_action' ) ) {
+	echo "<strong>404.1 Error</strong>";
+	exit;
 }
-
-// Diverses test afin de savoir si :
-// Le format de fichier correspond à notre tableau array
-if(!in_array($ftype, $allowed_types)){$error = 1;}
-
-// La taille du fichier n'est pas dépassée
-if($fize > $MAX_FILE_SIZE){$error = 2;}
-
-// Le fichier n'existe pas déjà
-if(file_exists($serverpath."m_".$fname)){$error = 3;}
-
-// Si tout va bien, c'est bien déroulé
-if(move_uploaded_file($ftmp,''.$serverpath.''.$fname.'')) {$error = 0;}
-
-if($fname!="") {
-				header('refresh: 0; url='.$ref.'&img='.$path.'&f='.$fname.'&target="_blank"');
-				}
-else {
-		header('refresh: 0; url='.$ref);
+pluginInit();
+function pluginInit()
+{
+	// File version 1.1.7
+	$ref = $_SERVER['HTTP_REFERER'];
+	
+	// Taille maximum 
+	$MAX_FILE_SIZE = 400000;
+	$error = 0;
+	
+	// Dossier de destination du fichier
+	$serverpath = ABSPATH . 'wp-content/plugins/reciply/images/';
+	//$serverpath = "images/";// Path to where images should be uploaded to on the server.
+	
+	foreach ($_FILES as $file) {
+	$allowed_types = array("image/bmp", "image/gif", "image/pjpeg", "image/jpeg", "image/jpg", "image/png");
+	$fname = $file['name'];
+	$ftype = $file['type'];
+	$fsize = $file['size'];
+	$ftmp =$file['tmp_name'];
+	$path = "$serverpath$fname";
 	}
+	
+	// Diverses test afin de savoir si :
+	// Le format de fichier correspond à notre tableau array
+	if(!in_array($ftype, $allowed_types)){$error = 1;}
+	
+	// La taille du fichier n'est pas dépassée
+	if($fize > $MAX_FILE_SIZE){$error = 2;}
+	
+	
+	// Le fichier n'existe pas déjà
+	if(file_exists($serverpath."m_".$fname)){$error = 3;}
+	if ( $error != 0 ) {
+		echo "<strong>404.2 Error Code = ".$error."</strong>";
+		exit(0);
+	}
+	
+	
+	// Si tout va bien, c'est bien déroulé
+	if(move_uploaded_file($ftmp,''.$serverpath.''.$fname.'')) {$error = 4;}
+	
+	if($fname!="") {
+					header('refresh: 0; url='.$ref.'&img='.$path.'&f='.$fname.'&target="_blank"');
+					}
+	else {
+			header('refresh: 0; url='.$ref);
+		}
+}
 
 ?>
\ No newline at end of file

Vulnerable code:                 version : "1.1.7"
Version: 1.1.7
// File version 1.1.7
$ref = $_SERVER['HTTP_REFERER'];

// Taille maximum 
$MAX_FILE_SIZE = 400000;

// Dossier de destination du fichier
$serverpath = "images/";// Path to where images should be uploaded to on the server.

foreach ($_FILES as $file) {
$allowed_types = array("image/bmp", "image/gif", "image/pjpeg", "image/jpeg", "image/jpg", "image/png");
$fname = $file['name'];
$ftype = $file['type'];
$fsize = $file['size'];
$ftmp =$file['tmp_name'];
$path = "$serverpath$fname";

// Diverses test afin de savoir si :
// Le format de fichier correspond à notre tableau array
if(!in_array($ftype, $allowed_types)){$error = 1;}

// La taille du fichier n'est pas dépassée
if($fize > $MAX_FILE_SIZE){$error = 2;}

// Le fichier n'existe pas déjà
if(file_exists($serverpath."m_".$fname)){$error = 3;}

// Si tout va bien, c'est bien déroulé
if(move_uploaded_file($ftmp,''.$serverpath.''.$fname.'')) {$error = 0;}

if($fname!="") {
				header('refresh: 0; url='.$ref.'&img='.$path.'&f='.$fname.'&target="_blank"');
				}
else {
		header('refresh: 0; url='.$ref);
Fixed code:                 version : "1.1.8"
Version: 1.1.8
//add_action('plugins_loaded','pluginInit');
if ( !function_exists( 'add_action' ) ) {
	echo "<strong>404.1 Error</strong>";
	exit;
pluginInit();
function pluginInit()
{
	// File version 1.1.7
	$ref = $_SERVER['HTTP_REFERER'];
	
	// Taille maximum 
	$MAX_FILE_SIZE = 400000;
	$error = 0;
	
	// Dossier de destination du fichier
	$serverpath = ABSPATH . 'wp-content/plugins/reciply/images/';
	//$serverpath = "images/";// Path to where images should be uploaded to on the server.
	
	foreach ($_FILES as $file) {
	$allowed_types = array("image/bmp", "image/gif", "image/pjpeg", "image/jpeg", "image/jpg", "image/png");
	$fname = $file['name'];
	$ftype = $file['type'];
	$fsize = $file['size'];
	$ftmp =$file['tmp_name'];
	$path = "$serverpath$fname";
	
	// Diverses test afin de savoir si :
	// Le format de fichier correspond à notre tableau array
	if(!in_array($ftype, $allowed_types)){$error = 1;}
	
	// La taille du fichier n'est pas dépassée
	if($fize > $MAX_FILE_SIZE){$error = 2;}
	
	
	// Le fichier n'existe pas déjà
	if(file_exists($serverpath."m_".$fname)){$error = 3;}
	if ( $error != 0 ) {
		echo "<strong>404.2 Error Code = ".$error."</strong>";
		exit(0);
	}
	
	
	// Si tout va bien, c'est bien déroulé
	if(move_uploaded_file($ftmp,''.$serverpath.''.$fname.'')) {$error = 4;}
	
	if($fname!="") {
					header('refresh: 0; url='.$ref.'&img='.$path.'&f='.$fname.'&target="_blank"');
					}
	else {
			header('refresh: 0; url='.$ref);
		}
}