Skip to content

Commit

Permalink
Bug 913904: (CVE-2013-1734) [SECURITY] CSRF when updating attachments
Browse files Browse the repository at this point in the history
r=dkl a=sgreen
  • Loading branch information
LpSolit committed Oct 16, 2013
1 parent 6f5ed9c commit 2a3d79a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions attachment.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -661,20 +661,23 @@ sub update {
$attachment->set_filename(scalar $cgi->param('filename'));

# Now make sure the attachment has not been edited since we loaded the page.
if (defined $cgi->param('delta_ts')
&& $cgi->param('delta_ts') ne $attachment->modification_time)
{
($vars->{'operations'}) =
Bugzilla::Bug::GetBugActivity($bug->id, $attachment->id, $cgi->param('delta_ts'));
my $delta_ts = $cgi->param('delta_ts');
my $modification_time = $attachment->modification_time;

# The token contains the old modification_time. We need a new one.
$cgi->param('token', issue_hash_token([$attachment->id, $attachment->modification_time]));
if ($delta_ts && $delta_ts ne $modification_time) {
datetime_from($delta_ts)
or ThrowCodeError('invalid_timestamp', { timestamp => $delta_ts });
($vars->{'operations'}) =
Bugzilla::Bug::GetBugActivity($bug->id, $attachment->id, $delta_ts);

# If the modification date changed but there is no entry in
# the activity table, this means someone commented only.
# In this case, there is no reason to midair.
if (scalar(@{$vars->{'operations'}})) {
$cgi->param('delta_ts', $attachment->modification_time);
$cgi->param('delta_ts', $modification_time);
# The token contains the old modification_time. We need a new one.
$cgi->param('token', issue_hash_token([$attachment->id, $modification_time]));

$vars->{'attachment'} = $attachment;

print $cgi->header();
Expand Down

0 comments on commit 2a3d79a

Please sign in to comment.