在 PHP 中使用 AES 加密时,应该在哪里存储密钥?
我正在我的网络应用程序中实现 AES-256 位加密:
http://www.utoxin.name/2009/07/automatic-db-field-encryption-in-cakephp/
其中一个步骤表示将使用的密码和密钥存储在 boostrap 文件中。但是,是什么阻止某人使用 PS 或其他东西扫描文件系统并解密数据呢?
保护数据的最佳方法是什么?
I am implementing AES-256 bit encrpytion in my web app:
http://www.utoxin.name/2009/07/automatic-db-field-encryption-in-cakephp/
One of the steps says to store the cipher used and key in a boostrap file. But what is stopping someone from scanning the file system with PS or something and decrypting the data?
What is the best way to secure the data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果有人可以访问您服务器硬盘上的所有文件,那么一切都将失败。那么你就无法保护你的数据,因为你的网络应用程序仍然必须能够访问它。
这种加密只能保护您免受可以访问数据库的攻击者的攻击,但不能保护文件系统(例如通过 SQL 注入)。即使在这种情况下,他们也可能能够读取数据:根据特定的泄漏情况,网络应用程序可能会很乐意为他们解密!
If someone has access to all files on the hard drive of your server, all bets are off. There is no way you can protect your data then, because your webapp still has to be able to access it.
This encryption will only protect you from attackers who can access the database, but not the file system, e.g. through SQL injection. And even in that case they may be able to read the data: depending on the particular leak, the webapp might happily decrypt it for them!
(我意识到这是一个古老的问题,但作为链接博客文章的作者,我想添加一些评论)
所接受的答案所说的都是正确的。一旦您的文件系统受到损害,就没有任何保护。另外,是的,如果写得不好,就有可能以未加密的形式暴露数据。该工具的目的只是提供一种方法,使处理数据库中数据的加密变得更加容易。如果您不喜欢自动解密功能,则删除该行为的 afterFind() 回调以使其不再触发以及任何可以提高安全性的其他调整(以方便)。
我希望这对偶然发现这篇文章的其他人有所帮助。有人已经这样做了,因为我的博客刚刚因为这个问题而受到了几次点击。 :)
(I realize this is an ancient question, but as the author of the linked blog post, I wanted to add some comments)
What the accepted answer says is all correct. Once your filesystem is compromised there's no protection. Also, yes, if poorly written it is possible to expose data in an unencrypted form. This tool was meant to simply provide a way to make it much easier to handle the encrypting of data in the database. If you don't like the auto-decrypt functionality, it would be trivial to remove the afterFind() callback on the behavior so that it no longer triggers, as well as any number of other adjustments that could improve security (at the cost of convenience).
I hope this helps anyone else who stumbles across this post. Someone has, since I just got a couple hits to my blog from this question. :)
在 unix 机器上,您可以将其存储到由 apache 用户帐户创建的文件中,权限为 0600。这可以通过 root 访问,所以如果盒子是安全的,就没有问题。在 Windows 盒子上,我不知道。
On a unix box you can store it into a file, created by the user account for apache, with 0600 permisions. This can be accessed by the root, so if the box it's secure there is no problem.On windows boxes, I don't know.