You are here: Home > Blog > Preventing a common security problem with login forms
I've seen this mistake so many times, I find it quite annoying but it's also a potential security risk, let me explain...
The problem occurs on pages that have a login form with a username and a password. In an attempt to make the login process easier, the web designer adds a piece of JavaScript that sets the focus to the username field when the page loads. The idea is that this saves the user from clicking in the field before they type. However this often causes more problems than it solves. On slower connections the timing of the focus can wreak havoc.
I have found this problem on some pretty major websites; Digg and Network Solutions are good examples. I alerted Network Solutions to the problem months ago but it still hasn't been fixed. It seems security is not a priority for them.
So what can be done to fix the problem?
The answer to the problem is really quite simple. All we need to do is add a check to the JavaScript function before we set the focus. If there is already a value in the username or password field then do nothing, if they are blank then set the focus. Done!
© Copyright 1993 - 2007 Matthew James Taylor | About & Contact | RSS feed