We have relaunched: What's new at ZDNet Asia?

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.

Events

Microsoft MSDN/Developer Event
25 Mar 2010

One Marina Boulevard, Microsoft Singapore

IT Architect Regional Conference Singapore 2010
20 - 21 Apr 2010

Singapore Management University, Singapore

The Internet Show 2010
21-22 Apr 2010

Suntec 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
Transform your business interactions with real-time voice, video and telepresence solutions.
Tech Vendor: Cisco

ZDNet Asia Live

Found this great little deal calculator http://www.zdnetasia.com/downloa...

3 hours 19 minutes ago by winstoncranford on topsy

RT @mistertechblog: I wrote about Nexus One and Touchdown, desktop dock, Bluetooth/USB tethering, ebooks here: http://bit.ly/bRdzx0

9 hours 30 minutes ago by yklee13 on topsy

Read my blog post on getting the most from your Nexus One: http://www.zdnetasia.com/blogs/m...

Data Centre Operator (Fresh Graduates Welcome to Apply) in ... http://bit.ly/bagYuu

10 hours 36038 seconds ago by intmasterfeed on topsy

#Cisco #Cloud Cloud on ZDNet Asia: Aussie university joins Cisco cloud ยท Early-adopter criminals embrace cloud... http://bit.ly/d93C8S #TCN

11 hours 3 minutes ago by thetechgang on topsy

www.3w.com.au has seen it's outsourced IT Contracting Business in Manila grow at 4 times the rate of its traditional Australian Based...

17 hours 41 minutes ago by brucemills on Companies' outsourcing spend to increase

RT @3wconsulting: Whitepaper from http://3W.com.au "Outsourcing Your IT Requirements to Philippines" now on @zdnetaustralia & @zdnetasia http://ow.ly/1oY9f

Whitepaper from http://3W.com.au "Outsourcing Your IT Requirements to Philippines" now on @zdnetaustralia & @zdnetasia http://ow.ly/1oYbA

Whitepaper from http://3W.com.au "Outsourcing Your IT Requirements to Philippines" now on @zdnetaustralia & @zdnetasia http://ow.ly/1oYbz

Zdnetasia.com Estimated Worth $178,365 USD. Daily Ad Revenue:$244 USD, Daily Views:81,445 Pages... - http://www.haplog.com/www.zdneta...

When I create an event, I click on an approximate time during the day when I want the event to occur, then I click "edit event detail...

1 day 10 minutes ago by bessellbrowne on Google Calendar gets 'smart' rescheduling

ipads break alott i had one it broke three times in the month i had it so i got rid of the damn thing id just go for the laptop Top Grade...

1 day 12 minutes ago by bessellbrowne on Report: 'Hundreds of thousands' of iPad preorders

There are a number of websites that still require Internet Explorer to view and IE for Mac Stinks (it is really ies4osx which is the Wind...

1 day 13 minutes ago by bessellbrowne on Microsoft: Only minor tweaks in Windows 7 SP1

The receivers don't transmit back to the satellite. Unless there is a phone line attached to the receiver, they don't have any wa...

1 day 16 minutes ago by bessellbrowne on Apple to join the geolocation craze?

"Lead Cognos BI Developer Insurance - Jobs - ZDNet Asia" http://bit.ly/bRcxOG

1 day 11 minutes ago by rhrcognos on topsy

whatever little understanding I have we 'll only progress toward end of the world if we use HPCs to lenthen life of human being. Huma...

2 days 23 minutes ago by abhi32002@gmail.com on High computing promises elixir of life

Thanks for the knowledgeable article on SDDs. Allas...when all this reasearch will happen in Indian Universities. Hope the new bill on Fo...

2 days 35 minutes ago by abhi32002@gmail.com on APAC HPC users eye solid-state drives

It was a good article. This brings a good opportunity for Indian IT firms to come up with new solutions in this field. HPC can become a b...

2 days 54 minutes ago by abhi32002@gmail.com on High computing most-wanted job in Asia

COL KR DHARMADHIKARY(RETD) its very late to reply the link, but if it is still alive and looking for opportunity, i would like to know th...

2 days 51 minutes ago by deb021280 on Education takes off in rural India, helped by PCs

It was just a matter of time until google was marginalised anyway. I'm afraid this will be forgotten in China very quickly. Still, it...

2 days 56 minutes ago by robinsmith on Report: Google to leave China on April 10

High performance computing (HPC) most-wanted job in Asia http://bit.ly/9vFC3i (via @zdnetasia) #singapore

He doesn't care if her shoes are of glass, All he wants to see is a huge rack and nice a*s. Sleeping beauty's not awoken by true ...

2 days 25 minutes ago by warlowdavies on One pair of 3D glasses to rule them all

RT @zdnetasia: EMC COO, Pat Gelsinger, on bridging gaps in the organization and its cloud ambitions in Asia. (cont) http://tl.gd/i5jjd

EMC COO, Pat Gelsinger, on bridging gaps in the organization and its cloud ambitions in Asia. http://bit.ly/9etOZW

Asian SMBs need to pay more attention to disaster recovery planning http://bit.ly/bDet08 via @zdnetasia

Asian SMBs need to pay more attention to disaster recovery planning http://bit.ly/bDet08

[TECH] URL Shorteners slow Web redirection. - http://bit.ly/bySnWK @zdnetasia

URL shorteners are great but they can slow web redirection & you pray it would never go down http://bit.ly/bySnWK via @zdnetasia

URL shorteners slow Web redirection. http://bit.ly/bySnWK

Chinese agencies cry foul over Google. http://bit.ly/by6rwV

all of sg's isps have been practising compulsory invisible proxy for all home subscribers at their backend since many years back alre...

3 days 35 minutes ago by melvinchia on Web filters mean bad news for business

it is not to good for china.
Proactol

3 days 20 minutes ago by nathonastle on Chinese ad partners beg Google for information

Very good explanation of JMX

4 days 25 minutes ago by Babith B on Managing applications with JMX

The reaction to a report issued Tuesday by Flurry Analytics managed to completely overlook some interesting news--the Android-based Motorola Droid outsold the original iPhone over the same period of time following their respective launches--to focus instead on the sales numbers for the Nexus One.

4 days 29 minutes ago by lonemavericks on diggs

Another ZTE story....

4 days 31 minutes ago by Moderate Your Greed on Philippines opens bid for final 3G license