From 5a9a6a88105bd70cdc456b2bcbfb6b39afddbd6a Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Tue, 12 Aug 2008 14:41:29 +0000 Subject: [PATCH] Bug 437169: [SECURITY] Local files on the server can be attached to a bug (making them publicly visible) when importing bugs with -attach_path Patch By Greg Hendricks r=LpSolit, a=mkanat --- importxml.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/importxml.pl b/importxml.pl index eaec9d99b9..6b0c043b4d 100755 --- a/importxml.pl +++ b/importxml.pl @@ -384,8 +384,13 @@ sub process_attachment() { elsif ($encoding =~ /filename/) { # read the attachment file Error("attach_path is required", undef) unless ($attach_path); - my $attach_filename = $attach_path . "/" . $attach->field('data'); - open(ATTACH_FH, $attach_filename) or + + my $filename = $attach->field('data'); + # Remove any leading path data from the filename + $filename =~ s/(.*\/|.*\\)//gs; + + my $attach_filename = $attach_path . "/" . $filename; + open(ATTACH_FH, "<", $attach_filename) or Error("cannot open $attach_filename", undef); $attachment{'data'} = do { local $/; }; close ATTACH_FH; -- 2.47.2