Skip to content

Commit

Permalink
panorama: validate input folder for image uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jan 26, 2024
1 parent 0ae20da commit 1aa9597
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -4,6 +4,7 @@ use warnings;
use strict;
use Carp qw/confess/;
use Cpanel::JSON::XS qw/decode_json/;
use Cwd ();
use Data::Dumper qw/Dumper/;
use Encode qw(encode_utf8);
use File::Copy qw/move copy/;
Expand Down Expand Up @@ -732,7 +733,14 @@ sub _task_upload {
}

my $upload = $c->req->uploads->{$type};
my $folder = $c->stash->{'usercontent_folder'}.'/'.$location;
my $folder = Cwd::abs_path($c->stash->{'usercontent_folder'}.'/'.$location);

# make sure requested folder is below the usercontent folder
if(CORE::index(Cwd::abs_path($c->stash->{'usercontent_folder'}), $folder) != 0) {
# must be text/html result, otherwise extjs form result handler dies
$c->stash->{text} = Thruk::Utils::Filter::json_encode({ 'msg' => 'Fileupload contains illegal folder.', success => Cpanel::JSON::XS::false });
return;
}

if(!-w $folder.'/.') {
# must be text/html result, otherwise extjs form result handler dies
Expand Down

0 comments on commit 1aa9597

Please sign in to comment.