Bugtraq mailing list archives
Re: Insecure use of file in /tmp by trn
From: pfaffben () MSU EDU (Ben Pfaff)
Date: Tue, 24 Aug 1999 13:09:28 -0400
Rogier Wolff <R.E.Wolff () BITWIZARD NL> writes: Creating a tempfile from a C program is possible since we have a mkstmp call. It is sufficiently tricky that I wouldn't dare replicating the functionality myself. Creating a private directory in /tmp and putting the tempfiles in there might be the only solution for shell scripts. Debian uses a program called `mktemp' to create temporary files in shell scripts. Other distributions might well adopt this or a similar solution. An excerpt from its manpage is enclosed below. SYNOPSIS mktemp [-q] [-u] template DESCRIPTION The mktemp utility takes the given file name template and overwrites a portion of it to create a file name. This file name is unique and suit- able for use by the application. The template is any file name with six `Xs' appended to it, for example /tmp/temp.XXXXXX. The `Xs' are replaced with the current process number and/or a unique letter combination. Roughly 26 ** 6 combinations are tried. If mktemp can successfully generate a unique file name, the file is cre- ated with mode 0600 (unless the -u flag is given) and the filename is printed to standard output. Debian packages using mktemp in maintainer scripts must depend on de- bianutils >= 1.7. EXAMPLES The following sh(1) fragment illustrates a simple use of mktemp where the script should quit if it cannot get a safe temporary file. p=`basename $0` TMPFILE=`mktemp /tmp/$p.XXXXXX` || exit 1 echo "program output" >> $TMPFILE
Current thread:
- Re: Insecure use of file in /tmp by trn Rogier Wolff (Aug 22)
- Re: Insecure use of file in /tmp by trn Martin Schulze (Aug 23)
- <Possible follow-ups>
- Re: Insecure use of file in /tmp by trn Richard Kettlewell (Aug 23)
- Re: Insecure use of file in /tmp by trn Ben Pfaff (Aug 24)
- Re: Insecure use of file in /tmp by trn Theo de Raadt (Aug 27)
- Re: Insecure use of file in /tmp by trn Martin Schulze (Aug 29)
- WU-FTPD Security Update Thomas Biege (Aug 29)
- Re: Insecure use of file in /tmp by trn Luca Berra (Aug 30)
- Re: Insecure use of file in /tmp by trn Shuman (Aug 28)
- Re: Insecure use of file in /tmp by trn Todd C. Miller (Aug 30)
- Re: Insecure use of file in /tmp by trn Rogier Wolff (Aug 28)
- Vixie Cron version 3.0pl1 vulnerable to root exploit Martin Schulze (Aug 28)
- Re: Insecure use of file in /tmp by trn Theo de Raadt (Aug 27)