Bug 101440 - Unsafe use of temporary file in dcopidlng script
Summary: Unsafe use of temporary file in dcopidlng script
Status: RESOLVED INTENTIONAL
Alias: None
Product: dcop
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: security
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-13 20:06 UTC by Ana Guerrero (Debian KDE maintainers)
Modified: 2005-03-14 14:57 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
the patch in question (763 bytes, patch)
2005-03-13 20:07 UTC, Ana Guerrero (Debian KDE maintainers)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ana Guerrero (Debian KDE maintainers) 2005-03-13 20:06:42 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    Debian testing/unstable Packages
OS:                Linux

The following was posted to Debian as http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=298533 by Javier Fernández-Sanguino Peña <jfs@computer.org>. It would be nice if KDE included this fix (attached), which applies to the latest code:

---
Reviewing the Gentoo advisory GLSA 200503-14 [0] which refers to
CAN-2005-0365 I've checked out to see if our dcopidlng script was
vulnerable to the symlink attack found by Davide Madrisan even though it 
does not use /tmp.

It seems ours is not because the temporary file is 
created in the local directory (instead of in /tmp) directly, however, the 
creation does provide a way for a race condition.

I think the attached patch is a better fix for this issue than the one 
provided by Gentoo [1]. There are several bugs in Gentoo's fix:

1- The file is removed twice (once in the trap and once at the end of the 
fix)
2- Leaving temporary files in the home directory might not be good. Mktemp 
-t is better since users can set their TMPDIR environment variable to point 
to "/home/user/tmp" if they want to, but users without a home directory 
(think chroot) will work in any case (failsback to /tmp)
3- The temporafy file is still being create in an unsafe way (but in a safe 
directory), mktemp does this better

So, please use the attached patch (and maybe forward it upstream) for a 
next release.

[0] http://www.gentoo.org/security/en/glsa/glsa-200503-14.xml
[1] http://bugs.gentoo.org/attachment.cgi?id=51120&action=view
---
Comment 1 Ana Guerrero (Debian KDE maintainers) 2005-03-13 20:07:32 UTC
Created attachment 10092 [details]
the patch in question
Comment 2 Stephan Kulow 2005-03-14 14:57:00 UTC
sorry, the patch is nonsense. For one mktemp is not portable and for second, this way to generate temporary files is used throughout the build process