Files
webmin/custom/cgi_args.pl
Ilia Ross 301722b572 Fix to tighten privileged ACL checks
This PR addresses privately reported issue and tries to restricts root/UID 0 user mutations and Custom Commands definition editing to full, non-safe Webmin admins.

This closes privilege-escalation paths for restricted operators while preserving execution of pre-approved Custom Commands under existing cmds ACLs.
2026-06-28 00:05:21 +02:00

43 lines
1.2 KiB
Perl
Executable File

do 'custom-lib.pl';
sub cgi_args
{
my ($cgi) = @_;
my @cust = grep { &can_run_command($_) } &list_commands();
if ($cgi eq 'edit_cmd.cgi') {
# Custom command editor
return 'none' if (!&custom_can_edit_commands());
my ($cmd) = grep { !$_->{'edit'} && !$_->{'sql'} } @cust;
return $cmd ? 'id='.&urlize($cmd->{'id'}) : 'new=1';
}
elsif ($cgi eq 'form.cgi') {
# Custom command form
my ($cmd) = grep { !$_->{'edit'} && !$_->{'sql'} } @cust;
return $cmd ? 'id='.&urlize($cmd->{'id'}) : 'none';
}
elsif ($cgi eq 'edit_file.cgi') {
# File editor editor
return 'none' if (!&custom_can_edit_commands());
my ($cmd) = grep { $_->{'edit'} } @cust;
return $cmd ? 'id='.&urlize($cmd->{'id'}) : 'new=1';
}
elsif ($cgi eq 'view.cgi') {
# Custom command form
my ($cmd) = grep { $_->{'edit'} } @cust;
return $cmd ? 'id='.&urlize($cmd->{'id'}) : 'none';
}
elsif ($cgi eq 'edit_sql.cgi') {
# SQL query
return 'none' if (!&custom_can_edit_commands());
my ($cmd) = grep { $_->{'sql'} } @cust;
return $cmd ? 'id='.&urlize($cmd->{'id'}) : 'new=1';
}
elsif ($cgi eq 'sqlform.cgi') {
# SQL query form
my ($cmd) = grep { $_->{'sql'} } @cust;
return $cmd ? 'id='.&urlize($cmd->{'id'}) : 'none';
}
return undef;
}