Commit 9c49307f authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 472206: [SECURITY] Bugzilla should optionally not allow the user to view…

Bug 472206: [SECURITY] Bugzilla should optionally not allow the user to view possibly harmful attachments - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=mkanat r=justdave a=LpSolit
parent d3829921
...@@ -40,7 +40,13 @@ $Bugzilla::Config::Attachment::sortkey = "025"; ...@@ -40,7 +40,13 @@ $Bugzilla::Config::Attachment::sortkey = "025";
sub get_param_list { sub get_param_list {
my $class = shift; my $class = shift;
my @param_list = ( my @param_list = (
{ {
name => 'allow_attachment_display',
type => 'b',
default => 0
},
{
name => 'attachment_base', name => 'attachment_base',
type => 't', type => 't',
default => '', default => '',
......
...@@ -332,8 +332,10 @@ sub view { ...@@ -332,8 +332,10 @@ sub view {
$filename =~ s/\\/\\\\/g; # escape backslashes $filename =~ s/\\/\\\\/g; # escape backslashes
$filename =~ s/"/\\"/g; # escape quotes $filename =~ s/"/\\"/g; # escape quotes
my $disposition = Bugzilla->params->{'allow_attachment_display'} ? 'inline' : 'attachment';
print $cgi->header(-type=>"$contenttype; name=\"$filename\"", print $cgi->header(-type=>"$contenttype; name=\"$filename\"",
-content_disposition=> "inline; filename=\"$filename\"", -content_disposition=> "$disposition; filename=\"$filename\"",
-content_length => $attachment->datasize); -content_length => $attachment->datasize);
disable_utf8(); disable_utf8();
print $attachment->data; print $attachment->data;
......
...@@ -24,23 +24,38 @@ ...@@ -24,23 +24,38 @@
%] %]
[% param_descs = { [% param_descs = {
attachment_base => "It is possible for a malicious attachment to steal your " _ allow_attachment_display =>
"cookies or access other attachments to perform an attack " _ "If this option is on, users will be able to view attachments from"
"on the user.<p>" _ _ " their browser, if their browser supports the attachment's MIME type."
"If you would like additional security on attachments " _ _ " If this option is off, users are forced to download attachments,"
"to avoid this, set this parameter to an alternate URL " _ _ " even if the browser is able to display them."
"for your $terms.Bugzilla that is not the same as " _ _ "<p>This is a security restriction for installations where untrusted"
"<tt>urlbase</tt> or <tt>sslbase</tt>. That is, a different " _ _ " users may upload attachments that could be potentially damaging if"
"domain name that resolves to this exact same $terms.Bugzilla " _ _ " viewed directly in the browser.</p>"
"installation.<p>" _ _ "<p>It is highly recommended that you set the <tt>attachment_base</tt>"
"For added security, you can insert <tt>%bugid%</tt> into " _ _ " parameter if you turn this parameter on.",
"the URL, which will be replaced with the ID of the current " _
"$terms.bug that the attachment is on, when you access " _ attachment_base =>
"an attachment. This will limit attachments to accessing " _ "When the <tt>allow_attachment_display</tt> parameter is on, it is "
"only other attachments on the same ${terms.bug}. " _ _ " possible for a malicious attachment to steal your cookies or"
"Remember, though, that all those possible domain names " _ _ " perform an attack on $terms.Bugzilla using your credentials."
"(such as <tt>1234.your.domain.com</tt>) must point to " _ _ "<p>If you would like additional security on attachments to avoid"
"this same $terms.Bugzilla instance." _ " this, set this parameter to an alternate URL for your $terms.Bugzilla"
_ " that is not the same as <tt>urlbase</tt> or <tt>sslbase</tt>."
_ " That is, a different domain name that resolves to this exact"
_ " same $terms.Bugzilla installation.</p>"
_ "<p>Note that if you have set the"
_ " <a href=\"editparams.cgi?section=core#cookiedomain\"><tt>cookiedomain</tt>"
_" parameter</a>, you should set <tt>attachment_base</tt> to use a"
_ " domain that would <em>not</em> be matched by"
_ " <tt>cookiedomain</tt>.</p>"
_ "<p>For added security, you can insert <tt>%bugid%</tt> into the URL,"
_ " which will be replaced with the ID of the current $terms.bug that"
_ " the attachment is on, when you access an attachment. This will limit"
_ " attachments to accessing only other attachments on the same"
_ " ${terms.bug}. Remember, though, that all those possible domain names "
_ " (such as <tt>1234.your.domain.com</tt>) must point to this same"
_ " $terms.Bugzilla instance.",
allow_attachment_deletion => "If this option is on, administrators will be able to delete " _ allow_attachment_deletion => "If this option is on, administrators will be able to delete " _
"the content of attachments.", "the content of attachments.",
......
...@@ -270,6 +270,17 @@ ...@@ -270,6 +270,17 @@
[% END %] [% END %]
</a> </a>
</td> </td>
[% ELSIF !Param("allow_attachment_display") %]
<td id="view_disabled" width="50%">
<p><b>
The attachment is not viewable in your browser due to security
restrictions enabled by [% terms.Bugzilla %].
</b></p>
<p><b>
In order to view the attachment, you first have to
<a href="attachment.cgi?id=[% attachment.id %]">download it</a>.
</b></p>
</td>
[% ELSIF attachment.is_viewable %] [% ELSIF attachment.is_viewable %]
<td width="75%"> <td width="75%">
[% INCLUDE global/textarea.html.tmpl [% INCLUDE global/textarea.html.tmpl
......
...@@ -131,9 +131,11 @@ ...@@ -131,9 +131,11 @@
[% IF attachments.size %] [% IF attachments.size %]
<span class="bz_attach_view_hide"> <span class="bz_attach_view_hide">
[% IF obsolete_attachments %] [% IF obsolete_attachments %]
<a href="#a0" onClick="return toggle_display(this);">Hide Obsolete</a> ([% obsolete_attachments %]) | <a href="#a0" onClick="return toggle_display(this);">Hide Obsolete</a> ([% obsolete_attachments %])
[% END %]
[% IF Param("allow_attachment_display") %]
<a href="attachment.cgi?bugid=[% bugid %]&amp;action=viewall">View All</a>
[% END %] [% END %]
<a href="attachment.cgi?bugid=[% bugid %]&amp;action=viewall">View All</a>
</span> </span>
[% END %] [% END %]
<a href="attachment.cgi?bugid=[% bugid %]&amp;action=enter">Add an attachment</a> <a href="attachment.cgi?bugid=[% bugid %]&amp;action=enter">Add an attachment</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment