On Sonntag, 6. Juli 2008, Mats wrote:
> I just installed Pylons and found the ability to execute python
> commands within the traceback pretty cool.
>
> Unfortunately I'm concerned that this could be a major security
> vulnerability. I was expecting that there might be some restriction on
> which machines can access the server, e.g. only to accept HTTP
> requests from localhost. I asked a friend to check from his computer
> and this was not the case: I was giving shell access to my machine to
> the entire web!
>
> It seems that some bright hacker or hacker network could look for
> computers with port 5000 open and attempt to make an HTTP request for
> a non-existent page, and if it's running Pylons then the script could
> automatically insert very nasty code into the traceback from the 404-
> like error message...
>
> ( Yes, the development.ini file says that we should enable the
> debug=False option for production, but in my humble opinion 1) that
> message seems rather hidden (as opposed to an explicit warning yes/no
> prompt the first time one runs "paster --serve development.ini"), and
> 2) it seems to imply that running with debug=True as the default state
> is fine when you're new to Pylons and just wish to test this out of
> the box. )
The warning about the debug mode isn't that hard to find. The senior chief
deployment officer is supposed to customize the INI file anyway because
that's what controls the behavior of the deployed application. You can't
really blame the developer of the software if their users don't read the
documentation.
Pylons is lead developed in the USA but I hope that doesn't meant that we
others need all these security stickers like telling that microwaves
aren't suited well for drying cats and that you should remove the
sunscreen from your car before driving.
The warning is there. And the paste_deploy_config.ini_tmpl (the template
that is used to create INI files when you deploy the application) has set
debug to False. So almost everybody should be safe. And the others deserve
to get hacked. :)
Cheers
Christoph
--
When you do things right people won't be sure you've done anything at all.
Mats brings up an important point, that if your development
workstation is accessible from the Internet, unintended users can
access your unfinished application. For most developers, being
limited to localhost is entirely sufficient. If developers do need to
share their unfinished app with colleagues on an internet or the
Internet can change their development.ini. But even then, there
should be a warning about putting it behind basic authentication and
SSL.
--
Mike Orr <slugg...@gmail.com>
Sorry, I didn't mean to be harsh. But you sounded like you found the answer
while posting to the mailing list but wanted to complain anyway. The
warning is there. And if someone really deploys an application with debug
mode on (which means the default INI file was trashed) then that's what I
meant by "they deserve to get hacked". Like my father-in-law who clicks on
any warning dialog without even reading it. :)
> After further pondering, I feel this is a valid concern (not addressed
> in docs or startup script),
I second the idea to only bind the web server to localhost so nobody else
can access the application during development unless the developer
explicitly says so. But I'm contra disabling the beautiful interactive
debugger by default - people might miss it out accidentally and it's one
of the reasons I favor Pylons over anything else.
One thing I definitely second is that the documentation needs a little
going-over. So if you didn't find the deployment information in the first
place that's understandable.
> Also thank you Mike for mentioning how to restrict allowed subnets --
> I didn't realize that was an allowed-ip-addresses netmask; one might
> consider renaming it to something other than 'host' (e.g.
> 'allowed_subnet 127.0.0.1 # (0.0.0.0 to allow any client on the
> internet)') unless this is standard nomenclature.
I don't think you can use a network/netmask or multiple IPs; you can
just use an IP/domain name or the special address 0.0.0.0. I was
thinking of a situation where you're connected to both a local network
10.0.0.0 and the Internet; you could allow it to listen to the local
network.
The official addressing documentation is in the Python library
reference at the beginning of the socket module. The word 'host' is
traditional; I'm not sure 'listening_network' is any better. But
given that PasteDeploy is widely deployed with the current name,
renaming the variable would increase confusion.
But Python, Paste, and Pylons all need to document better what the
allowed values for 'host' are.
--
Mike Orr <slugg...@gmail.com>
It would probably be good to put a setting in evalexception to check for
this setting, and then when/if Pylons puts in some basic handler by
default (the simplest one would be a check that the connection was on
localhost) it can turn that setting on. This would make debug settings
generally less necessary.
--
Ian Bicking : ia...@colorstudy.com : http://blog.ianbicking.org
That's what the X-Forwarded-For header is for. It must be checked in
addition to Remote-Addr.
Cliff
That's what localnet is for -- all of 127.0.0.1 to 127.255.255.254 are
your own computer, for those occasions where you need 16,581,373
different IPs to test your new multiservice application (perhaps a
Twisted Names application). Well, it *was* assigned in the days
before IP scarcity.
Of course, never leave it to Microsoft to let a mere standard get in
it's way, so somebody with Windows will have to test whether it works
there.
In any case, we can't put something as nonstandard as 127.0.0.2 in the
default development.ini. A lot of users would look at that and think
it was a mistake. And there may be some platform somewhere where it
doesn't actually work.
--
Mike Orr <slugg...@gmail.com>
I happened to be tinkering a bit on a XP test. A quick test showed
that you can at least ping the entire 127/8 address space in XP. I would
expect that you can bind to those addresses as well, but I couldn't
quickly test that (no python installed).
Wichert.
--
Wichert Akkerman <wic...@wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
FWIW, recent-ish Linux distributions have been putting entries similar
to this in /etc/hosts:
127.0.0.1 localhost
127.0.1.1 norval.mydomain.com norval
So gethostbyname("localhost") and gethostbyname(hostname()) return
different local addresses.
Cheers,
Chris