Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
60630ac1
Commit
60630ac1
authored
Apr 10, 2013
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only allow pre-defined directories (avoid regex)
Just to be more secure.
parent
43138247
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
12 deletions
+30
-12
APIDaemon.pm
PVE/APIDaemon.pm
+7
-6
pveproxy
bin/pveproxy
+23
-6
No files found.
PVE/APIDaemon.pm
View file @
60630ac1
...
...
@@ -265,16 +265,17 @@ sub handle_request {
}
if
(
$self
->
{
dirs
}
&&
(
$method
eq
'
GET
'))
{
foreach
my
$dir
(
keys
%
{
$self
->
{
dirs
}})
{
# we only allow simple names
if
(
$uri
=~
m/^$dir([a-zA-Z0-9\-\_\.\/]+)$/
)
{
my
$reluri
=
$1
;
$reluri
=~
s/\.\./XX/g
;
# do not allow '..'
my
$filename
=
"
$self
->{dirs}->{
$dir
}
$reluri
";
# we only allow simple names
if
(
$uri
=~
m!^(/\S+/)([a-zA-Z0-9\-\_\.]+)$!
)
{
my
(
$subdir
,
$file
)
=
(
$1
,
$2
);
if
(
my
$dir
=
$self
->
{
dirs
}
->
{
$subdir
})
{
my
$filename
=
"
$dir$file
";
my
$fh
=
IO::
File
->
new
(
$filename
)
||
die
"
unable to open file '
$filename
' - $!
\n
";
send_file_start
(
$self
,
$reqstate
,
$filename
);
return
;
}
else
{
print
"
FAILED
\n
"
}
}
}
...
...
bin/pveproxy
View file @
60630ac1
...
...
@@ -44,11 +44,33 @@ $0 = "pveproxy";
PVE::APIDaemon::enable_debug() if $opt_debug;
sub add_dirs {
my ($result_hash, $alias, $subdir) = @_;
$result_hash->{$alias} = $subdir;
my $wanted = sub {
my $dir = $File::Find::dir;
if ($dir =~m!^$subdir(.*)$!) {
my $name = "$alias$1/";
$result_hash->{$name} = "$dir/";
}
};
find({wanted => $wanted, follow => 0, no_chdir => 1}, $subdir);
}
my $cpid;
my $daemon;
eval {
my $dirs = {};
add_dirs($dirs, '/pve2/ext4/', '/usr/share/pve-manager/ext4/');
add_dirs($dirs, '/pve2/images/' => '/usr/share/pve-manager/images/');
add_dirs($dirs, '/pve2/css/' => '/usr/share/pve-manager/css/');
add_dirs($dirs, '/vncterm/' => '/usr/share/vncterm/');
$daemon = PVE::APIDaemon->new(
port => 8006,
keep_alive => 100,
...
...
@@ -69,12 +91,7 @@ eval {
file => '/usr/share/pve-manager/images/favicon.ico',
},
},
dirs => {
'/pve2/images/' => '/usr/share/pve-manager/images/',
'/pve2/css/' => '/usr/share/pve-manager/css/',
'/pve2/ext4/' => '/usr/share/pve-manager/ext4/',
'/vncterm/' => '/usr/share/vncterm/',
},
dirs => $dirs,
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment