exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

lfv.txt

lfv.txt
Posted Jul 18, 2001
Authored by Antonomasia

Looking for Vulnerabilities - Our approach has been to look for a few common mistakes in programs (and scripts) of interest (mainly setuid, setgid programs and network servers). This paper focuses on unsafe temp files, unsafe environment, and buffer overflows.

tags | paper, overflow, vulnerability
systems | unix
SHA-256 | f66499c4db19f49b5b6f1abda1969d8574ee7a5fbe0ed73010d9c2401d1d8dac

lfv.txt

Change Mirror Download
             =====================================
Looking for Vulnerabilities
(Antonomasia <ant@notatla.demon.co.uk>)
============================================

Our approach has been to look for a few common mistakes in programs
(and scripts) of interest (mainly setuid, setgid programs and network
servers).

The common flaws are:
1) unsafe temporary files
2) dependence on the environment
3) buffer overflows

With shell scripts it has just been done by inspection, after finding
the ones likely to be interesting with 'find' and 'grep'.
Examples such as this one

find /somewhere -some-options > /tmp/rm$$
rm `cat /tmp/rm$$`

show that the user is risking the removal of files he doesn't intend
if /tmp/rm$$ exists already having been prepared by an attacker.

With binaries, the first two faults listed above tend to be visible
under commands like:

strings - prog | \
egrep '[Tt][Mm][Pp]|popen|^system|chown|chmod|%s/|/%s|%s.*>|/usr|usr/'

These match references to "/tmp" and similar names and the tmpnam() C
function. The " -c", system and popen strings are famously dangerous in
these programs for the following reasons:

they give commands to the shell (to be avoided)
the PATH (and other environment) gets used
input might include shell metachars (and limited taint-checking here
by the programmer is often flawed)

chown and chmod have obvious security implications so it is nice to know
when a program uses them. The %s constructions suggested above are
often used in data given to a shell. So when you suspect that the shell
is being used these often indicate what the shell is likely to be doing.

When you see text like "/some/program -opts %s %s >/dev/null 2>&1"
This suggests a command similar to ./snmpcheck AAA BBB';/bin/sh #'
as a way to get a root shell. The program is obsolete on the platform
where this was observed.

Sometimes this does not work well, the program may be well-enough
written to drop privileges before calling external programs. Further
greps looking for the setuid family of system calls, umask, chdir, PATH,
and anything else prompted by earlier observations may shed some light
on the proceedings. On small programs you can read the entire strings
output (perhaps varying the minimum string length). I normally pipe
this through "uniq -c" to reduce the length slightly.

For perl CGI scripts the constructs system("something"); and
open(H, "command|"); are dangerous and should be viewed similarly.

Failure to set a umask or specify a mode for a file can be a fault as
the setuid program may create world-writable files as root. With a
little care you can overwrite the file of your choice: perhaps a startup
file called from a script like
[ -f /usr/sbin/foo/file ] && . /usr/sbin/foo/file
where a mode of 666 does not prevent the content being executed.

Use of a wrapper program to list UID, GID, CWD and the environment can
help expose the way something is called. It also helps if it lists all
parent processes leading back to init. Sometimes you see shell scripts
disguised as C programs where there are popen() calls with long
pipelines such as "ps|grep|cut" in them. If the PATH has not been set
this could be easy to compromise. Another feature I've seen in code
like this is that programs are setuid something non-root. This means
that although nobody can get root access this way there is still the
chance of adjusting the programs unless ro mounts or non-traditional
filemodes are employed.

Buffer Overflows

For testing local setuid programs it may be necessary to copy the
program to a non-suid file because on many modern systems setuid
programs will not dump core and you will want to look at the corefiles.
Some programs will (in production versions) refuse to dump core anyway
via setrlimit().

Beside stdin, you have influence over a number of other inputs such as
the command-line arguments, environment variables and current directory.

Passing a large string to the program (a few thousand chars) may cause
a segmentation fault and core dump if the data is being read unsafely.
Depending on how the program works you might need to test this over a
network connection (or getpeername() may prevent the faulty code from
being reached) or you might simply run the program under a debugger
with "break gets" if it is that blatantly wrong.

##############################################################
# Antonomasia ant notatla.demon.co.uk #
# See http://www.notatla.demon.co.uk/ #
##############################################################
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