Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How secure is to read a password? #235

Open
miguelvelezmj25 opened this issue Mar 22, 2016 · 2 comments
Open

How secure is to read a password? #235

miguelvelezmj25 opened this issue Mar 22, 2016 · 2 comments

Comments

@miguelvelezmj25
Copy link

I was looking through your examples for capturing a password and I saw this code in one of your examples

String line = reader.readLine("Enter password> ", mask);

However, it is suggested by the Java API as well as many people on the internet to use a char[] instead of a String so that you can write random bytes to the char[] to avoid having the password in sitting in memory in an immutable object.

Security note: If an application needs to read a password or other secure data, it should use readPassword() or readPassword(String, Object...) and manually zero the returned character array after processing to minimize the lifetime of sensitive data in memory.

Console cons;
char[] passwd;
if ((cons = System.console()) != null && 
        (passwd = cons.readPassword("[%s]", "Password:")) != null) {
    ...
    java.util.Arrays.fill(passwd, ' ');
}

I was wondering if this is addressed in your code base or how do you handle security after the user has entered a password?

@gnodet
Copy link
Member

gnodet commented Mar 22, 2016

That's currently not supported.
You need to use the method which return a String at the moment.

@miguelvelezmj25
Copy link
Author

Is there any type of security implemented in the meantime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants