使用 MD5 对保护敏感数据的密码进行哈希处理是否安全?

发布于 2024-11-15 18:37:21 字数 297 浏览 2 评论 0原文

我一直在和这个保安人员讨论。他可能是我为我的新项目最能负担得起的人。无论如何,它是一项保存用户可以通过电话请求的敏感数据(密码、PIN)的服务。用户有一个密码(4 位数字),用于访问敏感数据。安全人员告诉我,他将使用 MD5 对用于访问敏感数据的密码进行哈希处理。正如我所想的,讨论从这里开始,并且我非常确定,MD5 太脆弱了,因为它已经被破解/碰撞了。

应使用什么哈希方法来对保护敏感信息的密码进行哈希处理?我有一种感觉,这项服务可能会成为黑客的高价值目标,所以我真的很担心。我开始担心安全人员将提供的服务的整体质量,特别是安全性,但不知道在哪里可以找到其他人。

I've been in discussion with this security guy. He's probably the most I can afford for my new project. Anyways, it is a service that saves sensitive data (Password, PINs) that can be requested by the user via phone. The user has a password (4 digits) which he uses to access the sensitive data. The security guy told me he would use MD5 to hash the password that is used to access the sensitive data. Here the discussion started, as I thought, and am quite sure, that MD5 is too vulnerable since it has been cracked/collisions have been caused.

What hashing method should be used to hash passwords that protect sensitive information? I have a feeling that this service might become a high value target for hackers, so I'm really worried about it. I'm starting to worry about the overal quality, and especcialy security of services the security guy is going to deliver, but have no idea where to find others.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

甜味超标? 2024-11-22 18:37:21

我在这里看到了很多问题。

首先,如果四位密码足以阻止访问您的超级敏感数据,那么您就有麻烦了。我希望还有其他安全措施,因为手动暴力破解 10,000 个组合是微不足道的,更不用说使用某种脚本了。

其次,我不确定您是否理解对密码进行哈希处理的意义。我怀疑仅仅从 10,000 种可能性中你就会得到哈希冲突,但是当密码可以被暴力破解时,这基本上是无关紧要的。您所完成的一切只是对数据库具有读取访问权限的人进行的一点混淆。

第三,密码哈希算法的需求与其他哈希算法的需求不同。您需要算法很慢,这通常意味着必须重复运行它,并且您需要有盐,以便无法从查找表中导出密码。据说,河豚还不错。我发现 PostgreSQL 的 pgcrypto 文档有一个很好的解释。

I see a number of problems here.

First, if a four-digit passcode is all that is preventing access to your uber-sensitive data, you're in trouble. I hope that there are other security measures in place, since brute-forcing 10,000 combinations by hand is trivial, much less with some kind of script.

Second, I'm not sure you understand the point of hashing the passwords. I doubt you will get a hash collision just from 10,000 possibilities, but that is basically irrelevant when the passwords can be brute-forced. All you are accomplishing is a little bit of obfuscation from someone with read access to the database.

Third, the needs of a password hashing algorithm are different than the needs of other hashing algorithms. You need the algorithm to be slow, which usually means having to run it repeatedly, and you need for there to be salt so that the password cannot be derived from a lookup table. Supposedly, Blowfish isn't bad. I find the pgcrypto docs from PostgreSQL have a pretty good explanation.

暖心男生 2024-11-22 18:37:21

虽然 MD5 被破坏,但这些漏洞不会影响密码散列。因此,MD5 而不是更好的哈希函数并不是这里的问题。不过我通常建议使用更好的哈希函数。

通常使用某种方法来减慢哈希速度并添加盐。查看有关密钥派生函数的维基百科
PBKDF2 和 bcrypt 是 KDF 的流行选择。

但我想不出有什么办法可以保护4位数字的密码。只有 10,000 个不同的密码。暴力破解是微不足道的。即使是盐和 KDF 也无济于事。

使用低熵 PIN 的系统依赖于检查服务器/硬件永远不会受到损害。因此,他们可以在几次错误尝试后将攻击者拒之门外。但如果攻击者获得了密码哈希的访问权限,您就无法执行此操作。

While MD5 is broken, these vulnerabilities don't affect password hashing. So MD5 instead of better hash functions isn't the problem here. Still I generally recommend using a better hash function.

Normally use some method to hash slower and add a salt. Check Wikipedia on Key Deriviation Functions.
PBKDF2 and bcrypt are popular choices for KDFs.

But I can think of no way to protect a 4 digit password. There are only 10'000 different passwords. It's trivial to bruteforce. Even salts and KDFs won't help you.

Systems using low entropy PINs rely on the checking server/hardware never getting compromised. So they can lock an attacker out after a few wrong attempts. But you can't do that if the attacker gains access to the password hash.

浅忆 2024-11-22 18:37:21

想想看,为什么要对密码进行哈希处理?因为即使您的数据库被盗,入侵者也无法根据哈希找到密码。但是:如果您的密码空间为 4 位数字(10000 个组合),那么需要多长时间才能找到与给定 MD5 哈希值匹配的密码?一毫秒?使用任何现代哈希函数都会遇到相同的安全漏洞(MD5 现在不被认为是安全的)。

你需要的是用很长的盐腌制。为每个用户创建一些随机数据(称为)并计算哈希值(密码+盐)。显然,您没有存储密码,但您将存储每个用户的哈希值和盐。 第二个想法:带盐的 4 位密码仍然不安全 - 您得到的只是入侵者必须暴力破解 -强制每个用户输入密码,但对于 10K 密钥空间来说,这仍然是微不足道的。我不知道还有什么其他方法可以保护如此短的密码。

Think about it, why are you hashing passwords? Because even if your database is stolen, the intruder won't be able to find a password based on the hash. But: if the space of your passwords is 4 digits (10000 combinations), how long will it take to find a password that matches given MD5 hash? One millisecond? You will hit the same security vulnerability with any modern hash function (MD5 isn't considered secure nowadays).

What you need is salting with a very long salt. For each user create some random data (called salt) and compute hash(password + salt). You aren't obviously storing passwords, but you will store hashes and salts per each user. Second thought: 4-digit password with salt still isn't secure - all you get is that the intruder will have to brute-force password per each user, but with 10K key space this is still trivial. I don't know any other method that will protect such a short password.

中二柚 2024-11-22 18:37:21

是的,MD5 已被严重泄露。我建议您使用 PBKDF2 功能,这将提供更好的安全性。

MD5 安全

PBKDF2 维基百科文章

不过,我建议使用比 4 位数密码更强的密码。

Yes, MD5 is severly compromised. I would advice you to use a PBKDF2 functionality, which would provide a much better security.

MD5 security

PBKDF2 Wikipedia article

I would recommend using a stronger password than a 4 digit one, though.

酒几许 2024-11-22 18:37:21

有一种基于风险的简单方法可以解决这个问题。

根据定义,风险是危险乘以不良事件的概率。在这种情况下,您担心 MD5 哈希值被破解的可能性,这当然很重要。但是,对于只有 4 位数字长的 PIN,直接暴力攻击一次成功的概率仅为 10-4,因此根据数据的值,您很快就会得到不良风险。

无论如何,在一次试验中破解 MD5 的概率很可能远小于 10-4,所以他可能是正确的。

There is an easy method to figure this out, based on risk.

By definition, Risk is Hazard times probability of the undesired event. In this case, you're concerned about the probability of an MD5 hash being cracked, which is certainly significant. But with a PIN that's only 4 digits long, the probability of a straight out brute force attack succeeding in one try is only 10-4, so depending on the value of the data, you pretty quickly get to an undesirable risk.

In any case, the probability of cracking an MD5 in one trial is very likely much smaller than 10-4, so he's probably correct.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文