简体   繁体   English

在这种情况下,在机器上安全地存储密码?

[英]Storing a password safely on the machine in this scenario?

I am trying to find a way for my application to store a username and password (which must be retrieved later in raw form after decrypting - hashing is not an option). 我试图找到一种方法让我的应用程序存储用户名和密码(必须在解密后以原始格式检索 - 散列不是一个选项)。 At first glance, I thought of some simple encryption algorithm. 乍一看,我想到了一些简单的加密算法。

However, most encryption algorithms (even the ones using a SALT or PEPPER) are flawed in that decompiling the C# executable can easily tell what the SALT and PEPPER is, and how the codes are decrypted. 但是,大多数加密算法(甚至使用SALT或PEPPER的加密算法)都存在缺陷,因为反编译C#可执行文件可以很容易地判断出SALT和PEPPER是什么,以及代码是如何解密的。 This can be fixed by obfuscating the code - however, ultimately even that can be broken. 这可以通过混淆代码来解决 - 但是,最终甚至可以解决这个问题。

I realize I might be going into extremes here. 我意识到我可能会在这里走极端。 However, my application will be used by major companies around the world, and security is super important (oh, and I am also hypothetically interested in a solution). 但是,我的应用程序将被世界各地的大公司使用,安全性非常重要(哦,我也假设对解决方案感兴趣)。

The program will only run on Windows 7 or later. 该程序只能在Windows 7或更高版本上运行。

Initially I looked into the ProtectedData class in C#, which makes the password secure for the current user. 最初我查看了C#中的ProtectedData类 ,这使得当前用户的密码安全。 However, I want security for the current program as well (if possible), so that other programs running on the same user can't fetch the password. 但是,我也希望当前程序的安全性(如果可能),以便在同一用户上运行的其他程序无法获取密码。

Then finally, I realized that Windows 7 and later has a Credentials Manager in the control panel, and that applications can interact with this ( and so can C# ). 最后,我意识到Windows 7及更高版本在控制面板中有一个Credentials Manager,并且应用程序可以与此交互( C#也是如此 )。

However, is the Credentials Manager secured to the current user, and the current program as well? 但是,Credentials Manager是否已保护当前用户以及当前程序? Can other programs on the same user still access the credentials? 同一用户的其他程序是否仍可以访问凭据?

If yes, does there even exist a way of securing this data entirely? 如果是,是否存在完全保护这些数据的方法? I trust in Windows 7's Credential Manager to be safe enough , but I am just concerned that other applications can freely take my application's data. 我相信Windows 7的Credential Manager 足够安全 ,但我只关心其他应用程序可以自由地获取我的应用程序的数据。

Edit - it should probably be mentioned that I have a code signing certificate from StartSSL if that's of any use. 编辑 - 应该提到我有来自StartSSL的代码签名证书,如果有任何用途的话。 Not sure how that would help though, but maybe you have a clue. 不知道这会有什么帮助,但也许你有一个线索。

From whom are you trying to protect the password? 你想从谁那里保护密码?

The fact is, if the password is stored on the local computer, then someone who has physical access to that computer can access it. 事实是,如果密码存储在本地计算机上,那么对该计算机具有物理访问权限的人可以访问它。 This is a fundamental limitation of security, computer or otherwise. 这是安全性,计算机或其他方面的基本限制。

If it is a password that is fine for the user of your program to access, then Windows Credential Manager is in fact the best solution. 如果它是一个适合您的程序用户访问的密码,那么Windows Credential Manager实际上是最佳解决方案。 If you want the password inaccessible to the average other piece of software, then you can encrypt it. 如果您希望其他软件无法访问密码,则可以对其进行加密。 But note that since you are decrypting locally, it will always be possible given sufficient effort to reverse engineer that decryption, regardless of the means of securing it (ie whether you use Windows CM or not). 但请注意,由于您在本地进行解密,因此无论采取何种措施(无论您是否使用Windows CM),都可以通过充分的努力来对解密进行反向工程。

If you don't want even the user to be able to get at the password, then it's simply not possible to safety store the password on the local machine. 如果您甚至不希望用户能够获得密码,那么就不可能将密码安全地存储在本地计算机上。 You'd have to come up with some other means of access, such as having a server you control that applies the password as needed to the resource on behalf of the user. 您必须提出一些其他访问方式,例如让控制的服务器代表用户根据需要将密码应用于资源。 Of course, then you have the problem of authenticating the user; 当然,那么你就有了验证用户的问题; if someone discovers their password, then they wind up with that user's level of access to whatever resource you're trying to protect. 如果有人发现了他们的密码,那么他们最终会获得该用户对您要保护的资源的访问级别。

The bottom line: use the available tools, preferably built-in OS features. 底线:使用可用的工具,最好是内置的OS功能。 Don't put more effort into security than is justified by the value of the asset, and try really hard to reuse "official" security mechanisms rather than trying to reinvent your own. 不要把更多的精力放在安全上,而不是资产价值的合理性,并且尽量重用“官方”安全机制而不是试图重新发明自己的安全机制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM