Security strategies for storing password on disk

后端 未结 3 1163
感情败类
感情败类 2021-02-09 15:43

I am building a suite of batch jobs that require regular access to a database, running on a Solaris 10 machine. Because of (unchangable) design constraints, we are required use

3条回答
  •  感情败类
    2021-02-09 16:25

    You're not far from the best approach given your constraints. You have two issues to deal with. The first is password storage. The second is using the password securely.

    Dealing with the second one first -- you have a huge issue in the use of the command line program. Using options to the 'ps' command, a user can see the arguments used in running the command line program. From what you've written, this would contain the password in plain text. You mention this is an unchangeable interface. Even so, as an ethical programmer, you should raise the issue. If this were a banking application handling financial transactions, you might consider finding another job rather than being part of an unethical solution.

    Moving on to securely storing the password, you don't mention what language you are using for your batch files. If you are using a shell script, then you have little recourse than than to hard code the password within the shell script or read it in plain-text from a file. From your description of storing the password in a separate file, I'm hoping that you might be writing a program in a compiled language. If so, you can do a little better.

    If using a compiled language, you can encrypt the password in the file and decrypt within your program. The key for decryption would reside in the program itself so it couldn't be read easily. Besides this, I would

    • chmod 400 the file to prevent other users from reading it
    • add a dot prefix ('.') to the file to hide it from normal directory listing
    • rename the file to make it less interesting to read.
    • be careful not to store the key in a simple string -- the 'strings' command will print all printable strings from a unix executable image.

    Having done these things, the next steps would be to improve the key management. But I wouldn't go this far until the 'ps' issue is cleared up. There's little sense putting the third deadbolt on the front door when you plan to leave the window open.

提交回复
热议问题