Unmask your passwords with this JavaScript trick

 

Summary

If you think you mistyped a password into a password field in your browser, a simple JavaScript trick can help you find out by unmasking the password.

Liked by

ce440107 September 14th, 2009

hontiki September 9th, 2009

Events

IT Priorities 2010

Sydney, Australia - 27 Jul 2010
Melbourne, Australia - 28 Jul 2010
Mumbai, India - 4 Aug 2010
Delhi, India - 6 Aug 2010

IDC's Asia/Pacific Cloud Computing Conference 2010
31 Aug 2010

Marriott Hotel, Singapore

In Masking passwords: Why it's not a good idea, Michael Kassner discussed what Dr. Jakob Nielsen had to say about it from a usability perspective.

I get Nielsen's newsletters, and the man knows more about usability testing than any two other people I've encountered put together. Considering that in many ways interface design is security design, applying the principles Dr. Nielsen discusses to making the secure way to use a piece of software the easy way could be a great boon to many software developers.

masked password

In June this year, however, Dr. Nielsen published an article in his Alertbox newsletter titled Stop Password Masking. The summary at the top of the article reads:

Usability suffers when users type in passwords and the only feedback they get is a row of bullets. Typically, masking passwords doesn't even increase security, but it does cost you business due to login failures.

I was (predictably) concerned with how people would take the advice he offered. The truth of the matter is that masking passwords is an essential security feature in many circumstances, such as any time I use my laptop to log into a Web site at a coffee shop where random strangers might shoulder-surf to see my passwords, or any time I do so where there may be cameras overhead that can record what appears on the screen, such as an airport waiting area or library.

Even sitting in your cubicle at work, where you might type passwords more times per day than you do anywhere else in the course of a week, can be an important place for password masking.

On the other hand, there are times it can be nice to see your password, and where you can be reasonably certain nobody else is going to see it on your screen. For those times, it would be nice to have a way to unmask a password.

A snippet of JavaScript is here to save the day:

  var els = document.getElementsByTagName('input');
  for(var x = 0; x < els.length; x++) {
    if(els[x].type.toLowerCase() == 'password' ) {
      var test = els[x].type = 'text';
    }
  }

If you put javascript: at the beginning of that, and delete all the newlines so that it becomes a one-liner, you can delete the text in your browser's address bar and paste the JavaScript snippet in the address bar instead, then hit the Enter key. This will cause masked passwords to be revealed.

unmasked password

If you expect to need to use this often, you can create a bookmark button in your Firefox Bookmarks Toolbar easily enough. Start by creating a new bookmark--any bookmark will do, though you may want to choose one for a page without a favicon. Then:

  1. Right-click on the new bookmark button and select Properties. The title bar for the bookmark's Properties dialog will still show the name of the bookmark's original Webpage while you make edits, but don't worry about that.
  2. Change the text in the Name field to Unmask (or whatever else you want it to say).
  3. Change the text in the Location field the same way you would for the browser address bar, as described above.
  4. Clear the Keyword and Description fields, and fill them with whatever you like (or nothing at all).
  5. Click the Save Changes button.
Properties dialog for Unmask bookmark

Voila. Any time you want to see the password text you type into a masked password field, now, you can just click the Unmask bookmark button in your Bookmark Toolbar.

In Firefox, you can also just drag and drop this link to your Bookmark Toolbar to get the same effect, if you like:

Unmask

You are, unfortunately, on your own for figuring out how to do any of this in other browsers.

Finally, if you are a Web developer and you think it is a good idea to give your site's visitors the ability to unmask passwords when they try to log in, you can always create an Unmask Password link using the above JavaScript snippet. I recommend thinking long and hard about that before making the option available, however.

In an article like this, I can make people aware that there is a danger to security that is addressed by masked password fields, thus leaving it up to the user to make an informed decision. Many visitors to your site on the Internet may not be aware of the risks of unmasking passwords, however, and dumping a lot of text on users explaining the dangers so they can make an informed decision can more than counteract any usability gains from making it possible to unmask passwords with a simple mouse click. Whatever you do, just don't force your users to live with unmasked passwords.

As a final warning, keep in mind that when you walk away from your computer with your password on the screen, the fact that it is masked may not stop someone else from getting your password using something like this JavaScript trick. Most software security techniques, no matter how useful in a networked world, are not proof against physical access to the machine.

Chad Perrin is an IT consultant, developer, and freelance professional writer. He holds both Microsoft and CompTIA certifications and is a graduate of two IT industry trade schools.

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment
Access data anywhere in the private cloud & enable entirely new efficiencies with EMC VPLEX.
Tech Vendor: EMC

ZDNet Asia Live

US court rejects class action status for Intel antitrust suit http://bit.ly/9AbnMF

Non-green IT products 'marketing suicide': This 50-hectare eco-business park is described as a "living laboratory"... http://bit.ly/aCqko4

great! US court rejects class action status for Intel antitrust suit http://bit.ly/9acwER Good day!

Shocked! RT: @danielgoh: Oh really? RT @scoopsg: (zdnetasia) S'pore marketeers not chirping to Twitter's tune http://scoo.ps/dpkySs

Non-green IT products 'marketing suicide': By Munir Kotadia, ZDNet Australia on July 30, 2010 (8 minutes ago) Vend... http://bit.ly/aCqko4

Asian firms aware of IT snoops. http://bit.ly/9eGRxG

sg marketeers not chirping to twitter's tune http://bit.ly/aRAa1Y - baby steps baby steps

Non-green IT products 'marketing suicide': This 50-hectare eco-business park is described as a "living laboratory"... http://bit.ly/cEkDUD

Non-green IT products 'marketing suicide': At the same time, it seems vendors see green technology as a very high ... http://bit.ly/aCqko4

57 minutes ago by greentreats on topsy

Oh really? RT @scoopsg: (zdnetasia) S'pore marketeers not chirping to Twitter's tune http://scoo.ps/dpkySs

@mrcolinlim but of course for more tech updates you can always visit zdnetasia.com

RT @zdnetasia: Searchable Facebook user data posted to Pirate Bay http://bit.ly/ciJQxY

1 hour 54 minutes ago by phyllis777loves on topsy

RT @HazelHassan: Facebook led police to Philippine serial killer -- http://ow.ly/2iGnh

RT @zdnetasia: 10 questions to ask when http://www.zdnetasia.c...

RT @zdnetasia: S'pore marketeers not chirping to Twitter's tune http://bit.ly/bF2aoa

Facebook led police to Philippine serial killer -- http://ow.ly/2iGnh

2 hours 10 minutes ago by hazelhassan on topsy

S'pore marketeers not chirping to Twitter's tune: Marketing via Twitter has not picked up in Singapore, where it s... http://bit.ly/9GEDJS

great! S'pore marketeers not chirping to Twitter's tune http://bit.ly/dotZES Good day!

http://bit.ly/8v7Ov3 S'pore marketeers not chirping to Twitter's tune - ZDNet Asia http://is.gd/dSngs

4 hours 3 minutes ago by easytweeting on topsy

in the mean time, if you need to find PDF eBooks, you may use http://www.findpdf.us/

4 hours 33 minutes ago by findpdf on Researchers find workaround for Adobe PDF fix

Just want to say what a great blog you got here! My appreciation of your work, cause i am an IT student also. Try this one too, http://w...

4 hours 41 minutes ago by winsource on Making the case for Filipino IT entrepreneurship

Hi, We have ton of HP empty cartridges. Could you collect them in our office??
Thanks

1 day 34 minutes ago by Pacific Time Pte Ltd on Recycle your HP print cartridges and get rewards

Thanks Kenneth, for your insights. Good to know people out there can see the issue for what it is, and to do so impassively, that is. ...

2 days 39 minutes ago by yedwin on iPhone 4 shows prudence in procrastination

While I agree that the issues with the device have raised many an eyebrow, I think it's unwise to forget that many phone reviews have...

2 days 51 minutes ago by kennethkoh on iPhone 4 shows prudence in procrastination

The online apple store http://store.apple.com/ is not available now. Maybe it's updating the pricing ;)

2 days 49 minutes ago by mingnow on iPhone 4 to ring in Singapore on Friday

After an awful silence, finally the prices are out..

2 days 45 minutes ago by melvinchia on iPhone 4 to ring in Singapore on Friday

Glad you discovered the Xfce 4.6 magic. Its other endearing feature is its phenomenal configurability. You can make the desktop look and ...

3 days 51 minutes ago by gnome_refugee on Smitten with Xfce 4

yep, tried them all and xfce with compiz/emerald instead of fvwm is by far the best experience I've had. If you didn't know ther...

3 days 49 minutes ago by ggolemg on Smitten with Xfce 4

@mingnow: why do you think so? How do you think the FOSS community could tackle this issue? I'm involved in a lot of efforts to get t...

3 days 55 minutes ago by fredericmuller on Taobao initiates Chinese open source revolution

Geez. I would think giving free books and getting kids to school would be a better place to start.

3 days 3 minutes ago by mingnow on India's US$35 tablet--how low can it go?

I think it's great the that country with the biggest internet population is finally contributing back to the open-source world. I thi...

4 days 50 minutes ago by mingnow on Taobao initiates Chinese open source revolution

hey.there Im Wendy from a PR Agency.I find your blog interesting and well written.In days to come,we would hold an event. Therefore We ...

4 days 20 minutes ago by wendy on iPhone 4 shows prudence in procrastination

It could be done without all these. Just use the opacity addon of Compiz.

4 days 44 minutes ago by hariks0 on How to get RGBA support in Ubuntu