bugGNU patch - Bugs: bug #26099, Use of 'mktemp' is dangerous

 
 

bug #26099: Use of 'mktemp' is dangerous

Submitted by:  Andreas Gruenbacher <agruen>
Submitted on:  Mon 06 Apr 2009 03:16:24 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Andreas Gruenbacher <agruen>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 13 Oct 2010 10:20:21 PM UTC, comment #3:

mktemp is no longer being used.

Andreas Gruenbacher <agruen>
Project AdministratorIn charge of this item.
Fri 07 May 2010 11:41:51 AM UTC, comment #2:

Thanks, but that's not what's needed. The way how patch uses mktemp() is mostly secure:

mktemp (tmp);
while ("there is another patch")
{
/* This is racy. */
fd = open (tmp, O_CREAT|O_EXCL, 0666);
close (fd);
rename (tmp, outname);
}

An attacker can launch a denial-of-service attack by creating file tmp before patch can open it, though (i.e., before the first open, or between a rename and the next open); that's the bad thing about it. In addition, O_NOFOLLOW should be used to protect against symlink attacks.

I'll give fixing this a try myself.

PS.
Your commens shows up as Anonymous: I can't make use of anynymous code, anyway :(

Andreas Gruenbacher <agruen>
Project AdministratorIn charge of this item.
Thu 06 May 2010 09:18:51 PM UTC, comment #1:

I did a patch for using mkstemp(). All tests succeed.
There's no change form chmod to fchmod or something like that.

(file #20474)

Anonymous
Mon 06 Apr 2009 03:16:24 PM UTC, original submission:

When building patch, gcc complains that the use of mktemp is dangerous, and suggests to use mkstemp instead. While patch uses mktemp in a safe way, it would be nice to get rid of the warning.

At the same time, patch could switch from chmod to fchmod and from utime to futimes for added performance as well as safety.

Andreas Gruenbacher <agruen>
Project AdministratorIn charge of this item.

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #20474:  patch-2.6.1-mkstemp.patch added by None (8KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by agruen (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 13 Oct 2010 10:20:21 PM UTCagruenStatusPostponed=>Fixed
      Open/ClosedOpen=>Closed
    Thu 06 May 2010 09:18:51 PM UTCNoneAttached File-=>Added patch-2.6.1-mkstemp.patch, #20474
    Sat 11 Apr 2009 11:58:56 AM UTCagruenAssigned toNone=>agruen
    Mon 06 Apr 2009 04:10:07 PM UTCagruenStatusNone=>Postponed

    Back to the top


    Powered by Savane 3.1-cleanup1