From 08d9ef3cd0a3fa81adf9541aef4cd94a88f559d7 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 18 Sep 2026 16:57:34 -0700 Subject: [PATCH] Add checks for allowed .htaccess file path --- apache/apache-lib.pl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apache/apache-lib.pl b/apache/apache-lib.pl index a192a6141..c71d50a43 100755 --- a/apache/apache-lib.pl +++ b/apache/apache-lib.pl @@ -1871,15 +1871,14 @@ return @rv; } # allowed_auth_file(file) +# Returns 1 if a .htaccess file can be edited by the current user sub allowed_auth_file { -local $_; +my ($file) = @_; +return 0 if ($file =~ /\.\./); +my $f = &server_root($file); return 1 if ($access{'dir'} eq '/'); -return 0 if ($_[0] =~ /\.\./); -local $f = &server_root($_[0]); -return 0 if (-l $f && !&allowed_auth_file(readlink($f))); -local $l = length($access{'dir'}); -return length($f) >= $l && substr($f, 0, $l) eq $access{'dir'}; +return &is_under_directory($access{'dir'}, $f); } # directory_exists(file)