Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not hardcode passwords?

In my last question "Portable database for storing secrets" the best answer until now tell to use sqlite-crypt.

Reading sqlite-crypt docs, the new param for open the database is the pass-phrase. Of course, I don't want hardcode the password, so I was thinking what the best, simple and fast method to store that password?

like image 576
Click Ok Avatar asked Feb 17 '09 01:02

Click Ok


People also ask

What is a hardcoded password?

Hardcoded Passwords, also often referred to as Embedded Credentials, are plain text passwords or other secrets in source code. Password hardcoding refers to the practice of embedding plain text (non-encrypted) passwords and other secrets (SSH Keys, DevOps secrets, etc.)

What is hard coding example?

(1) A part of a program that has been declared as unchanging. For example, a constant is hard coded and remains the same throughout the execution of the program. (2) Programming code that solves a problem but offers less flexibility for future changes.


2 Answers

Some options.

  1. Ask the user for a passkey (aka they memorize one password to get to all their password) (good idea)

  2. Create a key on the first startup of the app, which is then hashed in your own unique way (bad idea)

  3. Use a mixture of the above, aka give users the options of one, or two (remember my password checkbox)

like image 106
Infamy Avatar answered Oct 02 '22 11:10

Infamy


You pretty well have to store it in a user.

Otherwise you're just substituting some other security mechanism for the one you're asking about...


David's point in the comment on Infamy's answer is well taken. One should allow some flexibility, in case the user is handling protection at a lower layer... So, go vote for Infamy.

like image 29
dmckee --- ex-moderator kitten Avatar answered Oct 02 '22 11:10

dmckee --- ex-moderator kitten