uppajamas demosreadmeview sourcedownload sourceleave feedback
 
an image of some pajamas!

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.

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.


have fun!

;o)
(or


references:
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!
 
cbparser powered comments..

previous comments (two pages)   show all comments

huskey - 24.06.05 11:17 am

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! smiley for :D


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.


cor - 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. smiley for :lol:

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)
(or


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!


cor - 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)
(or


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


cor - 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)
(or


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 knowledgesmiley for :D


cor - 29.01.06 5:45 am

Hmm. sounds good. I'll try that sometime. Thanks. smiley for :D

But then, it's only Internet Explorer users that suffer, and they do that anyway! smiley for :lol:

;o)
(or


Dane - 30.01.06 4:58 am

Maybe I missed this, but there's still a bit of a problem with this... that is, how to create the password in the first place. If you already know it, that's wonderful, but is there any way for a user to create a password and send it to the server for the first time without doing it in plain text?


cor - 30.01.06 6:16 am

Nope, Dane, this isn't a mechanism for creating passwords, just for authentication. There are possibly other ways to do that, but it's not something I've ever needed, or looked at. Sorree.

;o)
(or

ps.. sami, onsubmit doesn't seem to make any difference in IE. I'll maybe have another fiddle later.


cor - 28.03.06 10:30 am

Observant sorts may have noticed that earlier today I uploaded the new "pajamas modular authentication system", which is pajamas taken to the next level.

pajamas.php becomes a module-loader-authentication-engine-thing, and the old "pj" is now effectively a plug-in, works great. Everything is pure xhtml 1.0 strict, and with help from PCheese, 100% OOP! I expect oop-ness to start sneaking into my other php, it's certainly an intuitive way work the code.

Though I have tested it out fairly thoroughly, and am using it right now elsewhere, I expect bugs, and bug reports are most welcome. Feel free to play around with the demos (links at the top) and download the pajamas package, which comes with two plug-in modules "pj" and "plain", as well as the pajamas demos, example code, etc. Check out the readme for more details. You can also view the source right here.

Thanks for all the input so far, here and by mail, hopefully the new system will be all that was hoped for and more.

for now..

;o)
(or

ps.. when I first uploaded the whole lot here to corz.org, the "simple" interface demo didn't work, kept telling me the password was wrong when it wasn't. Then I remembered about the phpsuexec here at my host, added a few local php.ini files (whose only session directive is session.use_trans_sid = 0). All is suddenly well! Hmm. Any thoughts on would be appreciated.


cor - 08.10.07 12:14 pm

By the way, although there's not an official release, as such; if you grab the latest version of my distro machine, you get a pajamas installation with a SHA-1 module. It also outputs strict XHTML, which I don't think the current release does.

I'll put together a new pajamas distro proper in the near future.

By the way; here at corz.org, apart from the comments, pajamas controls all my authentication, and I pretty much have a site-wide login, which is real nice.

;o)
(or


Ryan G - 25.11.07 7:04 pm

Corz, I cam here via this page:
http://foruhttp://forums.invisionpower.com/index.php?showtopic=181089&mode=linearplus

It says that pajamas is only "obscuring" the password. Is this true?

Best.
Ryan.


cor - 26.11.07 4:57 pm

Heh, no.

Either the poster a) didn't look at the code, or b) didn't understand it.

Whether you can see the "random number" is irrelevant. Firstly, pajamas uses many criteria to judge whether a particular user is authenticated or not, and secondly, even if someone had access to some as-yet-uninvented computer that could find a collision within a reasonable time-frame, it would be ABSOLUTELY NO USE TO THEM. It became out-of-date the instant it was received. Which is kind of the whole point.

Also, there's a SHA1 plugin, so even our theoretical computer wouldn't help!

;o)
(or

ps. I've been using pajamas on-site, for all my admin authentication, ever since it was first created, and with 100% success.


Me - 08.06.08 2:05 am

What stops someone reverse-engineering your system by looking at the source code of the page?

"The only "weakness" with the current pajamas implementation is that your password is visible to someone if they have access to your raw filesystem, and if they have that, no amount of authentication will stop them getting your goodies, will it? pajamas isn't designed to protect you from unscrupulous hosting admins!"

And what happens when a cracker accesses your raw filesystem via URL injection?


cor - 08.06.08 3:22 pm


What stops someone reverse-engineering your system by looking at the source code of the page?


You can even look at the source code for the pajamas package itself; it won't help you reverse engineer anything; there's nothing to reverse-engineer, MD5/SHA1/etc. are one-way cryptographic functions. The code is already well-known.


And what happens when a cracker accesses your raw filesystem via URL injection?


My first response to this is.. stop talking nonsense! However, you may know something I don't; so if you tell me exactly how this attack is crafted, and how you could access my raw file system with it, I may amend my response.

;o)
(or

ps. I've uploaded a file /inc/db/.ht_secrets - please use your attack and tell me the password contained in that file. Cheers!


Frosty - 10.07.08 10:18 pm

um, a bit of help please? When ever I use the PJ theme (which is the one that I want to use) it won't work smiley for :erm:. Also, my sessions are messed up. In the .php file I have it set at the default (60 I think) and in the root php.ini file I have
PHP.ini
session.gc_maxlifetime = 1440
session.use_trans_sid = 0
(just a standard installation of php5, apache, and mysql). The demo in this just sits there saying that the password is wrong when I enter the correct one.

I'm just trying to get this to work were I have some users working on a tutorials page.

Thanks,
Frosty

PS. I Also have a copy of PHPBB and it works how it was supposed to. A "needed stuff" page similar to phpbb's would be helpful smiley for :)


cor - 11.07.08 12:45 am

I don't know what a standard installation is, if such a thing even exists, and without more in the way of real error messages, your pj troubles are also a mystery to me.

Feel free to mail me whole screeds of log output, php error messages, copies of pj, between now and when I wake up, tomorrow. If there's only a single error message, or a small amount of useful data, drop it here.

I didn't realize there was "needed stuff" for pajamas, aside from basic php4+. But there may well be. Again, more details welcome.

You've seen the readme link at the top of the page, right?

;o)
(or

ps. iirc, the latest pajamas release, currently, is inside the distro machine beta (elsewhere onsite), there are differences that may affect how the old release demo works, but pj itself works great. check the implementation in the distro machine beta.


 

leave a comment, become part of this site!


First, confirm that you are human by entering the code you see..

(if you find it difficult to read, refresh the page for a new code)


Enter the 5-digit code this text sounds like : lower-case you, Upper-Case Aitch, foor, lower-case ex, Upper-Case Em


 
 
[site notice]

If you give a shit, BUY A SHIRT!