Click here to Skip to main content
15,884,986 members
Articles / Programming Languages / Java
Tip/Trick

How to Prevent Browser from Save Password Prompt in Struts

Rate me:
Please Sign up or sign in to vote.
4.95/5 (4 votes)
1 Dec 2015CPOL1 min read 11.3K   1   1
Preventing browsers from saving Admin user passwords, intentionally or unintentionally while using STRUTS forms

Introduction

The information security report identified a vulnerability report in which they have mentioned that that after login submission form, the browser asks to "save password" and this saved password can be decrypted easily.

Background

While I started to fix this issue, I searched the whole internet and could not find an answer to this. Most people said that it is the job of the user to select what he wants. But, the development team might not want to take its chances and emphasized to fix it.

Using the Code

Well, after a hopeless search over the internet and trying many things like legendary "autocomplete=off" option (which didn't work, although it helped me to deceive the auto form fill functionality of browsers), I wrote a dummy password field and set its style="diplay:none" and keeping my original <html:password > field intact after that dummy input field and this worked for me to deceive the browsers.

The original implementation was like this:

HTML
 <td align="right" id="any">
  <html:password property="password" 
redisplay="false" styleClass="any" maxlength="10"/>
 </td>

Now, whenever a user submits its form, the browsers (Internet Explorer 11, Chrome) pops a prompt like "Would you like to save Password".

What did the trick was that I modified it this way.

HTML
<input type="password" style="display:none"/>
HTML
<td align="right" id="any">
 <html:password property="password"
 redisplay="false" styleClass="any" maxlength="10"/>
</td>

Points of Interest

Browsers always see the first password field and they look into it to take any further actions. By applying the above trick, now what browsers see is that the password field is empty, they don't prompt to ask for "save password".

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generallooks like a nice trick Pin
rone1231-Dec-15 18:27
rone1231-Dec-15 18:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.