Security Incidents mailing list archives

Re: Suspicious files in /tmp


From: "Matt D. Harris" <mdh () solitox net>
Date: Mon, 18 Jun 2007 20:37:55 -0400

A lot of times in an exploit scenario, you don't have access to stdin. While the script could still be feasibly passed on the command line, this is a much greater restriction and would shut down a number of existing exploits. If you read further in my post, I do address that there're plenty of other interpretters around that would need to adhere as well. I don't see the ld_preload issue as being difficult to modify either, and furthermore not all exploit scenarios involve access to the env. Of course, I'm talking about mitigation here, it's far from a perfect solution, but for a web server environment where the "dump a file in /tmp and then execute it" vector is fairly common, it seems like a logical step for command interpretters to take. I don't think any of us see it as a perfect be-all-end-all solution to prevent web server compromises, but it's probably better than how it is now (the performance hit is negligible, and I don't see any other real down sides). If it even stops 5 out of 50 compromise attempts that get this far due to things like bad cgi or web server-interpretted code (php, asp, et al), then that's progress, and that's a good thing.
I might be missing something though in terms of down sides...
Take care, Matt

Michal Zalewski wrote:
On Mon, 18 Jun 2007, Matt D. Harris wrote:

Some logic to check the underlying filesystem of a script before reading
it would be a very cool addition to perl from a security standpoint.

This is not necessarily a great idea: not only Perl is in no way special,
but like most interpreters, it can be invoked to read scripts from stdin
or any other "volatile" source, without the necessity to store them in a
file. Most interpreters also accept include file search paths and
various command-line switches that would make such restrictions
pointless anyway.

But, say we implement heavily-handed restricted mode for Perl. Should bash
refuse to read from stdin and implement the same check? Gdb? Awk? Sed?
Where do you draw the line?

If you don't want your users to use interpreters, make these programs not
executable by that user; there's really no other way without a major
ovehaul of how un*xes are built.

And even then, interpreters aside, "noexec" flag is *not* an effective
method to stop the user from running custom code, and never was:

  - /lib/ld-linux.so.2 /tmp/myexec
  - LD_PRELOAD=/tmp/foo.so ls
  - etc, etc.

/mz


-------------------------------------------------------------------------
This list sponsored by: SPI Dynamics

ALERT: .How a Hacker Launches a SQL Injection Attack!.- White Paper It's as simple as placing additional SQL commands into a Web Form input box giving hackers complete access to all your backend systems! Firewalls and IDS will not stop such attacks because SQL Injections are NOT seen as intruders. Download this *FREE* white paper from SPI Dynamics for a complete guide to protection!
https://download.spidynamics.com/1/ad/sql.asp?Campaign_ID=70160000000Cn8E
--------------------------------------------------------------------------


Current thread: