corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
pajamas..
php and javascript advanced md5 authentication system
The connexion between "pajamas", which is an acronym for "php and javascript advanced md5 authentication system" and an actual pair of "Pyjamas" is that when you feel secure, you sleep better. Of course the words sound identical, too.
pajamas began as an attempt to create a more secure login using client-side hashing, which is one-way encryption, and as a demonstration, mainly for other web-coders, to two enormous security holes in all-too-common existence..
The first exists when folk use "public" browsers. Often the username and password are stored on the machine, and can be re-used, even by accident, by other members of the public. Clearly this presents a problem, and one which, for some reason, most people like to forget and/or ignore. Probably, like me, they realized it would need to be done with JavaScript, and then ran in the opposite direction.
The second hole is more obvious, and that is the plain text password travelling freely across the wires. This one has received more worldwide attention, but it's still ignored in most php web applications. There are literally hundreds of articles out there describing how to store a user's password using all manner of weird and wonderful algorithms, to protect it from "unauthorised database access", or "unauthorised server access", and yet still expecting the password to arrive in plain text. GUYS!
If your database isn't secure you are in trouble. Same for your filesystem. These are places over which you have control. The place where you certainly don't have control, ever, is the internet. And the moment that packet of data leaves the user's presumably safe environment it's fair game. Its contents could be stored on any one of the many nodes between server and client, dubious proxy "servers" could scan it, on poorly configured servers (most) passwords will show up on other server's referrer logs, etc. There it is, your plain-text password, travelling around the internet in a bundle of other useful plain text information, like the URL of the so-called secure login page, probably your username. No! This is insane!
pajamas takes an entirely different approach. The password is securely hashed before being sent over the wires. Now, not only is interception no longer a problem (it's impossible to retrieve the password from the hash in the given time-frame, even a very much longer time-frame), but public browsers can't save or cache it, either*, being a one-shot mish-mash of your password and some random generated string. Each time you login, it's completely different.
With pajamas, the only places the password ever exists in the clear are in your presumably secure server environment, and the presumably secure user's brain. This password is only protecting access to this server's content; ergo, breaching the web server breaches the user's "protected" data, anyway. To my reckoning, it would be considerably more difficult to compromise a modern web server and get root, than it is to search some log for the phrase "password".
Which strategy is best? You decide.
Since its birth back in 2004, pajamas spent quite a long time lying fairly dormant, yet working away quietly in the background as a highly useful authentication script. More recently, pajamas has grown into a rather neat modular authentication system, and the old "pj" module has essentially become one of its plug-ins. There's also a "plain" plugin that retains many of the good features of pj, but without the client-side hashing, for situations where JavaScript isn't available (On The Moon, maybe!). pj's client-side hashing is made possible with the excellent JavaScript functions provided by Paul Johnston's javascript MD5 code.
You can enjoy my wee "protected" image gallery, and try-out pajamas at the same time, here. If you'd like to ask questions, give feedback, enlighten me, etc, you can do that at the bottom.
The default module on corz.org uses HMAC-SHA256 over HTTPS. The browser signs a fresh server challenge using Web Crypto. See the SHA256 setup example.
There is also a sha1 pajamas plug-in called "shaggie", which is currently available only inside my other packages (e.g. the distro machine), feel free to download and play around with it; get back to me if you find any issues, thanks.
Here's the current pajamas code..
(of course, most of the good stuff is inside the modules!)
At least, this is the expected behaviour - currently, as far as I know, Opera saves the *typed* password, rather than the *sent* password, effectively defeating all forms of client-side password hashing strategy, dudes! - I've figured out a way around this, by the way, which will hopefully hit the code stage for my upcoming "shaggie" pajamas module. Take it easy!
Hey guys, I've got little knowledge with web programming but I have to say that this looks like a great little project. Keep it up!
Heruka - 28.06.05 11:52 pm
Great stuff!
Spend a little more time meditating - just a little more focus, you will see amazing things.
Thanks.
corz - 15.08.05 4:37 am
oops!
I've just been informed that I missed making this comments file world-writable when we moved servers. Sorree! Gotta get a mysql backend for these things.
pajamas development has been temporarily suspended while my future-pajamas-collaborator and I work on something else together, get a feel for this process, because we have big plans for pj's future..
The idea is to create a sort of universal plugin authentication system that web developers can pick up and drop into their sites, and pajamas would become a part of this, effectively one of the plug-in modules.
PCheese has also introduced me to the wonders of OOP in php, and an oopilized pajamas is definitely coming your way sometime soon.
all good, all to come.
stay tuned!
;o)
doug - 05.09.05 12:02 am
looking forward to it!
John Doe - 22.11.05 11:11 pm
I really like what you have done.
Regarding G Funk's comment on storing the passwords on the server, would you be interested in avoiding this? There are a set of protocols informally called "Perfect Forward Secrecy", or "Forward Secrecy" by some. See first two paragraphs of http://en.wikipedia.org/wiki/Perfect_forward_secrecy .
There are some ways to avoid storing the password on the server. If you are still interested, we could discuss it more.
------------------------------------------
Re: Response to G Funk
------------------------------------------
Well G Funk, it's a mind-bender, that's for sure!
At first glance it seems reasonable to store the password as an MD5 on the server, but in reality, all we have done is replaced the password with an MD5 of itself. In other words, you could authenticate by simply knowing the MD5, just as easily as you can by knowing the actual password.
When I first put pajamas together, I wrestled with this for some time!
corz - 24.11.05 3:17 pm
John Doe, yes, it's interesting stuff, but as I understand it, Perfect Forward Secrecy is more a concept, a standard, than a "system".
Pajamas will likely end up as part of a larger, more modular authentication system, and PFS-like features could certainly be on the cards, for sure, I'd considered a few hacky temporary key systems, and unusual incremental id tagging long before I'd even heard about PFS, but something irks me about the "more guns" approach to security, and I didn't go too far into that.
But I'd like to know more about PFS, especially from someone who knows what they are talking about, and if you know of an implementation of PFS that pajamas could plug-into/mimic/utilise/whatever, then yes, I'd be very keen to hear more. There's an almost secret link to my IRC channel in the toolbar (or rather, a link to a link), feel free to drop in. I am sometimes around.
for now..
;o)
wanbe - 12.01.06 11:35 am
very nice! thx.
Joe Mcstubilhosin - 16.01.06 6:26 pm
Hey, this PHP login doesn't seem to work for me; can you send me a .zip file of one. Maybe that would be easyier to copy then that code has well. Me email is
hacker-helper@gmail.com
Thank you, also if anyone is any good with javascript then I would like on of those; either if fine.
My server can support it so don't think that is what it is either, If anyone else needs some help I can give it just E-Mail me. KK
corz - 20.01.06 9:28 pm
You spotted the zip download link at the top of the page, yeah?
And Javascript is a browser thing, so long as your server supports php (>=v4.2) pajamas will run just fine, after that, it's their problem!
;o)
sami - 28.01.06 12:57 pm
hmm, why don't you use onSubmit instead of onClick handler? It should resolve the click 'log in' issue, atleast to my knowledge
Welcome to the comments facility!
Hey guys, I've got little knowledge with web programming but I have to say that this looks like a great little project. Keep it up!
Great stuff!
Spend a little more time meditating - just a little more focus, you will see amazing things.
Thanks.
oops!
I've just been informed that I missed making this comments file world-writable when we moved servers. Sorree! Gotta get a mysql backend for these things.
pajamas development has been temporarily suspended while my future-pajamas-collaborator and I work on something else together, get a feel for this process, because we have big plans for pj's future..
The idea is to create a sort of universal plugin authentication system that web developers can pick up and drop into their sites, and pajamas would become a part of this, effectively one of the plug-in modules.
PCheese has also introduced me to the wonders of OOP in php, and an oopilized pajamas is definitely coming your way sometime soon.
all good, all to come.
stay tuned!
;o)
looking forward to it!
I really like what you have done.
Regarding G Funk's comment on storing the passwords on the server, would you be interested in avoiding this? There are a set of protocols informally called "Perfect Forward Secrecy", or "Forward Secrecy" by some. See first two paragraphs of http://en.wikipedia.org/wiki/Perfect_forward_secrecy .
There are some ways to avoid storing the password on the server. If you are still interested, we could discuss it more.
------------------------------------------
Re: Response to G Funk
------------------------------------------
Well G Funk, it's a mind-bender, that's for sure!
At first glance it seems reasonable to store the password as an MD5 on the server, but in reality, all we have done is replaced the password with an MD5 of itself. In other words, you could authenticate by simply knowing the MD5, just as easily as you can by knowing the actual password.
When I first put pajamas together, I wrestled with this for some time!
John Doe, yes, it's interesting stuff, but as I understand it, Perfect Forward Secrecy is more a concept, a standard, than a "system".
Pajamas will likely end up as part of a larger, more modular authentication system, and PFS-like features could certainly be on the cards, for sure, I'd considered a few hacky temporary key systems, and unusual incremental id tagging long before I'd even heard about PFS, but something irks me about the "more guns" approach to security, and I didn't go too far into that.
But I'd like to know more about PFS, especially from someone who knows what they are talking about, and if you know of an implementation of PFS that pajamas could plug-into/mimic/utilise/whatever, then yes, I'd be very keen to hear more. There's an almost secret link to my IRC channel in the toolbar (or rather, a link to a link), feel free to drop in. I am sometimes around.
for now..
;o)
very nice! thx.
Hey, this PHP login doesn't seem to work for me; can you send me a .zip file of one. Maybe that would be easyier to copy then that code has well. Me email is
hacker-helper@gmail.com
Thank you, also if anyone is any good with javascript then I would like on of those; either if fine.
My server can support it so don't think that is what it is either, If anyone else needs some help I can give it just E-Mail me. KK
You spotted the zip download link at the top of the page, yeah?
And Javascript is a browser thing, so long as your server supports php (>=v4.2) pajamas will run just fine, after that, it's their problem!
;o)
hmm, why don't you use onSubmit instead of onClick handler? It should resolve the click 'log in' issue, atleast to my knowledge