Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-03-30
03:59 • Closed ticket [402924ffff]: Fix for race condition in unix/tclUnixPipe.c plu... artifact: 4eb459048b user: hobbs
2001-03-29
13:13 • Ticket [402924ffff]: 4 changes artifact: a3358c55a4 user: rmax
08:39 • Ticket [402924ffff]: 4 changes artifact: e4884ae1f6 user: hobbs
08:38 • Ticket [402924ffff]: 5 changes artifact: a44cf664f9 user: hobbs
2001-02-22
07:00 • Ticket [402924ffff]: 1 change artifact: 3e485eef32 user: dgp
2000-12-21
17:18 • Ticket [402924ffff]: 4 changes artifact: d9950aebca user: rmax
16:34 • Ticket [402924ffff]: 5 changes artifact: 96a1c078cb user: andreas_kupries
2000-12-19
21:54 • Ticket [402924ffff]: 4 changes artifact: 64e5d5725a user: rmax
21:52 • Add attachment None to ticket [402924ffff] artifact: 0e888d8075 user: rmax
14:52 • New ticket [402924ffff] Fix for race condition in tcl/tclUnixPipe.c. artifact: d5fd2675e7 user: rmax

Fix for race condition in unix/tclUnixPipe.c

Closed / Fixed402924ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
rmaxplain2000-12-19 21:54:36
oops, the path in the summary should read unix/tclUnixPipe.c
andreas_kupriesplain2000-12-21 16:34:02
To which bug does this patch belong to ?
rmaxplain2000-12-21 17:18:52
Am I supposed to create a bug entry before I submit a patch?

This patch fixes a security leak that makes Tcl vulnerable to symlink
attacks when it creates temporary files. I was pointed to this by our
security experts.
dgp Ticket [402924ffff]: 1 change [History diff]2001-02-22 07:00:35
hobbsplain2001-03-29 08:38:49
Logged In: YES 
user_id=72656

No need to create a bug first is necessary, but a bit of 
explanation is always nice. :^)

In the case of this patch, it does change the meaning of 
the open call from truncating any existing file to throwing 
an error if the file exists.  Of course, this shouldn't 
happen with tmpnam and all, but then I wonder how it is a 
security leak?  I'm inclined to believe the security guys, 
I just wanted to know more about how a problem could occur.
hobbsplain2001-03-29 08:39:14
Logged In: YES 
user_id=72656

No need to create a bug first is necessary, but a bit of 
explanation is always nice. :^)

In the case of this patch, it does change the meaning of 
the open call from truncating any existing file to throwing 
an error if the file exists.  Of course, this shouldn't 
happen with tmpnam and all, but then I wonder how it is a 
security leak?  I'm inclined to believe the security guys, 
I just wanted to know more about how a problem could occur.
rmaxplain2001-03-29 13:13:54
Logged In: YES 
user_id=124643

It is only a very tight race condition, but it exists. If
someone creates a symlink in the time between tmpnam() and
open() that has the same name as the temporary file you are
about to open, the target file of this symlink will be
deleted, if open is called with O_TRUNC.

Adding O_NOFOLLOW instead of replacing O_TRUNC with O_EXCL
may also help, but seems to be less portable.

BTW, the manpage of tmpnam says: 
BUGS
       Never use this function. Use mkstemp(3) instead.
hobbsplain2001-03-30 03:59:56
Logged In: YES 
user_id=72656

And on Solaris, the USAGE notes say:
...
     The tmpfile(3S) function is preferred over this 
function.
...

Each seems to have problems, so I'll just do the O_EXCL for 
now.  If someone wants to make a larger patch the goes with 
the conflicting advice of OSes, that should be separate.

I've patched as per the original suggestion for 8.4a2/8.3.3.
Log in (anonymous is fine) to add a comment.

Attachments: