Welcome! Log In Create A New Profile

Advanced

Re: Equivalent of Apache's SetEnv Variable

Ed W
August 27, 2010 11:00AM
On 27/08/2010 03:20, Jim Ohlstein wrote:
> On 8/26/10 7:07 AM, Ed W wrote:
>
>
>> No one seems quite as excited about this as I feel? What am I missing?
>
> What you say is true, that such a file would be parsed as PHP if
> requested in that manner but it needs to be uploaded successfully
> first. Most modern PHP based galleries will not upload a file ending
> with ".jpg" unless it actually is a JPEG. Same with a file
> misidentified as a PNG. Try it with a phpinfo script. It won't upload
> into apps like vBulletin or IPB. I can't speak for a lot of others
> since I haven't tested them.
>
> If an app does upload a misidentified file so easily, then the onus is
> on the webmaster to configure nginx correctly or, more simply, to not
> use the app or to not allow uploads from untrusted sources. The method
> proposed by Mike will work fine for such insecure apps, but the real
> fix is to fix the app.
>
> The "try_files" approach will be much more efficient than any "if"
> will be if you insist on using an insecure app.
>

I still think you guys aren't getting the point?

The wiki *documents* an insecure method of setting up many PHP
applications. It's almost the number one security vulnerability that
you MUST secure your uploads directory and assuming that the PHP
application can/will do this perfectly is optimistic at best. A little
help from the webserver is your minimum second layer of defence really.
In fact many "secure" PHP applications delegate security of the upload
directory completely to the webserver and ship with .htaccess files to
disable php access...

It's not about whether you and I can setup a secure nginx setup, it's
about the wiki encourage perhaps tens of thousands of users to setup
their systems so that they can be *trivially* broken into. Of course we
can all sit back and call the users who followed "our" instructions
idiots when this turns into a mass epidemic, but in the meantime there
is a huge encouragement to setup a bunch of PHP apps so that they can be
trivially broken into?

You are correct that all kinds of vague ways can defend against various
aspects of this. However, bottom line is that there are few perfect php
applications which perfectly filter uploads. There are a lot of clever
ways to sneak junk past upload filters

Just to knock one final myth on the head. Construct a .jpg file like
this and it appears to me that it will work fine and also slip past many
file filters:

# echo -e "\xff\xd8\xff\xe0" > test.jpg
# file test.jpg
test.jpg: JPEG image data
# php test.jpg
????
hello


The *correct* solution is to:
- Enable PHP for the minimum number of file locations possible
- Treat the upload directory as a special case and disable as much as
possible there (beware ordering in conf files)
- If possible use try_files on certain locations to further limit scope
of attack (may not be possible everywhere)

Why doesn't anyone think this is a huge accident waiting to blowup?

Ed W


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Equivalent of Apache's SetEnv Variable

Raina Gustafson July 29, 2010 12:28PM

Re: Equivalent of Apache's SetEnv Variable

Eugaia July 29, 2010 01:24PM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev July 29, 2010 01:32PM

Re: Equivalent of Apache's SetEnv Variable

Raina Gustafson July 29, 2010 01:34PM

Re: Equivalent of Apache's SetEnv Variable

Raina Gustafson August 03, 2010 05:08PM

Re: Equivalent of Apache's SetEnv Variable

mike August 03, 2010 05:24PM

Re: Equivalent of Apache's SetEnv Variable

Raina Gustafson August 03, 2010 07:20PM

Re: Equivalent of Apache's SetEnv Variable

mike August 03, 2010 07:38PM

Re: Equivalent of Apache's SetEnv Variable

Raina Gustafson August 03, 2010 07:52PM

Re: Equivalent of Apache's SetEnv Variable

mike August 03, 2010 08:26PM

Re: Equivalent of Apache's SetEnv Variable

Ed W August 04, 2010 05:50PM

Re: Equivalent of Apache's SetEnv Variable

mike August 04, 2010 05:52PM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 02:48AM

Re: Equivalent of Apache's SetEnv Variable

mike August 05, 2010 03:10AM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 03:32AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 03:20AM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 03:38AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 04:12AM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 04:12AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 04:18AM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 04:26AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 04:54AM

Re: Equivalent of Apache's SetEnv Variable

mike August 05, 2010 05:18AM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 06:02AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 06:22AM

Re: Equivalent of Apache's SetEnv Variable

mike August 05, 2010 06:26AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 06:46AM

Re: Equivalent of Apache's SetEnv Variable

mike August 05, 2010 06:52AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 07:04AM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 07:16AM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 07:18AM

Re: Equivalent of Apache's SetEnv Variable

Igor Sysoev August 05, 2010 06:50AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 06:52AM

Re: Equivalent of Apache's SetEnv Variable

mike August 05, 2010 03:42AM

Re: Equivalent of Apache's SetEnv Variable

Grzegorz Nosek August 05, 2010 04:14AM

Re: Equivalent of Apache's SetEnv Variable

mike August 05, 2010 04:18AM

Re: Equivalent of Apache's SetEnv Variable

Cliff Wells August 04, 2010 10:48PM

Re: Equivalent of Apache's SetEnv Variable

Ed W August 26, 2010 07:12AM

Re: Equivalent of Apache's SetEnv Variable

mike August 26, 2010 07:22AM

Re: Equivalent of Apache's SetEnv Variable

Jim Ohlstein August 26, 2010 10:28PM

Re: Equivalent of Apache's SetEnv Variable

Ed W August 27, 2010 11:00AM

Re: Equivalent of Apache's SetEnv Variable

mike August 04, 2010 06:20AM

Re: Equivalent of Apache's SetEnv Variable

Raina Gustafson August 04, 2010 10:58AM

Re: Equivalent of Apache's SetEnv Variable

mike August 04, 2010 04:04PM

Re: Equivalent of Apache's SetEnv Variable

Raina Gustafson August 04, 2010 11:14AM

Re: Equivalent of Apache's SetEnv Variable

mike August 04, 2010 04:00PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 136
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready