Desi Founder @ Work

01 May, 2008

Security by obscurity works best sometimes

Posted by: sharjeel In: Security

When I was graduating from FAST-NU, I designed a web based system in PHP/MySQL for collecting data for Yearbook of our batch. Each student of our batch was given a username and password using which s/he could enter the personal data, make comments about friends, give nicknames and other such features.

At that time there was no server in our university available on which it could be deployed and the only place to host it was a Windows based machine in the labs on which all files in wwwroot folder were readable to anyone logged into the machine. But it did not mater as the MySQL database was secure and I did not mind anyone getting my PHP code. The only problem was that the password to MySQL had to be stored in a PHP config file and it could be read by anyone. I knew one naughty junior was already looking forward to the deployment of the application and I did not want to take any risk. On the other hand I wanted to get it deployed ASAP as well.

I thought about encrypting the password but the key had to be stored at a world readable place. I thought about many other possibilities but found loopholes in each of them. Finally I came up with a clever scheme. After applying it my config file looked like this:

$db_host = “localhost”;
$db_user = “yearbook”;
$db_pass = “********”;

Two days later the kid showed up looking a bit frustrated. He said “How the hell did you mask your password in a PHP file? I have looked all over web and I couldn’t find any info about password masking in PHP or any other text file”.

With a smug look I replied “I rewrote the NTFS to do that”. He went away looking a bit angry as well as disappointed.

I wish the poor chap had thought about the possibility of using eights asterisks as my password.

Tags:

7 Responses to "Security by obscurity works best sometimes"

1 | Omar

May 1st, 2008 at 5:51 pm

Avatar

To quote AC Doyle “Eliminate the impossible and whatever remains however improbable must be the truth”
:-)

2 | Robert Lee

May 1st, 2008 at 8:03 pm

Avatar

Wow, that’s just stupid. I mean, sure, that junior didn’t consider the obvious…but how many other students did?

The first thing I thought about when I saw your code was: “Maybe the password is just the asterisks.” My next thought was “Maybe he put 0×08s in the file immediately after the password, then put asterisks…but would that work in most text editors?” Guess which avenue I’d have explored first.

I would have tried to log into the server with the asterisks immediately upon seeing your code. I wouldn’t have been certain it would work, but I would have tried. And succeeded.

And that’s exactly the problem with security through obscurity. For every junior you fool, there is a senior you didn’t. And if he’s good, you’ll never know he got in. You’ll go on thinking, “Wow, that security model worked really well.” Then someday you’ll proudly blog about your wonderful discovery only to be mocked and laughed at by your peers.

Looks like that day has come. Congratulations.

3 | Hassan

May 2nd, 2008 at 4:47 am

Avatar

Interesting comment by Robert Lee :)

4 | Jaafer Naqvi

May 2nd, 2008 at 6:55 am

Avatar

hahahaha …….. yaar Sharjeel tu chah chu gaya ha :D
im still lmao :D

5 | Irfan

May 2nd, 2008 at 4:14 pm

Avatar

May be that kid was trying to assure you that your idea has worked and you do not need to apply further securities: P

6 | Khichi

May 2nd, 2008 at 9:47 pm

Avatar

@Irfan

Were you the kid?

Comment Form


  • sharjeel: @m: I'm not discouraging, I'm just making a distinction to make things clear. @Stas Shtin: Thanks for pointing out. I hastly wrote the code earli
  • ben: bm: I went and read section 1.2.1 of SICP as recommended in the reddit comments and the distinction between forms of functions and processes makes mor
  • Ned Batchelder: You might want to read Structure and Interpretation of Computer Programs, section 1.2.1. There they make a clear distinction between recursive proces

Flickr PhotoStream

    Cunning Cat Sultan Hotel - Jakarta Streets of Jakarta Streets of Jakarta For Sale My nephew, Hassaan LUMS under blue sky Economic Disparity Shakkar Qandi 

About

Desi Founder @ Work. A Pakistani tech entrepreneur's journal