PHPSecure 2.0
Posted: Fri Dec 22, 2006 10:46 am
As a PHP developer over the last couple of years, I've developed several webpages, most of which needed some form of login. Realizing that this was going to be a common need throughout my development career, I decided to develop a PHP security engine capable of most common security tasks.
My first version of this engine was developed in response to a need for a high-security database management application for a client I was working with. While it worked well, it was rather inefficient, and required a fair amount of overhead. Once it was in fair operating order, I took the code and saved it, deeming (rightly) that I'd be able to use it again. Since that time, I've used it in a total of 3 websites, upgrading and tweaking it as I went. However, this still didn't change the fact that it was rather inefficient, and had a fair amount of overhead that was completely needless.
Thus, over the past 3 days, I've rebuilt the system from scratch. The engine currently consists of 393 lines of code, as well as a settings file, strings file, and publicly available javascript implementation of the md5 hash function. The new security system has many important features:
A user system, complete with ready-to-use login form incorporating extreme password security
A configurable and powerful \"groups\" system to distinguish users from each other
A decent set of function calls, including a replacement for the mysql_query() function
Development enhancements--ensure a user is allowed to perform certain actions in certain areas of your website as he/she is attempting to perform them
Maintenance tasks, such as opening SQL connections, are performed for you
Multiple security features, including:
Inclusion hack blocking
Automated buffer overflow attack prevention for all $_GET and $_POST variables
SQL injection hack prevention
clean_input() function to clean up any user input
Cookie-based login system featuring three layers of encryption--if a user has Javascript enabled, it is impossible for anyone, even the website the administrator, to get access to their unencrypted password
This is certainly a developer's tool--it won't help you unless you know how to use a database and know PHP fairly well. What it WILL do is reliably, securely, and efficiently check user logins and groups, as well as ensure input variable security. However, it does have a few requirements in order to perform its job as expected:
An installation of the Crypt/Blowfish PEAR extension
An installation of PHPMailer, a PHP implementation of SMTP mail
A MySQL database (though this can be replaced with Microsoft SQL by doing a simple find/replace on the security pages)
So, on to the main point of this post. Basically, at this point, I'm finishing up some small tweaks and doing a boatload of testing in preparation of moving to a public release. At this point, my purpose in posting this is twofold.
1. I want to gauge interest in a developer's aid such as this
2. I want to see what features and comments YOU have on this project. What would YOU like to see in the way of function calls, security features, or automatic protection?
Any comments/questions/suggestions? I'll be more than happy to look into even the most farfetched idea, if only to see if it's possible. Hopefully I should be able to finish up the rest of this project in a couple of days, and when I do I'll make this available as a public download.
My first version of this engine was developed in response to a need for a high-security database management application for a client I was working with. While it worked well, it was rather inefficient, and required a fair amount of overhead. Once it was in fair operating order, I took the code and saved it, deeming (rightly) that I'd be able to use it again. Since that time, I've used it in a total of 3 websites, upgrading and tweaking it as I went. However, this still didn't change the fact that it was rather inefficient, and had a fair amount of overhead that was completely needless.
Thus, over the past 3 days, I've rebuilt the system from scratch. The engine currently consists of 393 lines of code, as well as a settings file, strings file, and publicly available javascript implementation of the md5 hash function. The new security system has many important features:
A user system, complete with ready-to-use login form incorporating extreme password security
A configurable and powerful \"groups\" system to distinguish users from each other
A decent set of function calls, including a replacement for the mysql_query() function
Development enhancements--ensure a user is allowed to perform certain actions in certain areas of your website as he/she is attempting to perform them
Maintenance tasks, such as opening SQL connections, are performed for you
Multiple security features, including:
Inclusion hack blocking
Automated buffer overflow attack prevention for all $_GET and $_POST variables
SQL injection hack prevention
clean_input() function to clean up any user input
Cookie-based login system featuring three layers of encryption--if a user has Javascript enabled, it is impossible for anyone, even the website the administrator, to get access to their unencrypted password
This is certainly a developer's tool--it won't help you unless you know how to use a database and know PHP fairly well. What it WILL do is reliably, securely, and efficiently check user logins and groups, as well as ensure input variable security. However, it does have a few requirements in order to perform its job as expected:
An installation of the Crypt/Blowfish PEAR extension
An installation of PHPMailer, a PHP implementation of SMTP mail
A MySQL database (though this can be replaced with Microsoft SQL by doing a simple find/replace on the security pages)
So, on to the main point of this post. Basically, at this point, I'm finishing up some small tweaks and doing a boatload of testing in preparation of moving to a public release. At this point, my purpose in posting this is twofold.
1. I want to gauge interest in a developer's aid such as this
2. I want to see what features and comments YOU have on this project. What would YOU like to see in the way of function calls, security features, or automatic protection?
Any comments/questions/suggestions? I'll be more than happy to look into even the most farfetched idea, if only to see if it's possible. Hopefully I should be able to finish up the rest of this project in a couple of days, and when I do I'll make this available as a public download.