Preamble: I have been a long time lurker but first time poster to the Information Security site, so please be gentle with me.
The Situation: I ran into a situation where I needed to securely store a password on a file. Now I know that there are currently many best practices and industry standards for doing such a task but - one of my very first fleeting thoughts on the problem - was to store the password in a file that is only accessible if you already have the password that is written on the file.
Doing this does solve a legitimate problem and there are several better ways of doing it other than to save the password in plaintext. I am aware of this, but the question is more of a why not this way? It seems to be simple solution and often the simple solutions are the best.
Example
UserA's password is mypass this password is stored in plain text on the file password.txt.
The folder that password.txt is in is owned by UserA.
Assumptions
The disk is encrypted so that only the User who owns a file can read it.
The relative protection for file permissions and user passwords are the same.
The permissions for that folder and all objects within that folder explicitly deny all access to everything inside the folder except for the owner. (for the sake of argument say that no other users including root/NT Authority/etc) has access to this folder and it's contents; only UserA.
Therefore:
To read the password in password.txt (which is mypass) you need the password mypass.
If you were to crack the password (mypass) to get access to the file password.txt you would effectively be cracking mypass anyways.
Question
So in a theoretical sense, if you could meet all the conditions in the assumptions, would my password be secure if the contents of the file containing my password was in a secured file?
Is there a name for this type of security as described in this question?
Are there any serious logical flaws in a system like this to secure a password on a file?
Keep It Theoretical
I tried to keep this as agnostic to OS as possible because the purpose of this question is not to question whether or not this is a viable method. In fact, there are several popular methods of accomplishing this very task and most will require that any passwords saved to file be encrypted:
i.e. The send-mailmessage cmdlet for PoSh has a parameter
-credentials (username,password)
but it explicitly will not accept the password in plain text form. This was implemented to actively discourage IT professionals from saving passwords in plaintext on files. I just want to know why it is discouraged.
EDIT 1/16/2016 First of all, thank you all so much for your quick responses and feedback on this question! I have edited my post to clarify a couple of points that were brought up.
Added Comments in the Situation section to explain that this a common practice in SA/Automation work. Also, added a *Keep it Threoretical** section to clarify that I wish to keep this theory as OS agnostic as possible. Thanks!