Fixed: Add missing token check to file manager requests on Backoffice
Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
@@ -18,6 +18,13 @@ $cms_accesses = Profile::getProfileAccess(Context::getContext()->employee->id_pr
|
||||
if (!$products_accesses['edit'] && !$cms_accesses['edit']) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
$tokenTab = $products_accesses['edit'] ? 'AdminProducts' : 'AdminCmsContent';
|
||||
$isMutatingRequest = isset($_POST['submit']) || in_array(basename($_SERVER['SCRIPT_NAME']), array('execute.php', 'upload.php', 'ajax_calls.php'), true);
|
||||
|
||||
if ($isMutatingRequest && (!isset($_REQUEST['token']) || !hash_equals(Tools::getAdminTokenLite($tokenTab), (string) $_REQUEST['token']))) {
|
||||
die('invalid token');
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// DON'T COPY THIS VARIABLES IN FOLDERS config.php FILES
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -242,6 +242,7 @@ if (isset($_POST['submit'])) {
|
||||
<script>
|
||||
var ext_img = new Array('<?php echo implode("','", $ext_img)?>');
|
||||
var allowed_ext = new Array('<?php echo implode("','", $ext)?>');
|
||||
var fmToken = "<?php echo Tools::getAdminTokenLite($products_accesses['edit'] ? 'AdminProducts' : 'AdminCmsContent'); ?>";
|
||||
var loading_bar =<?php echo $loading_bar?"true":"false";
|
||||
?>;
|
||||
var image_editor =<?php echo $aviary_active?"true":"false";
|
||||
@@ -257,6 +258,7 @@ if (isset($_POST['submit'])) {
|
||||
maxFilesize: <?php echo $MaxSizeUpload;
|
||||
?>, // MB
|
||||
url: "upload.php",
|
||||
params: {token: fmToken},
|
||||
accept: function (file, done) {
|
||||
var extension = file.name.split('.').pop();
|
||||
extension = extension.toLowerCase();
|
||||
@@ -391,6 +393,8 @@ if (isset($_POST['submit'])) {
|
||||
?>"/>
|
||||
<input type="hidden" name="path_thumb" value="<?php echo Tools::safeOutput($subfolder.$subdir);
|
||||
?>"/>
|
||||
<input type="hidden" name="token" value="<?php echo Tools::safeOutput(Tools::getAdminTokenLite($products_accesses['edit'] ? 'AdminProducts' : 'AdminCmsContent'));
|
||||
?>"/>
|
||||
|
||||
<div class="fallback">
|
||||
<?php echo lang_Upload_file ?>:<br/>
|
||||
|
||||
@@ -35,7 +35,7 @@ $(document).ready(function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax_calls.php?action=extract",
|
||||
data: { path: m }
|
||||
data: { path: m, token: fmToken }
|
||||
}).done(function( msg ) {
|
||||
if (msg!="")
|
||||
bootbox.alert(msg);
|
||||
@@ -220,7 +220,7 @@ $(document).ready(function(){
|
||||
sortDescending=!sortDescending;
|
||||
if (js_script) {
|
||||
$.ajax({
|
||||
url: "ajax_calls.php?action=sort&sort_by="+_this.attr('data-sort')+"&descending="+sortDescending
|
||||
url: "ajax_calls.php?action=sort&sort_by="+_this.attr('data-sort')+"&descending="+sortDescending+"&token="+encodeURIComponent(fmToken)
|
||||
}).done(function( msg ) {
|
||||
|
||||
});
|
||||
@@ -318,7 +318,7 @@ $(document).ready(function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "execute.php?action=create_folder",
|
||||
data: {path: folder_path, path_thumb: folder_path_thumb}
|
||||
data: {path: folder_path, path_thumb: folder_path_thumb, token: fmToken}
|
||||
}).done(function( msg ) {
|
||||
setTimeout(function(){window.location.href = $('#refresh').attr('href') + '&' + new Date().getTime();},300);
|
||||
|
||||
@@ -336,7 +336,7 @@ $(document).ready(function(){
|
||||
_this.find('i').addClass('icon-white');
|
||||
|
||||
$.ajax({
|
||||
url: "ajax_calls.php?action=view&type="+_this.attr('data-value')
|
||||
url: "ajax_calls.php?action=view&type="+_this.attr('data-value')+"&token="+encodeURIComponent(fmToken)
|
||||
}).done(function( msg ) {
|
||||
if (msg!="") {
|
||||
bootbox.alert(msg);
|
||||
@@ -719,7 +719,7 @@ function execute_action(action,file1,file2,name,container,function_name){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "execute.php?action="+action,
|
||||
data: {path: file1, path_thumb: file2, name: name.replace('/','')}
|
||||
data: {path: file1, path_thumb: file2, name: name.replace('/',''), token: fmToken}
|
||||
}).done(function( msg ) {
|
||||
if (msg!="") {
|
||||
bootbox.alert(msg);
|
||||
|
||||
2
admin-dev/filemanager/js/include.min.js
vendored
2
admin-dev/filemanager/js/include.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user