After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 130091 - insecure temporary file creation issues
insecure temporary file creation issues
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
2.5.x
Other Linux
: High major
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2003-12-27 19:18 UTC by Martijn Vernooij
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Martijn Vernooij 2003-12-27 19:18:43 UTC
I was browsing the nautilus source code and found these:

libnautilus-private/nautilus-file-utilities.c, line 343
                                                                          
                                                                          
                                                                            
nautilus_unique_temporary_file_name (void) {
        const char *prefix = "/tmp/nautilus-temp-file";
        char *file_name;
        static guint count = 1;
                                                                          
                                                                          
                                                                            
        file_name = g_strdup_printf ("%sXXXXXX", prefix);
                                                                          
                                                                          
                                                                            
        if (mktemp (file_name) != file_name) {
                g_free (file_name);
                file_name = g_strdup_printf ("%s-%d-%d",
prefix, count++, getpid ());
        }
                                                                          
                                                                          
                                                                            
        return file_name;
                                                                          
                                                                          
                                                                            
}
                                                                          
                                                                          
                                                                            
This one in libnautilus-private/nautilus-metafile.c, line 1740 is secure.
                                                                          
                                                                          
                                                                            
                temp_path = g_strconcat (metafile_path, "XXXXXX", NULL);
                failed = FALSE;
                                                                          
                                                                          
                                                                            
                fd = mkstemp (temp_path);
                if (fd == -1) {
                        failed = TRUE;
                }
                                                                          
                                                                          
                                                                            
This one in src/nautilus-profiler.c, line 287 'snatched defeat from the
jaws of victory':
                                                                          
                                                                          
                                                                            
        dump_file_name = g_strdup ("/tmp/nautilus-profile-log-XXXXXX");
                                                                          
                                                                          
                                                                            
        fd = mkstemp (dump_file_name);
                                                                          
                                                                          
                                                                            
        if (fd != -1) {
                close (fd);
        } else {
                g_free (dump_file_name);
                dump_file_name = g_strdup_printf
("/tmp/nautilus-profile-log.%d", getpid ());
        }
Comment 1 Luis Villa 2003-12-30 16:03:24 UTC
Both of the naut maintainers are on vacation ATM, FWIW. If you can
supply a patch to fix the problems, I'm sure they'll look at it as
soon as they get back. Thanks.
Comment 2 Alexander Larsson 2004-01-15 10:13:00 UTC
nautilus_unique_temporary_file_name isn't actually used anywhere, but
i changed it to mkstemp anyway. The profile thing i wouldn't worry
about, since thats only used by nautilus developers on very few
occasions. (I don't even know if the profiler stuff builds anymore.)
Comment 3 Martijn Vernooij 2004-01-15 10:47:59 UTC
As noted in the other report I filed on gnome-vfs (bug 130092) IMHO 
even places where code like this is not really dangerous, it should 
be coded correctly or accompanied by a very big warning comment that 
one should not cut and paste this code.

Sorry for only complaining and not fixing the bugs, but I really do 
not have time and bandwith to get all the source and build it.