Firefox plugin installer code

If you’re nerdy enough to care, here’s the code to install a new search plugin…

// Firefox plugin installer code

function addEngine(name,ext)
{
if ((typeof window.sidebar == "object") && (typeof
window.sidebar.addSearchEngine == "function"))
{
window.sidebar.addSearchEngine(
"http://www.example.com/searching/"+name+".src",
"http://www.example.com/searching/"+name+"."+ext,
name,
"" );
}
else
{
errorMsg(name,ext,"");
}
}

Firefox plugin installer code

Eval is Evil

Just read an article on Sitepoint about PHP’s Eval function, and basically, how it is evil.

Eval let’s you ‘run’ a string, as if it were code. Sounds useful, but I can’t say that I’ve ever found a situation where it is a good idea. Quite apart from the security risk highlighted – which is really more a question of user input validation – it seems to me that if you’re writing a programme, you should know what it is supposed to do up front.

If you already know what it is supposed to do, why would you need an eval function at all? Why not just programme it that way. Sure, I can see how eval might be a useful ‘shortcut’, but it just isn’t elegant

Eval is Evil

Javascript in the IE Links bar

I discovered this in the course of some work at a customer’s site – you can put Javascript into IE’s links bar!

The links bar is intended to give you buttons to take you to your commonly used websites (although it is nowhere near as good or useful as Firefox’s links bar, which is more like a menu). You press a button, it goes to that page.

However, in HTML in an anchor tag you can specify to Javascript to run, rather than just a page address. Out of interest, I tried doing this with IE’s links buttons, and it worked.

I was looking for a way to get a substring of the URL that the browser was currently at. The URL was of the form:
http://server/instance/app.dll?action=x&id=1234&next=y
and I was trying to get the value of the ‘id’ parameter (1234 in this case).

What I came up with was a URL that I put into a link. The URL was (one one line):
javascript:x=/id=([0-9]+)/i;x.exec(window.location);
window.clipboardData.setData("Text",RegExp.$1);alert(RegExp.$1);
To break it down:
javascript:
specifies that it is javascript code, not just a page address.
x=/id=([0-9]+)/i;
sets up a regular expression to get the ID
x.exec(window.location);
applies the expression to the current location of the browser window.
window.clipboardData.setData("Text",RegExp.$1);
copies this ID to the clipboard.
alert(RegExp.$1);
confirms that this has been done.

And it works! Hard to believe, but it really works! I’m sure that there must be some sort of security issue here – I need to think about how this might be abused, but there should be a way. Will let you know when I think of something…

Javascript in the IE Links bar

Passwords, Secret questions, and expiring Authentication

An interesting morning, not bad given that it isn’t 0915 yet. Anyways, I’ve just read some fascinating articles…

A guy I work with had been asking about how to figure out the entropy of a password. This is, put simply, measuring the disorder of a password – the more disordered, the harder it is to predict. And this is very hard to do, for reasons I’ll explain some other time.

Anyways, we then discussed passphrases. Instead of being a word like ‘Bgc4$4q2’ or something equally obscure, you use a phrase that would be difficult to reproduce – ‘Eat flying doughnut on Thursday’. This is still difficult to figure out the entropy for – you could choose an easily predicted password (e.g. ‘In the beginning God created the heaven and the earth’) – but is generally more secure.

So this morning I read a fascinating article by a guy from Microsoft PSS Security about passphrases. Worth a look for all techies, certainly I’ll be looking at using passphrases from here on.

I’ve also just read an article about how authentication never expires in e-commerce sites. An interesting point – it should be possible to terminate accounts on e-commerce sites. I mean, if you don’t, if the account is still valid, then your details could be used. But I can’t say that I know of a way to go to Amazon and tell them to disable my account.

I guess one option would be that if an account just hasn’t seen any activity in a while, you send out an email warning of it’s impending shutdown. If there is no response, close it down. Not perfect, but you’re making the window for the abuse of that username/password smaller.

And lastly, there is an article on why secret questions are a bad idea for password recovery. Basically, it’s the old ‘Security is as good as it’s weakest link’. Never liked these things anyway.

Passwords, Secret questions, and expiring Authentication