Skip to content

u/bluepostit

In this archive from May 2010 to Sep 2013

4
posts
81
comments
1
media
280
score

Disclaimer: I'm a security consultant.

I took a lookg at your Session class.

  1. Why do you use DES as the encryption mechanism? It's a poor cipher. If you want something compatible, you should try using stronger symmetric ciphers (AES, Blowfish, 3DES. etc). And if none are available, use DES and leave a warning. Hell, I'd throw an error, just like if you are using magic_quotes.

  2. You should be using another cipher block mode. ECB is prone to replay attacks. Use CBC instead (MCRYPT_MODE_CBC) with an IV initialization. Make sure you do it, otherwise PHP just uses \0 (byte 0) and this mechanism will be useless.

  3. Set the session cookie parameter HTTP-Only with session_set_cookie_params(). So if your application is vulnerable to a XSS attack, at least the session cookie can't be read with javascript. Edit: Consider also the secure parameter if you are using HTTPS. When a cookie has the Secure flag, the browser does not send the cookie if the connection isn't HTTPS.

  4. In your code, you are using the _salt attribute as the key parameter for mcrypt_encrypt. You should rename for easier code review and readability.

  5. I haven't read all the code, but if you are using an authentication method, make sure that the session ID gets regenerated on a successful login.

Further edits:

  1. I do not really understand the mechanism for your session. Why do you encrypt the data of your session on the server? It is pointless because if someone compromises the application and reads the sessions, the attacker could use the key that is used in your application (t3st!ng) to decrypt the session data.
9 points

Hi, I just want to drop a quick note.

I'm part of Montreal Python organizers, and we do monthly meetups with 4-5 presentations of 20 minutes. After, we have two free beers at a microbrewery across the street. We always have around 40 to 50 people showing up.

One of the lead organizer of Montreal Python made a speech at the last PyCon on boostrapping a Python community, but it works without problems with a PHP community. His 20 minutes talk is avalaible at the following address: http://blip.tv/pycon-us-videos-2009-2010-2011/pycon-2011-montreal-python-lessons-learned-from-bootstraping-a-python-community-4901495

And if there's anyone from Montreal, feel free to join us at our next MontrealPython!

0 points

Actually you only have one instance of lighttpd running and listening to port 80. What you have is a fork of several php-fpm workers that are idling to have a new cgi request.

As I stated on my comment to enkrs, it is possible to have php-fpm to dynamically create and remove php-fpm workers all depending on the load of the website.

1 points

Ahah I didn't even realized that I sent a link to the xml configuration page of php-fpm. I was just too lazy to ssh into my server and copy the config files.

Could you explain me what you are referring as to user pools? Are you talking about the ability of php-fpm to dynamically spawn more instance if needed?

The only down side I see having the server running a group owner means that in the event of a vulnerability related to the webserver itself (cgi , ssi, etc) you'd be able to read the other user's files if they are group-readable.

Edit: Alright nevermind, just took my first slip of coffee and I understand why the webserver needs a way to access the static files. My bad.

1 points

My comment only applies to a UNIX environment (Linux, Mac OS X, FreeBSD, etc).

The safest way is to have a local user for every instance of wordpress you want to have. That's something all the major control panel do (Cpanel, Plesk, Direct Admin, etc).

Basically each user also run its own instance of the webserver (apache, nginx, lighttpd). With apache it can be done with MPM. I've never done it by myself with apache though, so I could be misleading you. However for lighttpd and nginx what you want to do is have PHP built with PHP-FPM. You spawn one php-fpm instance for every user and you set the appropriate umask to 002.

And then you recursively chmod each folder to only be read and written by the user. Once that's done you also recursively chown the folder to each user respectively.

So in your case, you could create a user for every wordpress instance you want to run. On a linux box you issue this command :

$ groupadd wordpressuser1
$ useradd -g wordpressuser1 wordpressuser1

You configure one instance of php-fpm by setting the appropriate user in a config file. Every php-fpm instance must be listening to a different port. Let's say we create /etc/php/fpm/wordpressuser1.conf :

user wordpress1
group wordpress1
listen_address 127.0.0.1:9001

More info here: http://php-fpm.org/wiki/Configuration_File

You then spawn the php-fpm processes:

$ php-fpm /etc/php/fpm/wordpressuser1.conf

And than you configure your webserver to have a fastcgi (assuming you're using lighttpd or nginx) listener for every virtualhost.

If you have anymore questions feel free, or if I forgot or said something false.

Hope that helps!

Edit: umas 002 will ensure that every new files created by the users (be it using ftp, shell, php, etc) will be accessible only to the user, aka chmod 0700 if I remember correctly.

Edit 2: I just want to let everyone know that the first thing I do when I use a new shared host is to try

<?php system ('ls /home'); ?>

If that works and displays the content, I check if I can do it for the websites hosted on the server. You'll be surprised how many times that happened to me.

6 points

I've been using it for the past year for minor edits (config files, minor edit, etc). However, with the latest release of Netbean 7.0, on the day of the release I couldn't get the Python plugin to work, so I decided to give a try on the post I saw on /r/python on how to turn VIM as a modern IDE for python : http://sontek.net/turning-vim-into-a-modern-python-ide

I have now been using VIM full time for the past 3 days and all I can say : my productivity has risen to a point never seen before.

I will take the time this morning at work to test this guy's config.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.